/* ==========================================================================
   SIDEBAR (menú hamburguesa) + OVERLAY oscuro
   Modo claro: verde jade #1A4A3A — igual que el topbar
   Modo oscuro: cielo profundo #0F1722 — igual que el topbar
   ========================================================================== */

.sidebar {
  position: fixed;
  top: 0;
  left: -40rem;
  height: 100%;
  background: var(--verde-marca);
  padding: 0;
  transition: left 0.3s ease, background 0.4s ease;
  z-index: var(--z-sidebar);
  box-shadow: .8rem 0 4rem rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar.active {
  left: 0;
  width: clamp(28rem, 78%, 40rem); /* min 280px · 78% en móvil · max 400px en tablet */
}

/* Línea derecha — degradado dorado */
.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: .1rem;
  height: 100%;
  background: var(--linea-oro-v);
  pointer-events: none;
  z-index: 1;
}

/* Modo oscuro */
[data-tema="oscuro"] .sidebar {
  background: var(--azul-noche);
}

/* Variables de texto según tema */
[data-tema="claro"] .sidebar {
  --sidebar-texto:        #F2EDE4;
  --sidebar-hover:        rgba(201, 164, 76, 0.10);   /* dorado cálido */
  --sidebar-activo-bg:    rgba(201, 164, 76, 0.16);
  --sidebar-borde:        rgba(242, 237, 228, 0.15);
}
[data-tema="oscuro"] .sidebar {
  --sidebar-texto:        #E5E7EB;
  --sidebar-hover:        rgba(100, 130, 180, 0.10);
  --sidebar-activo-bg:    rgba(100, 130, 180, 0.18);
  --sidebar-borde:        rgba(229, 231, 235, 0.12);
}

/* ====== HEADER DEL SIDEBAR — patrón + logo ====== */
.sidebar-header {
  position: relative;
  height: 7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2rem;
  flex-shrink: 0;
  overflow: hidden;
}

/* Patrón ornamental como marca de agua — mismo que el topbar */
.sidebar-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("../../img/ornamento-topbar.svg");
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position: left center;
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

[data-tema="oscuro"] .sidebar-header::before {
  opacity: 0.25;
}

/* Línea inferior del header */
.sidebar-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: .2rem;
  background: var(--linea-oro-h);
  z-index: 1;
  pointer-events: none;
}

