/* ═══════════════════════════════════════════════════════════════════
   SIDEBAR DE NAVEGACIÓN COMPARTIDO — Proyectos RG
   ═══════════════════════════════════════════════════════════════════ */

/* Colores del menú: dorado de la marca RG (cambiar aquí y se cambia en todas las páginas) */
:root {
  --rg-menu-fondo: #7a5c24;
  --rg-menu-fondo-hover: #8c6a2f;
  --rg-menu-activo-fondo: rgba(255, 240, 205, 0.2);
  --rg-menu-activo-texto: #fff3d6;
}

/* Ocultar login instantáneamente si ya hay sesión guardada */
html.snav-authed #loginOverlay,
html.snav-authed #loginScreen {
  display: none !important;
}


.snav-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 240px;
  height: 100vh;
  background: var(--rg-menu-fondo);
  display: flex;
  flex-direction: column;
  z-index: 1200;
  transition: width 0.24s cubic-bezier(.4,0,.2,1), transform 0.28s cubic-bezier(.4,0,.2,1), box-shadow 0.24s ease;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid rgba(255,255,255,0.06);
}

.snav-logo-area {
  padding: 22px 20px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  position: relative;
}
.snav-logo-area img {
  height: 38px;
  width: auto;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

/* Botón para esconder el menú (dentro del sidebar) */
.snav-brand-copy { min-width: 0; }
.snav-logo-text {
  color: rgba(255,255,255,0.85);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.snav-logo-sub {
  color: rgba(255,255,255,0.65);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.snav-section-label {
  color: rgba(255,255,255,0.6);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 20px 20px 6px;
}

.snav-links {
  flex: 1;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.snav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.snav-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.snav-icon svg { width: 100%; height: 100%; }
.snav-label { min-width: 0; }
.snav-link:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
}
.snav-link.active {
  background: var(--rg-menu-activo-fondo);
  color: var(--rg-menu-activo-texto);
  font-weight: 600;
}
/* Submenu toggle chevron */
.snav-chevron {
  margin-left: auto;
  font-size: 0.85rem;
  transition: transform 0.2s ease;
  opacity: 0.4;
}
.snav-has-children.expanded .snav-chevron {
  transform: rotate(90deg);
}

/* Submenu children container */
.snav-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s cubic-bezier(.4,0,.2,1);
}
.snav-children.expanded {
  max-height: 500px;
}

/* Child items */
.snav-child {
  padding-left: 44px !important;
  font-size: 0.8rem !important;
  padding-top: 8px !important;
  padding-bottom: 8px !important;
  color: rgba(255,255,255,0.78) !important;
}
.snav-child:hover {
  color: rgba(255,255,255,0.8) !important;
}
.snav-child.active {
  color: var(--rg-menu-activo-texto) !important;
  background: var(--rg-menu-activo-fondo) !important;
}

/* Grandchildren (second-level submenu) */
.snav-grandchildren {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s cubic-bezier(.4,0,.2,1);
}
.snav-grandchildren.expanded {
  max-height: 200px;
}
.snav-grandchild {
  padding-left: 62px !important;
  font-size: 0.75rem !important;
  padding-top: 7px !important;
  padding-bottom: 7px !important;
  color: rgba(255,255,255,0.72) !important;
}
.snav-grandchild:hover {
  color: rgba(255,255,255,0.8) !important;
}
.snav-grandchild.active {
  color: var(--rg-menu-activo-texto) !important;
  background: var(--rg-menu-activo-fondo) !important;
}
.snav-bottom {
  padding: 12px 10px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.snav-asesor-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  margin-bottom: 6px;
}
.snav-asesor-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--rg-menu-activo-fondo);
  color: var(--rg-menu-activo-texto);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.snav-asesor-name {
  color: rgba(255,255,255,0.75);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.snav-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #ffd8d1;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: all 0.15s;
}
.snav-logout:hover {
  background: rgba(160,40,30,0.25);
  color: #ffffff;
}

/* Hamburger button (mobile) */
.snav-hamburger {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1300;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: var(--rg-menu-fondo);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  transition: background 0.15s;
}
.snav-hamburger:hover {
  background: var(--rg-menu-fondo-hover);
}

/* Overlay for mobile */
.snav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1190;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.snav-overlay.visible {
  opacity: 1;
}

/* Content area offset */
.snav-page-content {
  margin-left: 240px;
  min-height: 100vh;
  transition: margin-left 0.28s cubic-bezier(.4,0,.2,1);
}

/* Escritorio: barra compacta permanente. */
@media (min-width: 901px) {
  .snav-sidebar {
    width: 76px;
    scrollbar-width: none;
  }
  .snav-sidebar::-webkit-scrollbar { width: 0; height: 0; }
  .snav-logo-area {
    min-height: 62px;
    padding: 12px 8px;
    justify-content: center;
  }
  .snav-logo-area img { height: 29px; }
  .snav-brand-copy {
    display: none;
  }
  .snav-links { padding: 7px 6px; gap: 2px; }
  .snav-section-label {
    height: 1px;
    padding: 0;
    margin: 8px 11px 4px;
    overflow: hidden;
    color: transparent;
    border-top: 1px solid rgba(255,255,255,0.07);
  }
  .snav-link {
    min-height: 49px;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 6px 3px;
    text-align: center;
  }
  .snav-link .snav-icon { width: 18px; height: 18px; }
  .snav-link > .snav-label {
    width: 100%;
    max-width: 64px;
    font-size: 0.5rem;
    line-height: 1.1;
    text-align: center;
    white-space: normal;
  }
  .snav-chevron { display: none; }
  .snav-children,
  .snav-grandchildren {
    max-height: 0 !important;
  }
  .snav-bottom { padding: 8px 6px 12px; }
  .snav-asesor-badge {
    justify-content: center;
    padding: 7px 3px;
  }
  .snav-asesor-name { display: none; }
  .snav-logout {
    min-height: 47px;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 6px 3px;
    text-align: center;
  }
  .snav-logout .snav-icon { width: 17px; height: 17px; }
  .snav-logout .snav-label { font-size: 0.49rem; line-height: 1.05; }
  .snav-page-content { margin-left: 76px; }
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .snav-sidebar {
    transform: translateX(-100%);
  }
  .snav-sidebar.open {
    transform: translateX(0);
  }
  .snav-hamburger {
    display: flex;
  }
  .snav-overlay {
    display: block;
    pointer-events: none;
  }
  .snav-overlay.visible {
    pointer-events: auto;
  }
  .snav-page-content {
    margin-left: 0;
  }
}
