/* ==============================================
   NAVBAR UNIFIED STYLES
   Homologación visual para todos los módulos
   ============================================== */

/* GEOMETRÍA DE BOTONES CIRCULARES */
.navbar .btn.btn-circle, 
.navbar .btn-circle {
  display: inline-flex !important; /* Force flex to override swap grid */
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  border-radius: 50% !important;
  overflow: hidden; /* Ensure content doesn't spill */
  aspect-ratio: 1 / 1; /* Garantizar círculo perfecto */
}

/* TAMAÑO UNIFICADO (Small - 32px) */
.navbar .btn-circle.btn-sm {
  width: 2rem !important;
  height: 2rem !important;
  min-height: 2rem !important;
  min-width: 2rem !important;
  max-width: 2rem !important;
  max-height: 2rem !important;
}

/* CENTRADO DE ÍCONOS (Lucide/SVG) */
.navbar .btn-circle i,
.navbar .btn-circle svg {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
}

/* CORRECCIÓN PARA COMPONENTE SWAP (Theme Toggle) */
.navbar .swap {
  display: inline-flex !important; /* Override DaisyUI grid */
  position: relative;
  /* Reset de dimensiones internas */
  width: 100%;
  height: 100%;
}

.navbar .swap input {
  /* Asegurar que el input no rompa el layout */
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  cursor: pointer;
}

.navbar .swap .swap-on, 
.navbar .swap .swap-off {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 1.25rem; /* 20px - Ajustado para btn-sm */
  height: 1.25rem;
  margin: 0;
  padding: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.navbar .swap .swap-on { opacity: 0; }
.navbar .swap .swap-off { opacity: 1; }
.navbar .swap input:checked ~ .swap-on { opacity: 1; }
.navbar .swap input:checked ~ .swap-off { opacity: 0; }

/* CORRECCIÓN PARA COMPONENTE AVATAR (Profile) */
.navbar .avatar {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

.navbar .avatar > div {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100% !important;
  height: 100% !important;
  border-radius: 50% !important;
  padding: 0 !important;
  margin: 0 !important;
  /* Ring adjustments if needed */
}

.navbar .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ESTILOS VISUALES GENERALES */
.navbar {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-bottom: 1px solid rgba(249, 115, 22, 0.2);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

[data-theme="winter"] .navbar {
  background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
  border-bottom: 1px solid rgba(249, 115, 22, 0.2);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.navbar .btn-ghost:hover {
  background-color: rgba(249, 115, 22, 0.1);
  color: #F97316;
}

.navbar .divider-horizontal {
  background-color: rgba(249, 115, 22, 0.3);
  width: 1px;
  height: 32px;
  margin: 0 8px;
}

.navbar .avatar .ring-orange-500 { --tw-ring-color: #F97316; }

/* ==============================================
   ALERTAS FIJAS (S6)
   Una alerta `position: fixed` no puede pintarse encima del chrome. Este
   componente la ancla por debajo del navbar (64 px) o al pie, y le pone un
   ancho que nunca excede el viewport, así que tampoco genera scroll
   horizontal en móvil. Vive aquí porque es geometría del navbar, no del
   módulo que la lanza.
   ============================================== */
.mi-alert-fixed {
  position: fixed;
  top: calc(var(--mi-navbar-height, 4rem) + 0.75rem);
  right: 1rem;
  left: auto;
  width: auto;
  max-width: min(24rem, calc(100vw - 2rem));
  z-index: 50;
  margin: 0;
}

.mi-alert-fixed.mi-alert-fixed-bottom {
  top: auto;
  bottom: 1rem;
}

@media (max-width: 640px) {
  .mi-alert-fixed {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

/* ==============================================
   MÓVIL (S5): el navbar es una sola fila de chrome accionable
   A 390 px el cluster de accesos rápidos (5 botones), el título del
   módulo y la marca compiten por el ancho y empujan el final del navbar
   fuera del viewport. Se retira lo redundante -el título ya lo dice el
   contenido de la página; el cluster es un atajo, no la navegación- y se
   conserva el chrome accionable: regresar, marca, tema y menú de usuario.
   ============================================== */
@media (max-width: 640px) {
  .mi-navbar {
    gap: 0.25rem;
    padding-inline: 0.5rem;
  }

  .mi-navbar .navbar-start,
  .mi-navbar .navbar-end {
    gap: 0.25rem;
    min-width: 0;
    padding-inline: 0;
  }

  .mi-navbar .mi-navbar-cluster,
  .mi-navbar .mi-navbar-title {
    display: none;
  }

  /* Los separadores verticales no aportan cuando sólo quedan cuatro
     controles: el espaciado ya los agrupa. */
  .mi-navbar .divider-horizontal {
    display: none;
  }

  /* La marca puede encogerse en vez de empujar el resto del navbar. */
  .mi-navbar .navbar-end > a[href="/main/"] {
    min-width: 0;
    padding-inline: 0.25rem;
    overflow: hidden;
  }

  .mi-navbar .navbar-end > a[href="/main/"] svg {
    width: auto;
    max-width: 108px;
  }
}



/* ---------------------------------------------------------------- S11 ---- */
/* El avatar de perfil debe quedar centrado verticalmente con el resto de la
   barra. El contenedor `.dropdown` es `display: block`, así que alineaba su
   botón (32px) al tope de una caja de 37px y quedaba ~2.5px más arriba que el
   toggle de tema. */
.navbar-end .dropdown {
    display: flex;
    align-items: center;
}


/* ---------------------------------------------------------------- S14 ---- */
/* Toggle de tema: un solo icono por estado, geométricamente centrado en el
   círculo del botón. El `swap` de DaisyUI aplica una transformación a `.swap-on`
   y desplazaba el sol dentro del botón en todos los módulos. */
.theme-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 0;
}

.theme-toggle #theme-toggle {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.theme-toggle .theme-toggle-icon {
    /* `!important` porque otros sheets del shell fijan `svg { display:flex }`. */
    display: none !important;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    flex: 0 0 auto;
}

.theme-toggle #theme-toggle:not(:checked) ~ .theme-toggle-icon-moon,
.theme-toggle #theme-toggle:checked ~ .theme-toggle-icon-sun {
    display: block !important;
}

/* Los íconos de módulo de la barra: el de la opción ACTIVA en el naranja de
   marca y los demás en el gris atenuado, para que la opción activa se lea de
   un vistazo (odd/tasks/cotizaciones-modulo-de-primer-nivel.md, S5).
   El color viene de los tokens del sistema de diseño, así que cambia con el
   tema sin tocar el markup. */
.mi-nav-icon {
    color: var(--cb-text-muted, #9CA3AF);
}

.mi-nav-icon.is-active {
    color: var(--cb-orange-primary, #F97316);
}
