/**
 * ------------------------------------------------------------
 * app-shell.css
 * ------------------------------------------------------------
 * Sidebar + topbar compartidos por todas las páginas autenticadas
 * de usuario (dashboard, courses, take-course, community,
 * certificates). Extraído de dashboard.html — antes vivía
 * duplicado/dividido dentro de cada página.
 *
 * Cada página sigue trayendo su propio CSS para el contenido de
 * adentro (.wrap, tarjetas, etc.) — este archivo SOLO define el
 * shell: .shell / aside.sidebar / .main-col / header.topbar.
 *
 * Incluir junto con design-system.js / apply-branding.js:
 *   <link rel="stylesheet" href="/assets/app-shell.css">
 * ------------------------------------------------------------
 */
:root {
  --sidebar-w: 232px;
  --line: #e7e9ee;
  --ink: #10131a;
  --muted: #647688;
  --bg: #f5f6fa;
  --card: #ffffff;
  /* Falls back to var(--gs-primary) — per-academy branding (Brand Kit)
     still wins if set; esta paleta es solo el default del shell. */
  --panel-primary: var(--gs-primary, #2563eb);
  --panel-secondary: #0f172a;
  --panel-tertiary: #f8fafc;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  margin: 0;
  color: var(--ink);
}

/* ---- Shell layout ---- */
.shell { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
aside.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
aside.sidebar .brand {
  display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; font-weight: 800; font-size: 15px;
}
aside.sidebar .brand .mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--panel-secondary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800;
}
nav.side-nav { flex: 1; padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
nav.side-nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 600;
}
nav.side-nav a svg { flex-shrink: 0; opacity: .85; }
nav.side-nav a:hover { background: var(--panel-tertiary); color: var(--panel-secondary); }
nav.side-nav a.active { background: color-mix(in srgb, var(--panel-primary) 12%, white); color: var(--panel-primary); }
aside.sidebar .side-footer { padding: 14px 12px 18px; border-top: 1px solid var(--line); }
aside.sidebar .side-footer a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; text-decoration: none;
  color: var(--muted); font-size: 13px; font-weight: 600;
}
aside.sidebar .side-footer a:hover { background: #f2f3f7; color: var(--ink); }

/* ---- Main column ---- */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; background: #fff; border-bottom: 1px solid var(--line);
}
header.topbar h1 { font-size: 19px; margin: 0; font-weight: 800; letter-spacing: -0.01em; }
header.topbar .who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
header.topbar .who .avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--panel-tertiary); color: var(--panel-primary);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
}
header.topbar .who a { color: var(--panel-primary); text-decoration: none; font-weight: 600; }
#langSwitcher { font-size: 12px; padding: 5px 7px; border-radius: 7px; border: 1px solid var(--line); background: #fff; }

/* Nombre de la academia actual, arriba a la derecha (Aug 2026) — para
   que alguien con acceso a más de una academia (o que simplemente no
   se acuerda) sepa en cuál está sin tener que adivinar. */
.academy-badge {
  font-size: 12px; font-weight: 700; color: var(--panel-primary); background: var(--panel-tertiary);
  padding: 5px 12px; border-radius: 100px; border: 1px solid var(--line);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 700px) {
  .academy-badge { display: none; }
}

