/* ============================================================
   FSAC Scholar — Training Hub (training.css) — v4.0
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Outfit:wght@400;500;600;700;800;900&display=swap');

/* ============================================================
   1. DESIGN TOKENS (mirrors main.css tokens)
   ============================================================ */
:root {
    --sidebar-w: 270px;
    --list-w: 380px;
    --header-h: 56px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-sm:  8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-pill: 999px;
}

[data-theme="dark"] {
    --bg-body:    #080a0f;
    --bg-panel:   #0f1117;
    --bg-sidebar: #090b0f;
    --bg-hover:   #141720;
    --bg-elevated:#161a24;
    --border:     #1e2232;
    --border-hi:  #2a3048;
    --text-main:  #eef2ff;
    --text-muted: #7882a0;
    --text-subtle:#3d4562;
    --primary:    #6366f1;
    --primary-rgb: 99, 102, 241;
    --primary-light: rgba(99, 102, 241, 0.12);
    --accent:     #06b6d4;
    --accent-rgb: 6, 182, 212;
    --danger:     #f472b6;
    --success:    #10b981;
    --logo-bg:    rgba(255,255,255,0.04);

    /* Category colors */
    --cat-python: #3b82f6;
    --cat-sql:    #f59e0b;
    --cat-git:    #f97316;
    --cat-linux:  #eab308;
    --cat-docker: #06b6d4;
    --cat-cloud:  #8b5cf6;
    --cat-ml:     #ec4899;
    --cat-soft:   #10b981;
}

[data-theme="light"] {
    --bg-body:    #f0f4ff;
    --bg-panel:   #ffffff;
    --bg-sidebar: #ffffff;
    --bg-hover:   #eef2ff;
    --bg-elevated:#f8faff;
    --border:     #e2e8f0;
    --border-hi:  #c7d2fe;
    --text-main:  #0d1117;
    --text-muted: #4b5563;
    --text-subtle:#9ca3af;
    --primary:    #4f46e5;
    --primary-rgb: 79, 70, 229;
    --primary-light: rgba(79, 70, 229, 0.08);
    --accent:     #0891b2;
    --accent-rgb: 8, 145, 178;
    --danger:     #dc2626;
    --success:    #059669;
    --logo-bg:    rgba(0,0,0,0.03);

    --cat-python: #2563eb;
    --cat-sql:    #d97706;
    --cat-git:    #ea580c;
    --cat-linux:  #ca8a04;
    --cat-docker: #0891b2;
    --cat-cloud:  #7c3aed;
    --cat-ml:     #db2777;
    --cat-soft:   #059669;
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*, *::before, *::after {
    margin: 0; padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    transition: background 0.3s, color 0.3s;
}

/* Scrollbar */
.hide-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }
.hide-scrollbar::-webkit-scrollbar { display: none; }

/* ============================================================
   3. SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 30;
    transition: background 0.3s, border-color 0.3s, transform 0.3s;
    overflow: hidden;
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--logo-bg) 0%, transparent 100%);
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
}

.sidebar-brand:hover { background: var(--bg-hover); }

.sidebar-logo {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-hi);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-logo img { width: 28px; height: 28px; object-fit: contain; }
.sidebar-logo i { color: var(--primary); font-size: 1rem; }

.sidebar-brand-text {
    flex: 1;
    overflow: hidden;
}

.sidebar-brand-name {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--text-main);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-brand-sub {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 600;
    display: block;
}

.sidebar-back-icon {
    color: var(--text-subtle);
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: color var(--transition);
}

.sidebar-brand:hover .sidebar-back-icon {
    color: var(--primary);
}

/* Section Label */
.sidebar-section-label {
    padding: 14px 18px 6px;
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    flex-shrink: 0;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 4px 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-hi);
    border-radius: 4px;
}

.nav-cat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    margin-bottom: 2px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: var(--transition);
    position: relative;
    min-height: 42px;
}

.nav-cat-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.nav-cat-item.active {
    background: var(--bg-hover);
    color: var(--cat-color, var(--primary));
    border-color: rgba(var(--primary-rgb), 0.2);
    font-weight: 700;
}

.nav-cat-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--cat-color, var(--primary));
    background: rgba(var(--primary-rgb), 0.1);
    flex-shrink: 0;
    transition: transform var(--transition);
}

.nav-cat-item.active .nav-cat-icon,
.nav-cat-item:hover .nav-cat-icon {
    transform: scale(1.1);
}

.nav-cat-label { flex: 1; }

.nav-cat-count {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-subtle);
    background: var(--border);
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    flex-shrink: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.footer-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.footer-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.footer-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-hi);
    color: var(--text-main);
}

.sidebar-credits {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-subtle);
    font-weight: 500;
    line-height: 1.5;
}

.credit-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 700;
}

.credit-link:hover { color: var(--primary); }

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 29;
}

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

/* ============================================================
   4. LIST PANEL
   ============================================================ */
.list-panel {
    width: var(--list-w);
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 20;
    overflow: hidden;
}

