/* ============================================================
   TeamFix — Dashboard Layout System
   Organizado en secciones:
     1. Dark Mode Tokens
     2. App Shell (layout raíz)
     3. Sidebar
     4. Topbar slim
     5. Content Area
     6. KPI Stats Cards
     7. Flash Alerts
     8. Dark mode — ajustes de componentes heredados
     9. Responsive
   ============================================================ */

/* ─── 1. Dark Mode Tokens ────────────────────────────────── */
html[data-theme="dark"] {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-soft: #1e2130;
    --surface-muted: #252836;
    --text: #e8eaf0;
    --muted: #8b92a5;
    --primary: #4c8df6;
    --primary-dark: #91b8ff;
    --primary-soft: rgba(76, 141, 246, 0.16);
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(76, 141, 246, 0.22);
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
    --skeleton-base: #252836;
    --accent: #ff8080;
    --glass: rgba(26, 29, 39, 0.6);
}

html[data-theme="dark"] body {
    background:
        radial-gradient(
            circle at top left,
            rgba(76, 141, 246, 0.06),
            transparent 34%
        ),
        linear-gradient(180deg, #0f1117 0%, #0f1117 100%);
}

/* ─── 2. App Shell ───────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ─── 3. Sidebar ─────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 900;
    transition: transform 340ms cubic-bezier(0.16, 0.84, 0.24, 1);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 18px 20px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 128px;
    height: 42px;
    object-fit: contain;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 14px 10px 5px;
    margin-top: 4px;
    flex-shrink: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.91rem;
    transition:
        background 140ms ease,
        color 140ms ease;
    position: relative;
}

.sidebar-link svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 140ms ease;
}

.sidebar-link:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.sidebar-link:hover svg {
    opacity: 1;
}

.sidebar-link.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
}

.sidebar-link.active svg {
    opacity: 1;
}

.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--primary);
}

.sidebar-link-danger:hover {
    background: rgba(197, 34, 31, 0.08);
    color: var(--danger);
}

.sidebar-link-danger:hover svg {
    opacity: 1;
}

/* Sidebar footer con dark toggle */
.sidebar-footer {
    padding: 14px 10px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.dark-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.89rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
    text-align: left;
    box-shadow: none;
    transition:
        background 140ms ease,
        color 140ms ease,
        border-color 140ms ease;
}

.dark-toggle:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--border-strong);
    transform: none;
    box-shadow: none;
}

.dark-toggle svg {
    flex-shrink: 0;
}

.dark-toggle .toggle-label {
    flex: 1;
    text-align: left;
}

/* Toggle switch pill */
.toggle-switch {
    width: 30px;
    height: 17px;
    border-radius: 999px;
    background: var(--border-strong);
    position: relative;
    flex-shrink: 0;
    transition: background 240ms ease;
}

.toggle-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #fff;
    transition: transform 220ms cubic-bezier(0.16, 0.84, 0.24, 1);
}

html[data-theme="dark"] .toggle-switch {
    background: var(--primary);
}

html[data-theme="dark"] .toggle-switch::after {
    transform: translateX(13px);
}

/* Sidebar overlay para móvil */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.46);
    z-index: 899;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.sidebar-overlay.active {
    display: block;
}

/* ─── 4. Topbar slim ─────────────────────────────────────── */
/* Sobreescribir el topbar heredado de style.css */
.topbar {
    position: sticky;
    top: 0;
    z-index: 800;
    width: 100% !important;
    max-width: 100% !important;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 11px 24px;
    margin: 0 !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition:
        background 240ms ease,
        border-color 240ms ease;
}

.topbar .brand,
.topbar .topbar-logo {
    display: none !important;
}

.topbar-hamburger {
    display: none;
    background: none;
    border: none;
    padding: 7px;
    border-radius: 9px;
    cursor: pointer;
    color: var(--muted);
    box-shadow: none;
    line-height: 0;
    flex-shrink: 0;
    transition:
        background 140ms ease,
        color 140ms ease;
}

