/* =============================================================
   sidebar.css  — Layout global compartido entre todos los módulos
   Incluir SIEMPRE junto al CSS de colores del módulo:
     <link rel="stylesheet" href="<?=BASE_URL?>/assets/css/sidebar.css">
     <link rel="stylesheet" href="<?=BASE_URL?>/assets/css/sidebar-tutor.css">
   ============================================================= */

/* ══════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════ */
.app-shell {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - 53px);
}

.sidebar {
  width: 240px;
  min-width: 240px;
  /* Calcula la altura descontando el navbar (~56px) */
  height: calc(100vh - 56px);
  max-height: calc(100vh - 56px);
  position: sticky;
  top: 56px;
  background: linear-gradient(180deg, #0f1f3d 0%, #0a1628 50%, #060e1a 100%);
  border-right: 1px solid #1e3a5f;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #2ea8ff33 transparent;
  transition: transform .28s cubic-bezier(.4,0,.2,1),
              width .28s cubic-bezier(.4,0,.2,1),
              min-width .28s cubic-bezier(.4,0,.2,1);
  z-index: 200;
}

.sidebar::-webkit-scrollbar       { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #2ea8ff55; border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #2ea8ff; }

.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #ffffff;
  padding: 4px 8px 10px;
  flex-shrink: 0;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: #ffffff;
  text-decoration: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar > a:hover  { background: rgba(255,255,255,.10); color: #ffffff; }
.sidebar > a.active { background: rgba(255,255,255,.13); color: #ffffff; font-weight: 600; }
.sidebar a .icon    { flex-shrink: 0; width: 16px; text-align: center; font-size: 13px; }

.main-area {
  flex: 1;
  padding: 24px 28px;
  overflow-x: hidden;
  min-height: calc(100vh - 53px);
}

/* ══════════════════════════════════════════════
   GRUPOS — estructura base (colores en cada módulo)
   ══════════════════════════════════════════════ */
.sidebar-group {
  margin: 6px 0 2px;
  border-radius: 10px;
  overflow: visible;
  flex-shrink: 0;
}

.sg-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 8px 14px 2px;
  display: block;
  white-space: nowrap;
}

.sidebar-group a {
  margin: 0 !important;
  border-radius: 0 !important;
  padding-left: 14px;
  color: #ffffff;
  flex-shrink: 0;
}
.sidebar-group a:last-child { border-radius: 0 0 8px 8px !important; }

.sidebar-sep {
  height: 1px;
  background: rgba(255,255,255,.07);
  margin: 10px 8px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════
   TOGGLE — Colapsado en desktop
   ══════════════════════════════════════════════ */
.app-shell.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  padding-left: 0;
  padding-right: 0;
  border-right-color: transparent;
}
.app-shell.sidebar-collapsed .sidebar * { opacity: 0; pointer-events: none; }

/* ══════════════════════════════════════════════
   BOTÓN HAMBURGUESA (en navbar)
   ══════════════════════════════════════════════ */
#sidebar-toggle {
  background: none;
  border: 1px solid #30363d;
  color: #8b949e;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
#sidebar-toggle:hover { background: #21262d; color: #e6edf3; }

/* ══════════════════════════════════════════════
   OVERLAY — Solo móvil
   ══════════════════════════════════════════════ */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 199;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.show { display: block; }

/* ══════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════ */
@media (max-width: 991px) {
  .sidebar { width: 220px; min-width: 220px; }
}

@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh !important;
    max-height: 100vh !important;
    top: 0 !important;
    transform: translateX(-100%);
    width: 250px !important;
    min-width: 250px !important;
    box-shadow: 4px 0 20px rgba(0,0,0,.5);
    opacity: 1 !important;
    padding: 14px 8px !important;
  }
  .sidebar * { opacity: 1 !important; pointer-events: auto !important; }
  .app-shell:not(.sidebar-collapsed) .sidebar { transform: translateX(0); }
  .app-shell.sidebar-collapsed .sidebar {
    transform: translateX(-100%) !important;
    width: 250px !important;
    min-width: 250px !important;
    border-right-color: #1e3a5f !important;
  }
  .main-area { padding: 16px 14px; }
}

@media (min-width: 768px) {
  #sidebar-overlay { display: none !important; }
}