/* Banner de "vista de estudiante" (?student_view=1) — ver app-shell.js mount(). */
.student-view-banner {
  display: flex; align-items: center; gap: 8px; padding: 9px 28px;
  background: #eef2ff; color: #3730a3; font-size: 12px; font-weight: 600;
  border-bottom: 1px solid #c7d2fe;
}
.student-view-banner svg { width: 15px; height: 15px; flex-shrink: 0; }
.student-view-banner span { flex: 1; }
.student-view-banner a { color: #3730a3; text-decoration: underline; font-weight: 700; }

@media (max-width: 700px) {
  aside.sidebar { display: none; }
}

/* ------------------------------------------------------------
 * Shell theme presets
 * ------------------------------------------------------------
 * Variantes de look del SHELL interno (sidebar/topbar) — no
 * confundir con el Brand Kit / Theme del portal público de cada
 * academia (esos son capas separadas, ver design-system.js).
 * Se activan poniendo data-shell-theme="..." en <html> (lo hace
 * app-shell.js). 'default' = sin atributo, es lo que ya existía.
 * ------------------------------------------------------------ */

/* Dark: sidebar y topbar oscuros, el resto de cada página sigue igual. */
html[data-shell-theme="dark"] aside.sidebar,
html[data-shell-theme="dark"] header.topbar {
  background: #14161c;
  border-color: #262a35;
}
html[data-shell-theme="dark"] aside.sidebar .brand,
html[data-shell-theme="dark"] header.topbar h1 { color: #f2f3f7; }
html[data-shell-theme="dark"] nav.side-nav a { color: #9aa1b0; }
html[data-shell-theme="dark"] nav.side-nav a:hover { background: #1d2029; color: #f2f3f7; }
html[data-shell-theme="dark"] nav.side-nav a.active { background: color-mix(in srgb, var(--panel-primary) 22%, #14161c); color: #fff; }
html[data-shell-theme="dark"] aside.sidebar .side-footer { border-color: #262a35; }
html[data-shell-theme="dark"] aside.sidebar .side-footer a { color: #9aa1b0; }
html[data-shell-theme="dark"] aside.sidebar .side-footer a:hover { background: #1d2029; color: #f2f3f7; }
html[data-shell-theme="dark"] header.topbar .who { color: #9aa1b0; }
html[data-shell-theme="dark"] header.topbar .who .avatar { background: #1d2029; border-color: #262a35; }
html[data-shell-theme="dark"] #langSwitcher { background: #1d2029; border-color: #262a35; color: #f2f3f7; }
html[data-shell-theme="dark"] .academy-badge { background: #1d2029; border-color: #262a35; color: #f2f3f7; }

/* Compact: sidebar más angosto y espaciados más chicos, para pantallas con poco lugar. */
html[data-shell-theme="compact"] { --sidebar-w: 184px; }
html[data-shell-theme="compact"] nav.side-nav a { padding: 7px 10px; font-size: 13px; }
html[data-shell-theme="compact"] aside.sidebar .brand { padding: 14px 16px 12px; font-size: 14px; }
html[data-shell-theme="compact"] header.topbar { padding: 12px 22px; }

/* Soft: bordes más redondeados y sombra suave en la barra activa. */
html[data-shell-theme="soft"] nav.side-nav a { border-radius: 999px; }
html[data-shell-theme="soft"] nav.side-nav a.active { box-shadow: 0 1px 3px rgba(0,0,0,.08); }
html[data-shell-theme="soft"] aside.sidebar { border-radius: 0 18px 18px 0; }
html[data-shell-theme="soft"] header.topbar .who .avatar { border-radius: 12px; }

/* ---- Selector de tema (en el pie del sidebar, solo admin/super_admin) ---- */
.shell-theme-picker { padding: 10px 12px 4px; }
.shell-theme-picker .label { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.shell-theme-picker .swatches { display: flex; gap: 6px; }
.shell-theme-picker .swatch {
  width: 26px; height: 26px; border-radius: 8px; cursor: pointer; border: 2px solid transparent;
  display: flex; align-items: center; justify-content: center; font-size: 11px;
}
.shell-theme-picker .swatch.active { border-color: var(--panel-primary); }
.shell-theme-picker .swatch[data-swatch="default"] { background: #fff; border: 1px solid var(--line); }
.shell-theme-picker .swatch[data-swatch="dark"] { background: #14161c; }
.shell-theme-picker .swatch[data-swatch="compact"] { background: #f2f3f7; }
.shell-theme-picker .swatch[data-swatch="soft"] { background: var(--panel-tertiary); border-radius: 999px; }
html[data-shell-theme="dark"] .shell-theme-picker .label { color: #9aa1b0; }

/* ---- Campanita de notificaciones (ver app-shell.js wireNotificationBell) ---- */
.notif-bell-trigger {
  position: relative; cursor: pointer; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.notif-bell-trigger:hover { background: var(--panel-tertiary); color: var(--panel-secondary); }
.notif-badge {
  position: absolute; top: -1px; right: -1px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 100px; background: #dc2626; color: #fff; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; line-height: 1; border: 2px solid #fff;
}
.notif-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); right: 76px; width: 320px; max-height: 420px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 21; overflow: hidden; text-align: left;
}
.notif-dropdown.open { display: flex; flex-direction: column; }
.notif-header { padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px; color: var(--ink); }
.notif-list { overflow-y: auto; }
.notif-empty { padding: 24px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.notif-item {
  display: flex; gap: 10px; padding: 11px 14px; text-decoration: none; color: var(--ink);
  border-bottom: 1px solid var(--line); font-size: 12.5px; line-height: 1.45;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--panel-tertiary); }
.notif-item.unseen { background: color-mix(in srgb, var(--panel-primary) 6%, white); }
.notif-icon { flex-shrink: 0; font-size: 15px; line-height: 1.4; }
.notif-body { flex: 1; min-width: 0; color: var(--muted); }
.notif-actor { font-weight: 700; color: var(--ink); }
.notif-time { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
html[data-shell-theme="dark"] .notif-dropdown { background: #1d2029; border-color: #262a35; }
html[data-shell-theme="dark"] .notif-header { border-color: #262a35; color: #f2f3f7; }
html[data-shell-theme="dark"] .notif-item { border-color: #262a35; color: #f2f3f7; }
html[data-shell-theme="dark"] .notif-item:hover { background: #262a35; }
html[data-shell-theme="dark"] .notif-item.unseen { background: color-mix(in srgb, var(--panel-primary) 18%, #1d2029); }
html[data-shell-theme="dark"] .notif-bell-trigger { color: #9aa1b0; }
html[data-shell-theme="dark"] .notif-bell-trigger:hover { background: #1d2029; color: #f2f3f7; }

@media (max-width: 700px) {
  .notif-dropdown { right: -60px; width: 280px; }
}

/* ---- Menú desplegable del usuario (clic en el avatar) ---- */
header.topbar .who { position: relative; }
.user-menu-trigger { cursor: pointer; display: flex; align-items: center; }
.user-menu-trigger .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.user-menu-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); right: 0; min-width: 220px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 20; overflow: hidden; text-align: left;
}
.user-menu-dropdown.open { display: block; }
.user-menu-dropdown .um-header { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.user-menu-dropdown .um-name { font-weight: 700; font-size: 13px; color: var(--ink); }
.user-menu-dropdown .um-email { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.user-menu-dropdown a {
  display: flex; align-items: center; gap: 9px; padding: 10px 14px; font-size: 13px; font-weight: 600;
  color: var(--ink); text-decoration: none;
}
.user-menu-dropdown a:hover { background: var(--panel-tertiary); }
.user-menu-dropdown a svg { flex-shrink: 0; opacity: .8; }
html[data-shell-theme="dark"] .user-menu-dropdown { background: #1d2029; border-color: #262a35; }
html[data-shell-theme="dark"] .user-menu-dropdown .um-header { border-color: #262a35; }
html[data-shell-theme="dark"] .user-menu-dropdown .um-name { color: #f2f3f7; }
html[data-shell-theme="dark"] .user-menu-dropdown a { color: #f2f3f7; }
html[data-shell-theme="dark"] .user-menu-dropdown a:hover { background: #262a35; }