/* Botón cerrar — círculo estilo píldora, igual que el tema-toggle */
.close-btn {
  position: absolute;
  top: 50%;
  right: 1.6rem;
  transform: translateY(-50%);
  background: var(--verde-marca);
  border: .2rem solid #C9A44C;       /* mismo grosor y color que el tema-toggle */
  color: var(--sidebar-texto, #F2EDE4);
  width: 3.6rem;
  height: 3.6rem;
  border-radius: var(--radio-redondo);
  font-size: 1.5rem;
  font-weight: 600;
  transition:
    background     var(--transicion-media),
    border-color   var(--transicion-media),
    color          var(--transicion-media),
    transform      0.25s ease;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.close-btn:hover {
  background: rgba(201, 164, 76, 0.15);
  border-color: #FFE080;
  color: #FFE080;                    /* ← la X se torna amarilla */
  transform: translateY(-50%) rotate(90deg);
}
[data-tema="oscuro"] .close-btn {
  background: var(--azul-noche);
  border-color: #C9A44C;
}
[data-tema="oscuro"] .close-btn:hover {
  border-color: #B8C8E8;
  color: #B8C8E8;
  background: rgba(100, 130, 180, 0.12);
  transform: translateY(-50%) rotate(90deg);
}

/* Logotipo centrado */
.sidebar-logotipo {
  font-family: var(--fuente-titulos);
  font-weight: 700;
  font-size: 2.8rem;
  color: var(--sidebar-texto, #F2EDE4);
  text-decoration: none;
  position: relative;
  z-index: 2;
  letter-spacing: .05em;
}

/* ====== NAV ====== */
.auth {
  margin-top: 1.6rem;
  padding: 0 1.6rem;
  flex: 1;
  position: relative;
  z-index: 1; /* sobre el astronauta absoluto */
}

/* ====== ITEMS DE NAVEGACIÓN (compartidos por hamburguesa y sidebar fijo) ====== */
.auth a,
.psn-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  text-decoration: none;
  color: var(--sidebar-texto, #F2EDE4);
  font-family: var(--fuente-titulos);
  font-size: 1.7rem;
  letter-spacing: .03em;
  padding: 1.2rem 1.4rem;
  border-radius: var(--radio-sm);
  border-left: .3rem solid transparent;
  transition:
    background  var(--transicion-media),
    border-color var(--transicion-media),
    color       var(--transicion-media),
    padding-left var(--transicion-media);
}

.auth a:hover,
.psn-link:hover {
  background: rgba(201, 164, 76, 0.10);
  border-left-color: rgba(201, 164, 76, 0.55);
  padding-left: 1.6rem;
}

/* Página activa */
.auth a.activo,
.psn-link.activo {
  background: rgba(201, 164, 76, 0.16);
  border-left-color: #C9A44C;
  color: #FFE080;
  font-weight: 700;
  padding-left: 1.6rem;
}
[data-tema="oscuro"] .auth a.activo,
[data-tema="oscuro"] .psn-link.activo {
  color: #B8C8E8;
  border-left-color: rgba(100, 130, 180, 0.9);
  background: rgba(100, 130, 180, 0.18);
}

/* Iconos a la izquierda del texto, en ambos sidebars */
.psn-link-icon {
  font-size: 1.4rem;
  width: 1.8rem;
  text-align: center;
  flex-shrink: 0;
}
svg.psn-link-icon {
  height: 1.8rem;
  color: currentColor;
}

/* ====== ASTRONAUTA DE PALENQUE — fondo decorativo ====== */
.sidebar-astronauta {
  position: absolute;
  top: 7rem;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 0;
}
.sidebar-astronauta img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  opacity: 0.18;               /* ligeramente más sutil */
}

/* ====== CERRAR SESIÓN (sidebar privado) ====== */
.sidebar-salir {
  margin-top: auto;          /* empuja este botón + footer al fondo */
  margin-bottom: 1.6rem;     /* separación de la línea dorada del footer */
  display: flex;
  align-items: center;
  gap: 1rem;
  /* width: el stretch del sidebar (flex column) + los márgenes laterales
     de 1.6rem producen el mismo ancho que calc(100% - 3.2rem) */
  margin-left: 1.6rem;
  margin-right: 1.6rem;
  padding: 1.2rem 1.4rem;
  border-left: .3rem solid transparent;
  border-radius: var(--radio-sm);
  color: #F08080;
  font-family: var(--fuente-titulos);
  font-size: 1.6rem;
  letter-spacing: .03em;
  text-align: left;
  transition: background var(--transicion-media), border-color var(--transicion-media);
}
.sidebar-salir:hover {
  background: rgba(226, 75, 74, .12);
  border-left-color: rgba(240, 128, 128, .6);
}
.sidebar-salir-icon {
  width: 1.7rem;
  height: 1.7rem;
  flex-shrink: 0;
}

/* ====== FOOTER — toggle de tema ====== */
.sidebar-footer {
  padding: 2rem 1.8rem;
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.4rem;
  flex-shrink: 0;
}

/* Divisor del footer — degradado dorado horizontal */
.sidebar-footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: .1rem;
  background: var(--linea-oro-h);
}

/* Toggle del sidebar — mismo diseño, tamaño ligeramente menor */
.sidebar-footer .tema-toggle {
  width: 7.2rem;
  height: 3.6rem;
  padding: .7rem;
  flex-shrink: 0;
}
[data-tema="claro"] .sidebar-footer .tema-toggle .t-ball {
  top: .7rem;
  left: .7rem;
  transform: translateX(3.4rem);
}

.sidebar-tema-label {
  color: var(--sidebar-texto, #F2EDE4);
  font-family: var(--fuente-texto);
  font-size: 1.35rem;
  opacity: 0.75;
  letter-spacing: .02em;
}

/* ====== OVERLAY ====== */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transition: 0.3s;
  z-index: var(--z-overlay);
}
.overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Blur del contenido principal cuando el sidebar está abierto */
.app.blur {
  filter: blur(.4rem) brightness(0.85);
}

/* ====== DESKTOP — sidebar oculto ====== */
@media (min-width: 1024px) {
  .sidebar,
  .overlay {
    display: none;
  }
}

/*
  NOTA — link activo (.activo):
  En hamburguesa.js (o en cada HTML), agrega al abrir el sidebar:

    document.querySelectorAll('.auth a').forEach(a => {
      a.classList.toggle('activo', a.href.includes(location.pathname.split('/').pop()));
    });

  O más simple: añade clase .activo directamente en el HTML de cada página,
  en el link que corresponde a esa página.
*/