.topbar-hamburger:hover {
    background: var(--primary-soft);
    color: var(--primary);
    transform: none;
    box-shadow: none;
}

.topbar-branding {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.topbar-branding img {
    width: 100px;
    height: 34px;
    object-fit: contain;
}

.topbar-subtitle {
    font-size: 0.84rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ─── 5. Content Area ────────────────────────────────────── */
.content-area {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

/* Sobreescribir page-shell y page-footer dentro de content-area */
.content-area .page-shell {
    width: 100% !important;
    max-width: 1140px !important;
    margin: 0 auto !important;
    padding: 28px 24px 36px !important;
    box-sizing: border-box;
    flex: 1;
}

.content-area .page-footer {
    width: 100% !important;
    max-width: 1140px !important;
    margin: 0 auto !important;
    padding: 0 24px 20px !important;
}

/* ─── 6. KPI Stats Cards ─────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 26px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
    transition:
        transform 180ms ease,
        box-shadow 180ms ease;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.1);
}

/* Borde de acento izquierdo */
.kpi-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
    background: var(--kpi-accent, var(--primary));
}

.kpi-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--kpi-soft, var(--primary-soft));
    color: var(--kpi-accent, var(--primary));
    margin-bottom: 2px;
    flex-shrink: 0;
}

.kpi-value {
    font-size: 1.95rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
    letter-spacing: -0.03em;
}

.kpi-label {
    font-size: 0.81rem;
    color: var(--muted);
    font-weight: 600;
    margin-top: 2px;
}

/* Variantes de color */
.kpi-blue {
    --kpi-accent: var(--primary);
    --kpi-soft: var(--primary-soft);
}
.kpi-green {
    --kpi-accent: #188038;
    --kpi-soft: rgba(24, 128, 56, 0.1);
}
.kpi-amber {
    --kpi-accent: #b06000;
    --kpi-soft: rgba(176, 96, 0, 0.1);
}
.kpi-red {
    --kpi-accent: #c5221f;
    --kpi-soft: rgba(197, 34, 31, 0.1);
}
.kpi-purple {
    --kpi-accent: #7c3aed;
    --kpi-soft: rgba(124, 58, 237, 0.1);
}
.kpi-teal {
    --kpi-accent: #0d9488;
    --kpi-soft: rgba(13, 148, 136, 0.1);
}

/* ─── 7. Flash Alerts ────────────────────────────────────── */
.flash-danger {
    background: #fff1f0;
    border-color: rgba(197, 34, 31, 0.22);
    color: var(--danger);
}

.flash-success {
    background: #e6f4ea;
    border-color: rgba(24, 128, 56, 0.22);
    color: var(--success);
}

.flash-info {
    background: #e8f0fe;
    border-color: rgba(26, 115, 232, 0.22);
    color: var(--primary);
}

html[data-theme="dark"] .flash-danger {
    background: rgba(197, 34, 31, 0.12);
    border-color: rgba(197, 34, 31, 0.28);
    color: #ff6e6e;
}
html[data-theme="dark"] .flash-success {
    background: rgba(24, 128, 56, 0.12);
    border-color: rgba(24, 128, 56, 0.28);
    color: #4cbb6f;
}
html[data-theme="dark"] .flash-info {
    background: rgba(26, 115, 232, 0.12);
    border-color: rgba(26, 115, 232, 0.28);
    color: var(--primary-dark);
}
html[data-theme="dark"] .flash-warning {
    background: rgba(176, 96, 0, 0.12);
    border-color: rgba(176, 96, 0, 0.28);
    color: #ffa040;
}

/* ─── 8. Dark Mode — ajustes de componentes heredados ────── */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    background: var(--surface-muted);
    color: var(--text);
    border-color: var(--border-strong);
}

html[data-theme="dark"] .button-secondary {
    background: rgba(76, 141, 246, 0.14);
    color: var(--primary-dark);
}

