/* ============================================================
   QAD Calidad — Sidebar
   Navegación lateral: fondo azul marino dominante, isotipo
   provisional, ítem activo con subrayado cobre, y el menú de
   usuario del pie del sidebar. No declarar aquí el topbar
   superior — ver topbar.css.
   ============================================================ */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--color-navy);
  color: var(--color-text-faint);
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  box-shadow: var(--shadow-soft);
  z-index: var(--z-sidebar);
}

.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -16rem;
    height: 100vh;
    width: 16rem !important;
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: var(--z-sidebar-mobile);
  }
  .sidebar.w-64 { left: 0; }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(18,35,63,0.5);
    z-index: var(--z-backdrop);
  }
}

/* ─── Encabezado: isotipo + nombre del sistema, sin separación
   visual con la nav (mismo fondo azul marino) ────────────────── */
.sidebar-header {
  padding: 1.125rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: var(--topbar-height);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.95rem;
  font-variant: small-caps;
  letter-spacing: 0.02em;
  color: var(--color-surface);
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--color-navy);
  border: 1px solid var(--color-navy-border);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--color-copper);
}
.sidebar-logo-icon svg { width: 1.125rem; height: 1.125rem; color: var(--color-copper); }
.sidebar-logo-icon img { width: 100%; height: 100%; object-fit: contain; border-radius: 4px; }

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
  padding: 0.875rem 0.75rem 0.375rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.sidebar-footer {
  padding: 0.625rem 0.5rem;
  border-top: 1px solid rgba(159,179,204,0.18);
}

/* ─── Ítems de navegación: versalitas, subrayado cobre en activo ── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5625rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  font-variant: small-caps;
  letter-spacing: 0.02em;
  color: var(--color-text-faint);
  border-bottom: 2px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--color-surface);
}

.nav-item-active {
  background: transparent !important;
  color: var(--color-surface) !important;
  border-bottom-color: var(--color-copper) !important;
}

.nav-item .icon {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  stroke-width: 1.75;
  transition: color 0.15s;
}

/* ─── Botón de sección colapsable ────────────────────────────── */
.sidebar-section-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.875rem 0.75rem 0.375rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  outline: none;
  cursor: pointer;
  transition: color 0.15s;
}
.sidebar-section-btn:hover { color: var(--color-surface); }
.sidebar-section-btn .section-chevron {
  width: 0.75rem;
  height: 0.75rem;
  flex-shrink: 0;
  stroke-width: 2.5;
  transition: transform 0.2s ease;
  color: var(--color-text-faint);
}
.sidebar-section-btn .section-chevron.rotate-180 { transform: rotate(180deg); }

/* ─── Menú de usuario (pie del sidebar) ──────────────────────── */
.user-info {
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  color: var(--color-text-faint);
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-surface);
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.user-avatar-sm { width: 1.75rem; height: 1.75rem; font-size: 0.7rem; }
.user-avatar-lg {
  width: 4rem;
  height: 4rem;
  font-size: 1.375rem;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-surface);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(46,92,138,0.15);
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
  overflow: hidden;
}
.user-menu-trigger:hover,
.user-menu-trigger.active { background: rgba(255,255,255,0.06); }

.user-menu-info { flex: 1; min-width: 0; overflow: hidden; }
.user-menu-info .name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-info .email {
  font-size: 0.7rem;
  color: var(--color-text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}
.user-menu-chevron {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
  color: var(--color-text-faint);
  transition: transform 0.2s;
  stroke-width: 2.5;
}
.user-menu-chevron.rotate { transform: rotate(180deg); }

.user-dropdown {
  background: #1A3155;
  border: 1px solid rgba(159,179,204,0.2);
  border-radius: var(--radius-sm);
  margin: 0.25rem 0;
  overflow: hidden;
  box-shadow: var(--shadow-overlay);
}
.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5625rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-faint);
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.user-dropdown-item:hover { background: rgba(255,255,255,0.06); color: var(--color-surface); }
.user-dropdown-item.danger:hover { background: rgba(178,58,58,0.18); color: #E8A9A9; }
.user-dropdown-item svg { width: 1rem; height: 1rem; flex-shrink: 0; stroke-width: 1.75; }
.user-dropdown-divider { border: none; border-top: 1px solid rgba(159,179,204,0.18); margin: 0.125rem 0; }
