/* ── nav.css ── */

:root {
  --sidebar-width: 260px;
}

body.nav-wide {
  --sidebar-width: 320px;
}

/* ── Layout Principal ── */
.layout-wrapper {
  display: block;
  min-height: 100vh;
}

/* ── Sidebar de Navegación (fixed — siempre visible) ── */
.sidebar {
  width: var(--sidebar-width);
  background: #172033;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 52px 0 32px;
  box-shadow: 2px 0 18px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  z-index: 999;
  transition: transform 0.27s cubic-bezier(0.4, 0, 0.2, 1), width 0.27s cubic-bezier(0.4, 0, 0.2, 1);
  /* Scrollbar delgado */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.sidebar-brand {
  padding: 0 24px 14px;
  margin-bottom: 4px;
}
.sidebar-brand__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.sidebar-brand h2 {
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.05em;
  margin: 0;
  border: none;
  padding: 0;
  line-height: 1.3;
}
.sidebar-brand p {
  color: #b8892f;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-top: 4px;
}

.nav-width-toggle {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(184, 137, 47, 0.35);
  background: rgba(255, 255, 255, 0.05);
  color: #f8c66a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.nav-width-toggle:hover {
  background: rgba(184, 137, 47, 0.18);
  color: #fff;
  border-color: rgba(184, 137, 47, 0.65);
}
.nav-width-toggle:focus-visible {
  outline: 2px solid #b8892f;
  outline-offset: 2px;
}

.sidebar-title {
  color: rgba(255, 255, 255, 0.62);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 24px 6px;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
}

/* Variante clickable / colapsable — banda compacta */
.sidebar-title--toggle {
  position: relative;
  background: rgba(184, 137, 47, 0.08);
  border: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  font-family: inherit;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.04em;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 9px 24px;
  margin: 0;
  outline: none;
  transition: color .15s ease, background .15s ease;
  line-height: 1.3;
}
.sidebar-title--toggle > span {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Acento lateral dorado: marcado cuando el grupo está expandido */
.sidebar-title--toggle::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: #b8892f;
  border-radius: 0 3px 3px 0;
  transition: height .2s ease;
}
.sidebar-title--toggle:not(.is-collapsed)::before {
  height: 60%;
}
.sidebar-title--toggle:hover {
  color: #fff;
  background: rgba(184, 137, 47, 0.18);
}
.sidebar-title--toggle:focus-visible {
  outline: 2px solid #b8892f;
  outline-offset: -2px;
}
.sidebar-title__chev {
  font-size: 9px;
  opacity: 0.7;
  flex-shrink: 0;
  transition: transform .25s cubic-bezier(0.4, 0, 0.2, 1), opacity .15s ease;
  color: #b8892f;
}
.sidebar-title--toggle:hover .sidebar-title__chev { opacity: 1; }
.sidebar-title--toggle.is-collapsed .sidebar-title__chev {
  transform: rotate(-90deg);
}

/* Colapsable con animación de altura suave (grid-template-rows 1fr→0fr).
   Independiente del alto del contenido: sin clipping ni saltos. */
.sidebar-nav {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows .28s cubic-bezier(0.4, 0, 0.2, 1),
              opacity .2s ease;
}
.sidebar-nav__inner {
  display: flex;
  flex-direction: column;
  min-height: 0;       /* permite que el grid colapse a 0 */
  overflow: hidden;
  padding: 2px 0 6px;
}

.sidebar-nav--group.is-collapsed {
  grid-template-rows: 0fr;
  opacity: 0;
  pointer-events: none;
}

/* Badges en links del sidebar */
.nav-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
  letter-spacing: .3px;
  line-height: 1.2;
  vertical-align: middle;
}
.nav-badge--v2  { background: #ea580c; color: #fff; }
.nav-badge--new { background: #059669; color: #fff; }
.nav-badge--hint { background: #dc2626; color: #fff; box-shadow: 0 0 0 1px rgba(254, 202, 202, 0.65) inset; min-width: 18px; text-align: center; padding: 2px 5px; }
.nav-badge--wp  { background: #5b21b6; color: #fff; }
.nav-badge--ppt { background: #dc2626; color: #fff; box-shadow: 0 0 0 1px #fca5a5 inset; }
.nav-badge--doc { background: #0ea5e9; color: #fff; }

.sidebar-nav a .nav-label { flex: 1; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  border-left: 4px solid transparent;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav a i {
  font-size: 13px;
  width: 15px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border-left-color: rgba(184, 137, 47, 0.6);
}

.sidebar-nav a.active {
  color: #fff;
  background: rgba(184, 137, 47, 0.20);
  border-left-color: #b8892f;
  box-shadow: inset 6px 0 0 rgba(184,137,47,0.04);
}
.sidebar-nav a.active i { opacity: 1; }

/* ── Botón toggle ── */
.nav-toggle {
  position: fixed;
  top: 18px;
  left: calc(var(--sidebar-width) - 13px);
  width: 26px;
  height: 26px;
  background: #172033;
  border: 2px solid rgba(184, 137, 47, 0.55);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b8892f;
  font-size: 9px;
  z-index: 1001;
  transition: left 0.27s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.27s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.15s;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.nav-toggle:hover {
  background: #1e3a5f;
  color: #fff;
  border-color: #b8892f;
}
.nav-toggle:focus-visible {
  outline: 2px solid #b8892f;
  outline-offset: 2px;
}

/* ── Backdrop (mobile) ── */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ── Contenido Principal ── */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 36px 48px;
  background: #f4f6f9;
  overflow-x: hidden;
  min-height: 100vh;
  transition: margin-left 0.27s cubic-bezier(0.4, 0, 0.2, 1);
}

.content-box {
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Estado colapsado (desktop) ── */
body.nav-collapsed .sidebar {
  transform: translateX(calc(var(--sidebar-width) * -1));
}
body.nav-collapsed .nav-toggle {
  left: 10px;
  transform: rotate(180deg);
}
body.nav-collapsed .main-content {
  margin-left: 0;
}

/* ── Páginas roles-equipo (sin .layout-wrapper/.main-content) ── */
body.re-page {
  margin-left: var(--sidebar-width);
  transition: margin-left 0.27s cubic-bezier(0.4, 0, 0.2, 1);
}
body.re-page.nav-collapsed {
  margin-left: 0;
}

/* ── Estado abierto (mobile) ── */
body.nav-open .nav-backdrop {
  display: block;
}

/* ── Responsive ── */
@media (max-width: 992px) {
  /* En móvil, la sidebar está oculta por defecto */
  .sidebar {
    transform: translateX(calc(var(--sidebar-width) * -1));
  }
  .nav-toggle {
    left: 10px;
    transform: rotate(180deg);
  }
  .main-content {
    margin-left: 0;
    padding: 24px 20px;
  }
  body.re-page {
    margin-left: 0;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.4);
  }
  body.nav-open .nav-toggle {
    left: calc(var(--sidebar-width) - 13px);
    transform: rotate(0deg);
  }

  /* En móvil: nav-collapsed no aplica, sólo nav-open/close */
  body.nav-collapsed .sidebar       { transform: translateX(calc(var(--sidebar-width) * -1)); }
  body.nav-collapsed .nav-toggle    { left: 10px; transform: rotate(180deg); }
  body.nav-collapsed .main-content  { margin-left: 0; }
  body.nav-collapsed.re-page        { margin-left: 0; }

  .nav-width-toggle {
    display: none;
  }
}

@media print {
  .sidebar, .nav-toggle, .nav-backdrop { display: none !important; }
  .main-content { margin-left: 0; padding: 20px; }
}