html[data-theme="dark"] .tab {
    background: var(--surface-muted);
    color: var(--muted);
}

html[data-theme="dark"] .tab.active {
    background: var(--primary);
    color: #fff;
}

html[data-theme="dark"] .loading-overlay {
    background: rgba(15, 17, 23, 0.76);
}

html[data-theme="dark"] .classroom-hero-banner,
html[data-theme="dark"] .preview-banner {
    background: linear-gradient(135deg, #1557b0 0%, #2563d4 54%, #3b7de8 100%);
}

html[data-theme="dark"] .comparison-card-primary {
    background: linear-gradient(180deg, #1a1d27 0%, #1e2130 100%);
}

html[data-theme="dark"] .highlight-quote {
    background: linear-gradient(
        135deg,
        rgba(76, 141, 246, 0.14),
        rgba(91, 180, 255, 0.1)
    );
}

html[data-theme="dark"] .preview-banner p,
html[data-theme="dark"] .classroom-hero-banner p,
html[data-theme="dark"] .classroom-hero-banner .lead {
    color: rgba(255, 255, 255, 0.88);
}

html[data-theme="dark"] thead th {
    color: var(--muted);
}

html[data-theme="dark"] tbody tr {
    border-color: var(--border);
}

html[data-theme="dark"] .panel-soft,
html[data-theme="dark"] .panel-light {
    background: var(--surface-soft);
}

html[data-theme="dark"] .alert-warning,
html[data-theme="dark"] .flash-warning {
    background: rgba(176, 96, 0, 0.12);
    border-color: rgba(176, 96, 0, 0.28);
}

html[data-theme="dark"] .code-badge,
html[data-theme="dark"] .class-code-pill {
    background: rgba(76, 141, 246, 0.18);
    color: var(--primary-dark);
}

/* ─── 9. Responsive ──────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    .content-area {
        margin-left: 0;
    }

    .topbar-hamburger {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .content-area .page-shell {
        padding: 20px 16px 28px !important;
    }

    .topbar {
        padding: 10px 16px !important;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .kpi-value {
        font-size: 1.65rem;
    }
}

@media (max-width: 400px) {
    .stats-row {
        grid-template-columns: 1fr 1fr;
    }
    .topbar-branding img {
        width: 90px !important;
        height: 30px !important;
    }
    .topbar-subtitle {
        display: none;
    }
}

/* ─── Sidebar colapsable ─────────────────────────────────── */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    box-shadow: none;
    padding: 0;
    flex-shrink: 0;
    transition:
        background 140ms ease,
        color 140ms ease,
        transform 300ms ease;
    margin-left: auto;
}
.sidebar-collapse-btn:hover {
    background: var(--primary-soft);
    color: var(--primary);
    transform: none;
    box-shadow: none;
}

/* Estado colapsado */
.sidebar.sidebar-collapsed {
    width: 64px;
}
.sidebar.sidebar-collapsed .sidebar-logo {
    display: none;
}
.sidebar.sidebar-collapsed .sidebar-section-label {
    opacity: 0;
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}
.sidebar.sidebar-collapsed .sidebar-link span,
.sidebar.sidebar-collapsed .dark-toggle .toggle-label,
.sidebar.sidebar-collapsed .dark-toggle .toggle-switch {
    display: none;
}
.sidebar.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 10px;
}
.sidebar.sidebar-collapsed .sidebar-link svg {
    opacity: 0.85;
}
.sidebar.sidebar-collapsed .sidebar-link.active::before {
    top: 0;
    bottom: 0;
    border-radius: 0 3px 3px 0;
}
.sidebar.sidebar-collapsed .dark-toggle {
    justify-content: center;
    padding: 10px;
}
.sidebar.sidebar-collapsed .sidebar-collapse-btn {
    transform: rotate(180deg);
    margin: 0 auto;
}
.sidebar.sidebar-collapsed .sidebar-header {
    justify-content: center;
}