/* Mobile Header */
.mobile-header {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.mobile-menu-btn, .mobile-theme-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.mobile-menu-btn:hover, .mobile-theme-btn:hover {
    color: var(--primary);
    border-color: var(--border-hi);
}

.mobile-title {
    flex: 1;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile Category Scroll */
.mobile-category-scroll {
    display: none;
    gap: 8px;
    padding: 10px 14px;
    overflow-x: auto;
    white-space: nowrap;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.mob-cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: var(--bg-body);
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    flex-shrink: 0;
}

.mob-cat-pill.active {
    background: var(--cat-color, var(--primary));
    color: #fff;
    border-color: var(--cat-color, var(--primary));
    box-shadow: 0 2px 12px rgba(var(--primary-rgb), 0.3);
}

/* Search Bar */
.search-bar-wrap {
    padding: 12px 14px 8px;
    flex-shrink: 0;
}

.search-container {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 11px 36px 11px 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-body);
    color: var(--text-main);
    font-size: 0.88rem;
    font-weight: 500;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.search-input::placeholder { color: var(--text-subtle); }

.search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
    font-size: 0.85rem;
    pointer-events: none;
}

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    padding: 4px;
    font-size: 0.8rem;
}

/* Module Context */
.module-context {
    padding: 10px 14px 0;
    flex-shrink: 0;
}

.ctx-header {
    margin-bottom: 10px;
}

.ctx-breadcrumb {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.ctx-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.2px;
}

/* Tabs */
.ctx-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

.ctx-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: var(--transition);
    font-family: inherit;
}

.ctx-tab:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.ctx-tab.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), 0.25);
    font-weight: 700;
}

/* File List */
.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
}

/* Welcome State */
.welcome-state {
    padding: 2rem 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.welcome-icon {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-xl);
    background: rgba(var(--primary-rgb), 0.1);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.welcome-state h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
}

.welcome-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 260px;
}

.welcome-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 8px;
}

.welcome-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    background: var(--bg-hover);
    transition: var(--transition);
}

.welcome-pill:hover {
    color: var(--text-main);
    border-color: var(--border-hi);
}

/* Category header inside file list */
.cat-file-header {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 12px 8px 6px;
    margin-bottom: 4px;
    border-left: 3px solid var(--cat-color, var(--primary));
    padding-left: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cat-file-header:first-child { padding-top: 0; }

/* File Items */
.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 6px;
    cursor: pointer;
    background: transparent;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.file-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--cat-color, var(--primary));
    opacity: 0;
    transition: opacity var(--transition);
}

.file-item:hover {
    border-color: var(--border-hi);
    background: var(--bg-hover);
    transform: translateX(3px);
}

.file-item:hover::before { opacity: 1; }

.file-item.active {
    border-color: rgba(var(--primary-rgb), 0.35);
    background: var(--primary-light);
}

.file-item.active::before {
    opacity: 1;
    background: var(--primary);
}

.file-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

.file-meta { overflow: hidden; flex: 1; }

.file-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.file-item.active .file-name {
    color: var(--primary);
    font-weight: 700;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-subtle);
    font-weight: 500;
}

.file-badge {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--border);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Empty / loading states */
.empty-cat {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-subtle);
    font-size: 0.9rem;
}

.empty-cat i {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
    opacity: 0.5;
}

/* ============================================================
   5. PREVIEW AREA
   ============================================================ */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
    position: relative;
    overflow: hidden;
}

/* Toolbar */
.preview-toolbar {
    height: var(--header-h);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    flex-shrink: 0;
    gap: 12px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    overflow: hidden;
    min-width: 0;
}

.toolbar-back-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-body);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}

.toolbar-back-btn:hover {
    border-color: var(--border-hi);
    color: var(--text-main);
    background: var(--bg-hover);
}

.toolbar-doc-meta { overflow: hidden; }

.toolbar-doc-meta h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.doc-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    border: 1px solid var(--border);
    font-family: inherit;
}

.btn-focus {
    background: var(--bg-body);
    color: var(--text-muted);
}

.btn-focus:hover {
    background: var(--bg-hover);
    color: var(--text-main);
    border-color: var(--border-hi);
}

.btn-dl {
    background: var(--primary);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 12px rgba(var(--primary-rgb), 0.3);
}

.btn-dl:hover {
    background: var(--primary);
    box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.4);
    transform: translateY(-1px);
}

.btn-open {
    background: var(--bg-body);
    color: var(--text-muted);
}

.btn-open:hover {
    color: var(--text-main);
    background: var(--bg-hover);
    border-color: var(--border-hi);
}

/* iframe */
#pdf-frame {
    flex: 1;
    border: none;
    width: 100%;
    background: var(--bg-body);
    display: none;
}

/* Empty State */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 2rem;
    text-align: center;
}

.empty-icon {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-xl);
    background: rgba(var(--primary-rgb), 0.08);
    border: 1px solid rgba(var(--primary-rgb), 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 6px;
}

.empty-state h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
}

.empty-state p {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 300px;
}

/* Focus mode */
body.focus-mode .sidebar,
body.focus-mode .list-panel {
    display: none;
}

/* ============================================================
   6. RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
    :root { --list-w: 340px; }
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
        z-index: 30;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

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

    :root { --list-w: 100%; }

    .list-panel { width: 100%; }

    .preview-area {
        position: fixed;
        inset: 0;
        z-index: 50;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

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

    .mobile-header { display: flex; }
    .mobile-category-scroll { display: flex; }

    .btn-label { display: none; }
    .toolbar-btn { padding: 8px 12px; }
}

@media (max-width: 600px) {
    .toolbar-actions { gap: 6px; }
}
