/* =================================================================
   PalmaData — Sidebar moderno con navegacion contextual
   Estilo SaaS premium (Notion / Linear / Stripe), dark navy theme.
   ================================================================= */

.sb-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width, 260px);
  transition: width 0.28s ease;
  display: flex;
  flex-direction: column;
  background: linear-gradient(to bottom, #041E42, #0D4E8A);
  color: #ffffff;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  z-index: var(--z-sidebar, 1000);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.sb-sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('../img/palm-leaf.jpg') center/cover no-repeat;
  opacity: 0.08;
  pointer-events: none;
  z-index: 0;
}

.sb-sidebar > * { position: relative; z-index: 1; }

/* Scrollbar discreto */
.sb-sidebar *::-webkit-scrollbar       { width: 4px; }
.sb-sidebar *::-webkit-scrollbar-track { background: transparent; }
.sb-sidebar *::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); border-radius: 2px; }
.sb-sidebar *::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

/* ---------- Brand ---------- */
.sb-brand {
  padding: 0 5px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  line-height: 0;
}

.sb-brand-link { display: block; text-decoration: none; line-height: 0; }
.sb-brand-link:hover { text-decoration: none; }

.sb-brand-logo {
  width: 60%;
  height: auto;
  margin: -8px auto -10px;
  display: block;
}

.sb-brand-tagline {
  font-size: 10px;
  font-style: italic;
  color: rgba(255, 255, 255, 0.62);
  line-height: 1.2;
  padding: 0 10px 6px;
  margin-top: -28px;
  text-align: center;
}

/* ---------- Slider (main <-> submenu) ---------- */
.sb-slider {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.sb-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.22s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sb-view-main { transform: translateX(0);     opacity: 1; }
.sb-view-sub  { transform: translateX(100%);  opacity: 0; pointer-events: none; }

.sb-slider.sb-show-sub .sb-view-main {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}
.sb-slider.sb-show-sub .sb-view-sub {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Nav (main) ---------- */
.sb-nav {
  display: flex;
  flex-direction: column;
  padding: 4px 10px 10px;
  gap: 0;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: left;
  width: 100%;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
  font-family: inherit;
  line-height: 1.25;
}

.sb-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  text-decoration: none;
}

.sb-item:focus-visible {
  outline: 2px solid #00A9E0;
  outline-offset: 1px;
}

.sb-item.active {
  background: rgba(0, 169, 224, 0.16);
  color: #ffffff;
}

.sb-item-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.92;
}

.sb-item-label {
  flex: 1;
  min-width: 0;
}

.sb-item-chevron {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  transition: transform 0.16s ease, color 0.16s ease;
}

.sb-item:hover .sb-item-chevron { color: #ffffff; transform: translateX(2px); }

/* ---------- Submenu ---------- */
.sb-sub-header {
  display: flex;
  align-items: center;
  padding: 10px 14px 6px;
  flex-shrink: 0;
}

.sb-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  width: fit-content;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}

.sb-back:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.sb-back i { font-size: 11px; }


/* Wrap + dos pistas para animar slide horizontal entre niveles de submenu */
.sb-sub-track-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.sb-sub-track {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 6px 10px 14px;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.22s ease;
  will-change: transform, opacity;
}

.sb-sub-track-active             { transform: translateX(0);     opacity: 1; }
.sb-sub-track-incoming-forward   { transform: translateX(100%);  opacity: 0; pointer-events: none; }
.sb-sub-track-incoming-back      { transform: translateX(-100%); opacity: 0; pointer-events: none; }
.sb-sub-track-outgoing-forward   { transform: translateX(-100%); opacity: 0; pointer-events: none; }
.sb-sub-track-outgoing-back      { transform: translateX(100%);  opacity: 0; pointer-events: none; }

.sb-sub-item {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.25;
  transition: background 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
  position: relative;
}

.sb-sub-item::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  margin-right: 10px;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}