/* Content area se ajusta */
.content-area.sidebar-collapsed-area {
    margin-left: 64px;
}

/* Logos más grandes */
.sidebar-logo {
    width: 148px !important;
    height: 50px !important;
    object-fit: contain;
}
.topbar-branding img {
    width: 130px !important;
    height: 44px !important;
    object-fit: contain;
}

@media (max-width: 1024px) {
    .content-area.sidebar-collapsed-area {
        margin-left: 0;
    }
}

/* ─── Sidebar overlay — dark mode ───────────────────────── */
html[data-theme="dark"] .sidebar-overlay.active {
    background: rgba(0, 0, 0, 0.65);
}

/* ─── Tooltips CSS — sidebar colapsado ──────────────────── */
.sidebar.sidebar-collapsed .sidebar-link {
    position: relative;
}
.sidebar.sidebar-collapsed .sidebar-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface);
    color: var(--text);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
    z-index: 1000;
}
.sidebar.sidebar-collapsed .sidebar-link:hover::after {
    opacity: 1;
}

/* ─── Tooltips — dark mode override ─────────────────────── */
html[data-theme="dark"] .sidebar.sidebar-collapsed .sidebar-link::after {
    background: var(--surface-muted);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ─── KPI cards dark mode refinado ──────────────────────── */
html[data-theme="dark"] .kpi-card {
    background: var(--surface) !important;
    border-color: var(--border) !important;
}
html[data-theme="dark"] .kpi-card:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35) !important;
}

/* ─── Flash messages dark mode ──────────────────────────── */
html[data-theme="dark"] .flash-danger {
    background: rgba(197, 34, 31, 0.14) !important;
    color: #ff8a8a !important;
}
html[data-theme="dark"] .flash-success {
    background: rgba(24, 128, 56, 0.14) !important;
    color: #6fcf8a !important;
}
html[data-theme="dark"] .flash-info {
    background: rgba(76, 141, 246, 0.14) !important;
    color: #91b8ff !important;
}

/* ── Temas adicionales ──────────────────────────────────────────────── */

