/* Toggler SIEMPRE con tamaño fijo (en TODOS los tamaños) */
#mainNav .navbar-toggler {
  width: 55px !important;
  height: 40px !important;
  padding: 0 !important;
  flex: 0 0 auto !important; /* no se estira */
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 999px !important;
}

/* Nunca mostrar toggler en pantallas grandes */
@media (min-width: 992px) {
  #mainNav .navbar-toggler {
    display: none !important;
  }
}

/* Drawer derecho elegante */
.kfl-offcanvas {
  width: 290px; /* ajusta a gusto */
  border-left: 1px solid rgba(0, 0, 0, 0.08);
}

.kfl-offcanvas .offcanvas-header {
  padding: 18px 18px 10px 18px;
}

.kfl-offcanvas .offcanvas-body {
  padding: 10px 18px 18px 18px;
}

/* Items tipo lista */
.kfl-mobile-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kfl-item {
  display: block;
  padding: 12px 12px;
  border-radius: 12px;
  color: #111;
  text-decoration: none;
}

.kfl-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.kfl-sep {
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
  margin: 6px 0 10px 0;
}

/* Asegura que el botón se vea bien dentro del drawer */
.kfl-offcanvas .custom-btn {
  height: 42px !important;
  border-radius: 14px !important;
}

.offcanvas {
  transition: transform 0.35s ease-in-out !important;
}

/* Fondo blanco limpio */
.kfl-offcanvas {
  background-color: #ffffff !important;
  color: #111 !important;
}

/* Header del drawer */
.kfl-offcanvas .offcanvas-header {
  border-bottom: 1px solid #eaeaea;
}

/* Texto del usuario */
.kfl-offcanvas strong {
  color: #111;
}

.kfl-item {
  color: #222 !important;
  font-weight: 500;
}

.kfl-item:hover {
  background-color: #f5f7fb;
  color: #000 !important;
}

.kfl-offcanvas .custom-btn {
  background: transparent !important;
  border-radius: 14px !important;
}

/* azul */
.kfl-offcanvas .custom-btn-primary {
  border: 2px solid #2563eb !important;
  color: #2563eb !important;
}

.kfl-offcanvas .custom-btn-primary:hover {
  background: #2563eb !important;
  color: #fff !important;
}

/* rojo */
.kfl-offcanvas .custom-btn-danger {
  border: 2px solid #dc3545 !important;
  color: #dc3545 !important;
}

.kfl-offcanvas .custom-btn-danger:hover {
  background: #dc3545 !important;
  color: #fff !important;
}

/* Botones custom fuera del offcanvas (navbar desktop) */
#mainNav .custom-btn {
  border-radius: 14px !important;
  border-width: 2px !important;
}

/* ===== TOGGLER OSCURO SIEMPRE (como al inicio) ===== */
#mainNav .navbar-toggler.kfl-toggler {
  background: #2f2f39 !important; /* fondo oscuro */
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18) !important;
}

/* Icono hamburguesa blanco (forzado) */
#mainNav .navbar-toggler.kfl-toggler .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255,255,255,0.95)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* Hover/active bonito */
#mainNav .navbar-toggler.kfl-toggler:hover {
  background: #24242c !important;
}
#mainNav .navbar-toggler.kfl-toggler:focus {
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25) !important;
}

/* pill del usuario (quita inline styles) */
#mainNav .kfl-userpill {
  background-color: #f8f9fa;
  border-radius: 20px;
  border: 1px solid #dee2e6;
  color: #000;
  font-weight: 700;
}

/* Links desktop más “navbar-like” */
#mainNav .kfl-actions .kfl-link {
  padding: 6px 10px;
  border-radius: 10px;
}

#mainNav .kfl-actions .kfl-link:hover {
  background: rgba(0, 0, 0, 0.05);
}

@media (min-width: 992px) {
  #mainNav .kfl-center-links {
    min-width: 0 !important; /* <-- clave: ya no fuerza ancho */
    justify-content: center !important;
    flex-wrap: wrap; /* por si queda apretado */
    row-gap: 6px;
  }
}