.sb-sub-item-label {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.sb-sub-item-logo {
  height: 18px;
  width: auto;
  flex-shrink: 0;
  margin-left: 8px;
  opacity: 0.92;
}

.sb-sub-item-chevron {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  margin-left: 8px;
  flex-shrink: 0;
  transition: transform 0.16s ease, color 0.16s ease;
}
.sb-sub-item:hover .sb-sub-item-chevron {
  color: #ffffff;
  transform: translateX(2px);
}


.sb-sub-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  padding-left: 16px;
}
.sb-sub-item:hover::before {
  background: #00A9E0;
  transform: scale(1.4);
}

/* Estado activo: item seleccionado (módulo mostrándose en el mapa). */
.sb-sub-item.active {
  background: rgba(0, 169, 224, 0.12);
  color: #ffffff;
  padding-left: 16px;
}
.sb-sub-item.active::before {
  background: #00A9E0;
  transform: scale(1.4);
}

.sb-sub-item:focus-visible {
  outline: 2px solid #00A9E0;
  outline-offset: 1px;
}

/* ---------- Info box (área contextual) ---------- */
.sb-info-box {
  margin: 10px 12px 8px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: transparent;
  font-size: 11.5px;
  font-style: italic;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
  flex-shrink: 0;
  max-height: 30vh;
  overflow-y: auto;
}

.sb-info-box a {
  color: #B8E6FF;
  text-decoration: underline;
  font-style: italic;
}

.sb-info-box a:hover {
  color: #ffffff;
}

/* ---------- Footer ---------- */
.sb-footer {
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  flex-shrink: 0;
}

.sb-footer-caption {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  font-style: italic;
  line-height: 1.3;
}

.sb-footer-caption-small {
  font-size: 9px;
  margin-top: 4px;
}

.sb-footer-logo {
  display: block;
  margin: 6px auto;
  width: 110px;
  max-width: 100%;
  height: auto;
}

/* ---------- Mobile drawer ---------- */
.sb-hamburger {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(0, 31, 71, 0.92);
  color: #ffffff;
  font-size: 16px;
  /* Por encima de todos los overlays de módulo (ENOS z-index 1200,
     paneles fullscreen 1002, bottom-sheets 5000) para que el botón esté
     siempre disponible en móvil; por debajo del drawer (5500) que lo
     cubre al abrirse. */
  z-index: 5400;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: calc(var(--z-sidebar, 1000) - 1);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sb-overlay.active { display: block; opacity: 1; }

@media (max-width: 768px) {
  .sb-sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.35);
    width: 280px;
    /* Sobre los paneles fullscreen (Descargas/Boletines, z-index 1002) y
       los bottom-sheets (z-index 5000); sin esto el drawer se abría
       detrás del panel de Descargas y parecía no responder. */
    z-index: 5500;
  }
  .sb-sidebar.sb-open { transform: translateX(0); }
  .sb-overlay { z-index: 5499; }
  .sb-hamburger { display: inline-flex; align-items: center; justify-content: center; }
  /* En móvil el botón colapsar actúa como cierre del drawer: mostrar
     un icono de cerrar (✕) en lugar del de barras. */
  .sb-collapse-btn i::before { content: "\f00d"; }
}

/* ---------- Botón colapsar / expandir el menú ---------- */
.sb-collapse-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  z-index: 3;
  transition: background 0.15s ease, color 0.15s ease;
}
.sb-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

/* ---------- Estado colapsado: solo iconos de módulos ---------- */
body.sidebar-collapsed .sb-item-label,
body.sidebar-collapsed .sb-item-chevron,
body.sidebar-collapsed .sb-brand-logo,
body.sidebar-collapsed .sb-brand-tagline,
body.sidebar-collapsed .sb-info-box,
body.sidebar-collapsed .sb-footer {
  display: none;
}
body.sidebar-collapsed .sb-brand {
  min-height: 44px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
body.sidebar-collapsed .sb-collapse-btn {
  right: 50%;
  transform: translateX(50%);
}
body.sidebar-collapsed .sb-item {
  justify-content: center;
  gap: 0;
  padding: 8px 0;
}
body.sidebar-collapsed .sb-nav {
  padding: 6px 8px 10px;
}
body.sidebar-collapsed .sb-item-icon {
  width: 22px;
  height: 22px;
}