/* Océano */
html[data-theme="ocean"] {
    --bg: #0d1b2a;
    --surface: #1b2838;
    --surface-soft: #1e3040;
    --surface-muted: #243a50;
    --text: #ccd6f6;
    --muted: #8892b0;
    --primary: #64ffda;
    --primary-dark: #a8ffee;
    --primary-soft: rgba(100, 255, 218, 0.1);
    --border: rgba(100, 255, 218, 0.08);
    --border-strong: rgba(100, 255, 218, 0.22);
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
    --danger: #ff6b6b;
    --success: #64ffda;
    --skeleton-base: #1b2838;
    --accent: #64ffda;
    --glass: rgba(27, 40, 56, 0.6);
}
html[data-theme="ocean"] body {
    background:
        radial-gradient(
            circle at top left,
            rgba(100, 255, 218, 0.05),
            transparent 40%
        ),
        linear-gradient(180deg, #0d1b2a 0%, #0a1520 100%);
}

/* Bosque */
html[data-theme="forest"] {
    --bg: #0a1a0f;
    --surface: #102016;
    --surface-soft: #162a1c;
    --surface-muted: #1e3525;
    --text: #d4edda;
    --muted: #7fa88a;
    --primary: #52b788;
    --primary-dark: #95d5b2;
    --primary-soft: rgba(82, 183, 136, 0.12);
    --border: rgba(82, 183, 136, 0.1);
    --border-strong: rgba(82, 183, 136, 0.24);
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
    --danger: #ff8a80;
    --success: #52b788;
    --skeleton-base: #102016;
    --accent: #52b788;
    --glass: rgba(16, 32, 22, 0.6);
}
html[data-theme="forest"] body {
    background:
        radial-gradient(
            circle at top left,
            rgba(82, 183, 136, 0.06),
            transparent 40%
        ),
        linear-gradient(180deg, #0a1a0f 0%, #060f09 100%);
}

/* Atardecer */
html[data-theme="sunset"] {
    --bg: #1a0a12;
    --surface: #2a1020;
    --surface-soft: #34152a;
    --surface-muted: #3e1a32;
    --text: #ffd6e7;
    --muted: #c48098;
    --primary: #ff6b9d;
    --primary-dark: #ffaac5;
    --primary-soft: rgba(255, 107, 157, 0.12);
    --border: rgba(255, 107, 157, 0.1);
    --border-strong: rgba(255, 107, 157, 0.25);
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
    --danger: #ff6b6b;
    --success: #52b788;
    --skeleton-base: #2a1020;
    --accent: #ff6b9d;
    --glass: rgba(42, 16, 32, 0.6);
}
html[data-theme="sunset"] body {
    background:
        radial-gradient(
            circle at top left,
            rgba(255, 107, 157, 0.07),
            transparent 40%
        ),
        linear-gradient(180deg, #1a0a12 0%, #120008 100%);
}

/* Alto contraste */
html[data-theme="contrast"] {
    --bg: #000000;
    --surface: #0a0a0a;
    --surface-soft: #111111;
    --surface-muted: #1a1a1a;
    --text: #ffffff;
    --muted: #cccccc;
    --primary: #ffff00;
    --primary-dark: #ffff99;
    --primary-soft: rgba(255, 255, 0, 0.12);
    --border: rgba(255, 255, 255, 0.3);
    --border-strong: rgba(255, 255, 0, 0.5);
    --shadow: 0 4px 12px rgba(255, 255, 255, 0.08);
    --danger: #ff4444;
    --success: #44ff44;
    --skeleton-base: #0a0a0a;
    --accent: #ffff00;
    --glass: rgba(10, 10, 10, 0.6);
}
html[data-theme="contrast"] body {
    background: #000;
}

/* Lavanda */
html[data-theme="lavender"] {
    --bg: #120a1a;
    --surface: #1e1428;
    --surface-soft: #261a33;
    --surface-muted: #302040;
    --text: #e8d5f7;
    --muted: #a080c0;
    --primary: #c084fc;
    --primary-dark: #d8b4fe;
    --primary-soft: rgba(192, 132, 252, 0.14);
    --border: rgba(192, 132, 252, 0.09);
    --border-strong: rgba(192, 132, 252, 0.24);
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
    --danger: #ff6b8a;
    --success: #6ee7b7;
    --skeleton-base: #1e1428;
    --accent: #f472b6;
    --glass: rgba(30, 20, 40, 0.6);
}
html[data-theme="lavender"] body {
    background:
        radial-gradient(
            circle at top left,
            rgba(192, 132, 252, 0.06),
            transparent 40%
        ),
        linear-gradient(180deg, #120a1a 0%, #0d0614 100%);
}

/* Café */
html[data-theme="coffee"] {
    --bg: #1a120b;
    --surface: #2a1f16;
    --surface-soft: #33261c;
    --surface-muted: #3d2e22;
    --text: #f0e2d3;
    --muted: #b89a7e;
    --primary: #d4a373;
    --primary-dark: #eac7a3;
    --primary-soft: rgba(212, 163, 115, 0.14);
    --border: rgba(212, 163, 115, 0.09);
    --border-strong: rgba(212, 163, 115, 0.24);
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
    --danger: #ff8a80;
    --success: #81c784;
    --skeleton-base: #2a1f16;
    --accent: #ffab91;
    --glass: rgba(42, 31, 22, 0.6);
}
html[data-theme="coffee"] body {
    background:
        radial-gradient(
            circle at top left,
            rgba(212, 163, 115, 0.06),
            transparent 40%
        ),
        linear-gradient(180deg, #1a120b 0%, #140e08 100%);
}

/* Medianoche */
html[data-theme="midnight"] {
    --bg: #080c14;
    --surface: #0f1520;
    --surface-soft: #141b2a;
    --surface-muted: #1a2235;
    --text: #c8d6e5;
    --muted: #7a8fa8;
    --primary: #6c9fff;
    --primary-dark: #a8c8ff;
    --primary-soft: rgba(108, 159, 255, 0.14);
    --border: rgba(108, 159, 255, 0.09);
    --border-strong: rgba(108, 159, 255, 0.24);
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
    --danger: #ff7a7a;
    --success: #6ee7b7;
    --skeleton-base: #0f1520;
    --accent: #ff92a8;
    --glass: rgba(15, 21, 32, 0.6);
}
html[data-theme="midnight"] body {
    background:
        radial-gradient(
            circle at top left,
            rgba(108, 159, 255, 0.06),
            transparent 40%
        ),
        linear-gradient(180deg, #080c14 0%, #05080f 100%);
}

/* ── Theme Picker UI ─────────────────────────────────────────────────── */
.theme-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 6px 0;
}
.theme-picker-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 2px;
}
.theme-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 2px;
}
.theme-chip {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition:
        transform 160ms ease,
        border-color 160ms ease,
        box-shadow 160ms ease;
    box-shadow: none;
    flex-shrink: 0;
}
.theme-chip:hover {
    transform: scale(1.18);
}
.theme-chip.active {
    border-color: var(--text);
    box-shadow:
        0 0 0 2px var(--surface),
        0 0 0 4px var(--text);
    transform: scale(1.1);
}
/* Colores de los chips */
.chip-light {
    background: linear-gradient(135deg, #f6f8fc, #ffffff);
    border-color: rgba(0, 0, 0, 0.15);
}
.chip-dark {
    background: linear-gradient(135deg, #1a1d27, #0f1117);
    border-color: rgba(255, 255, 255, 0.12);
}
.chip-ocean {
    background: linear-gradient(135deg, #1b2838, #64ffda);
}
.chip-forest {
    background: linear-gradient(135deg, #102016, #52b788);
}
.chip-sunset {
    background: linear-gradient(135deg, #2a1020, #ff6b9d);
}
.chip-contrast {
    background: linear-gradient(135deg, #000000, #ffff00);
}
.chip-lavender {
    background: linear-gradient(135deg, #1e1428, #c084fc);
}
.chip-coffee {
    background: linear-gradient(135deg, #2a1f16, #d4a373);
}
.chip-midnight {
    background: linear-gradient(135deg, #0f1520, #6c9fff);
}

/* Sidebar colapsado: chips en columna */
.sidebar.sidebar-collapsed .theme-picker-label {
    display: none;
}
.sidebar.sidebar-collapsed .theme-chips {
    flex-direction: column;
    gap: 4px;
    align-items: center;
}
.sidebar.sidebar-collapsed .theme-chip {
    width: 18px;
    height: 18px;
}

/* Fix del nav-label — CLAVE para sidebar colapsado */
.sidebar.sidebar-collapsed .nav-label {
    display: none;
}

/* Inputs y selects en temas oscuros */
html[data-theme="ocean"] input,
html[data-theme="ocean"] select,
html[data-theme="ocean"] textarea,
html[data-theme="forest"] input,
html[data-theme="forest"] select,
html[data-theme="forest"] textarea,
html[data-theme="sunset"] input,
html[data-theme="sunset"] select,
html[data-theme="sunset"] textarea,
html[data-theme="contrast"] input,
html[data-theme="contrast"] select,
html[data-theme="contrast"] textarea,
html[data-theme="lavender"] input,
html[data-theme="lavender"] select,
html[data-theme="lavender"] textarea,
html[data-theme="coffee"] input,
html[data-theme="coffee"] select,
html[data-theme="coffee"] textarea,
html[data-theme="midnight"] input,
html[data-theme="midnight"] select,
html[data-theme="midnight"] textarea {
    background: var(--surface-muted);
    color: var(--text);
    border-color: var(--border-strong);
}
html[data-theme="ocean"] .button-secondary,
html[data-theme="forest"] .button-secondary,
html[data-theme="sunset"] .button-secondary,
html[data-theme="contrast"] .button-secondary,
html[data-theme="lavender"] .button-secondary,
html[data-theme="coffee"] .button-secondary,
html[data-theme="midnight"] .button-secondary {
    background: var(--primary-soft);
    color: var(--primary-dark);
}
html[data-theme="ocean"] .tab,
html[data-theme="forest"] .tab,
html[data-theme="sunset"] .tab,
html[data-theme="contrast"] .tab,
html[data-theme="lavender"] .tab,
html[data-theme="coffee"] .tab,
html[data-theme="midnight"] .tab {
    background: var(--surface-muted);
    color: var(--muted);
}
html[data-theme="ocean"] .tab.active,
html[data-theme="forest"] .tab.active,
html[data-theme="sunset"] .tab.active,
html[data-theme="contrast"] .tab.active,
html[data-theme="lavender"] .tab.active,
html[data-theme="coffee"] .tab.active,
html[data-theme="midnight"] .tab.active {
    background: var(--primary);
    color: var(--bg);
}

/* ── Shared dark theme component overrides ─────────────── */
html[data-theme="ocean"] .kpi-card,
html[data-theme="forest"] .kpi-card,
html[data-theme="sunset"] .kpi-card,
html[data-theme="contrast"] .kpi-card,
html[data-theme="lavender"] .kpi-card,
html[data-theme="coffee"] .kpi-card,
html[data-theme="midnight"] .kpi-card {
    background: var(--surface) !important;
    border-color: var(--border) !important;
}
html[data-theme="ocean"] .kpi-card:hover,
html[data-theme="forest"] .kpi-card:hover,
html[data-theme="sunset"] .kpi-card:hover,
html[data-theme="contrast"] .kpi-card:hover,
html[data-theme="lavender"] .kpi-card:hover,
html[data-theme="coffee"] .kpi-card:hover,
html[data-theme="midnight"] .kpi-card:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35) !important;
}
html[data-theme="ocean"] .loading-overlay,
html[data-theme="forest"] .loading-overlay,
html[data-theme="sunset"] .loading-overlay,
html[data-theme="contrast"] .loading-overlay,
html[data-theme="lavender"] .loading-overlay,
html[data-theme="coffee"] .loading-overlay,
html[data-theme="midnight"] .loading-overlay {
    background: rgba(15, 17, 23, 0.76);
}
html[data-theme="ocean"] .sidebar-overlay.active,
html[data-theme="forest"] .sidebar-overlay.active,
html[data-theme="sunset"] .sidebar-overlay.active,
html[data-theme="contrast"] .sidebar-overlay.active,
html[data-theme="lavender"] .sidebar-overlay.active,
html[data-theme="coffee"] .sidebar-overlay.active,
html[data-theme="midnight"] .sidebar-overlay.active {
    background: rgba(0, 0, 0, 0.65);
}
html[data-theme="ocean"] .panel-soft,
html[data-theme="ocean"] .panel-light,
html[data-theme="forest"] .panel-soft,
html[data-theme="forest"] .panel-light,
html[data-theme="sunset"] .panel-soft,
html[data-theme="sunset"] .panel-light,
html[data-theme="contrast"] .panel-soft,
html[data-theme="contrast"] .panel-light,
html[data-theme="lavender"] .panel-soft,
html[data-theme="lavender"] .panel-light,
html[data-theme="coffee"] .panel-soft,
html[data-theme="coffee"] .panel-light,
html[data-theme="midnight"] .panel-soft,
html[data-theme="midnight"] .panel-light {
    background: var(--surface-soft);
}
html[data-theme="ocean"] .code-badge,
html[data-theme="ocean"] .class-code-pill,
html[data-theme="forest"] .code-badge,
html[data-theme="forest"] .class-code-pill,
html[data-theme="sunset"] .code-badge,
html[data-theme="sunset"] .class-code-pill,
html[data-theme="contrast"] .code-badge,
html[data-theme="contrast"] .class-code-pill,
html[data-theme="lavender"] .code-badge,
html[data-theme="lavender"] .class-code-pill,
html[data-theme="coffee"] .code-badge,
html[data-theme="coffee"] .class-code-pill,
html[data-theme="midnight"] .code-badge,
html[data-theme="midnight"] .class-code-pill {
    background: var(--primary-soft);
    color: var(--primary-dark);
}
html[data-theme="ocean"] thead th,
html[data-theme="forest"] thead th,
html[data-theme="sunset"] thead th,
html[data-theme="contrast"] thead th,
html[data-theme="lavender"] thead th,
html[data-theme="coffee"] thead th,
html[data-theme="midnight"] thead th {
    color: var(--muted);
}
html[data-theme="ocean"] tbody tr,
html[data-theme="forest"] tbody tr,
html[data-theme="sunset"] tbody tr,
html[data-theme="contrast"] tbody tr,
html[data-theme="lavender"] tbody tr,
html[data-theme="coffee"] tbody tr,
html[data-theme="midnight"] tbody tr {
    border-color: var(--border);
}
html[data-theme="ocean"] .flash-danger,
html[data-theme="forest"] .flash-danger,
html[data-theme="sunset"] .flash-danger,
html[data-theme="contrast"] .flash-danger,
html[data-theme="lavender"] .flash-danger,
html[data-theme="coffee"] .flash-danger,
html[data-theme="midnight"] .flash-danger {
    background: rgba(197, 34, 31, 0.14) !important;
    color: #ff8a8a !important;
}
html[data-theme="ocean"] .flash-success,
html[data-theme="forest"] .flash-success,
html[data-theme="sunset"] .flash-success,
html[data-theme="contrast"] .flash-success,
html[data-theme="lavender"] .flash-success,
html[data-theme="coffee"] .flash-success,
html[data-theme="midnight"] .flash-success {
    background: rgba(24, 128, 56, 0.14) !important;
    color: #6fcf8a !important;
}
html[data-theme="ocean"] .flash-info,
html[data-theme="forest"] .flash-info,
html[data-theme="sunset"] .flash-info,
html[data-theme="contrast"] .flash-info,
html[data-theme="lavender"] .flash-info,
html[data-theme="coffee"] .flash-info,
html[data-theme="midnight"] .flash-info {
    background: var(--primary-soft) !important;
    color: var(--primary-dark) !important;
}
html[data-theme="ocean"] .flash-warning,
html[data-theme="forest"] .flash-warning,
html[data-theme="sunset"] .flash-warning,
html[data-theme="contrast"] .flash-warning,
html[data-theme="lavender"] .flash-warning,
html[data-theme="coffee"] .flash-warning,
html[data-theme="midnight"] .flash-warning {
    background: rgba(176, 96, 0, 0.14) !important;
    color: #ffb86c !important;
}

/* ── Quiz builder (crear cuestionario) y quiz runner (responder) ── */
.quiz-question-row {
    padding: 16px;
    margin-top: 10px;
}

.quiz-option-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.quiz-option-row input[type="radio"],
.quiz-q-options-tf input[type="radio"] {
    width: auto;
    flex: none;
}

.quiz-option-row .quiz-option-text {
    flex: 1;
}

.quiz-q-options-tf label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    margin-top: 6px;
}

.quiz-runner-question {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 12px;
}

.quiz-runner-option {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-weight: 500;
}

.quiz-runner-option input[type="radio"] {
    width: auto;
}

.quiz-result-badge {
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.82rem;
    font-weight: 700;
    margin-left: 8px;
}

.quiz-result-badge.correct {
    background: rgba(24, 128, 56, 0.14);
    color: var(--success, #188038);
}

.quiz-result-badge.incorrect {
    background: rgba(217, 48, 37, 0.14);
    color: var(--danger, #d93025);
}