/* ===== MOBILE/TABLET ===== */
@media (max-width: 991.98px) {
  #mainNav .container-lg {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    row-gap: 10px !important;
  }

  /* fila izquierda: logo + titulo */
  #mainNav .kfl-left {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    display: flex !important;
    align-items: center !important;
  }

  #mainNav .kfl-left .navbar-brand {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    min-width: 0 !important;
    margin-right: 0 !important;
  }

  #mainNav .kfl-left .navbar-brand img {
    flex: 0 0 auto !important;
    width: 70px !important;
    height: 70px !important;
    margin-right: 0 !important;
  }

  #mainNav .kfl-left .navbar-brand span {
    display: block !important;
    min-width: 0 !important;
    white-space: normal !important;
    line-height: 1.15 !important;
    font-size: 1rem !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }

  /* caso general: si NO hay usuario, toggler queda arriba derecha */
  #mainNav .kfl-mobile-top {
    display: flex !important;
    align-items: center !important;
    width: auto !important;
    margin-left: auto !important;
    gap: 10px !important;
  }

  #mainNav .kfl-toggler-mobile {
    order: 2 !important;
    margin: 0 !important;
    margin-left: auto !important;
    flex: 0 0 auto !important;
  }

  /* cuando SI existe usuario, el contenedor baja a la segunda fila */
  #mainNav .kfl-mobile-top:has(.kfl-userpill-mobile) {
    width: 100% !important;
    margin-left: 0 !important;
  }

  /* usuario a la izquierda */
  #mainNav .kfl-userpill-mobile {
    order: 1 !important;
    flex: 0 1 auto !important;
    width: auto !important;
    margin: 0 !important;
    justify-content: flex-start !important;
  }

   #mainNav:has(.kfl-userpill-mobile) .kfl-left .navbar-brand span{
    font-size: 1.1rem !important;
    font-weight: bold;
  }

  #mainNav:has(.kfl-userpill-mobile) .kfl-left .navbar-brand img{
    width: 82px !important;
    height: 82px !important;
  }
}

/* ===== MOBILE: Pantallas muy pequeñas */
@media (max-width: 575.98px) {
  #mainNav .kfl-left .navbar-brand {
    gap: 8px !important;
  }

  #mainNav .kfl-left .navbar-brand img {
    width: 70px !important;
    height: 70px !important;
  }

  #mainNav .kfl-left .navbar-brand span {
    font-size: 0.9rem !important;
    line-height: 1.1 !important;
  }

  #mainNav .navbar-toggler {
    width: 50px !important;
    height: 38px !important;
  }
}

/* ===== DESKTOP: usuario a la izquierda + links centrados + logout derecha ===== */
@media (min-width: 992px) {
  #mainNav .kfl-navwrap {
    justify-content: flex-start !important;
  }

  #mainNav .kfl-left {
    flex: 0 0 auto !important;
  }

  #mainNav .kfl-center {
    flex: 1 1 auto !important; /* ocupa el espacio del medio */
    justify-content: center !important; /* centra los links */
  }

  #mainNav .kfl-right {
    flex: 0 0 auto !important;
  }

  #page #mainNav .kfl-center {
    justify-content: flex-end !important;
  }
}

/* ===== DESKTOP CHICO (992px - 1199px): evita desbordes ===== */
@media (min-width: 992px) and (max-width: 1199.98px) {
  /* reduce separación general */
  #mainNav .kfl-center-links {
    gap: 18px !important;
  }

  /* botón logout más compacto en ese rango */
  #mainNav .custom-btn {
    min-width: 0 !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    height: 38px !important;
    font-size: 0.95rem !important;
  }

  /* (opcional) pill usuario un poquito más compacto */
  #mainNav .kfl-userpill {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

.kfl-anchor {
  margin-top: 100px;
  position: relative;
  top: -210px; /* mismo alto aprox del navbar sticky */
  height: 0;
}
