/* ============================================================
   LearnHub — Purple/Teal theme (NOT w3schools green)
   Design: clean, modern, glass-morphism, dark/light
   ============================================================ */

:root {
    --primary: #6C5CE7;
    --primary-dark: #5A4BD1;
    --primary-light: #A29BFE;
    --secondary: #00B894;
    --secondary-dark: #00A381;
    --secondary-light: #55EFC4;
    --accent: #FDCB6E;
    --accent-dark: #F9A825;
    --danger: #E17055;
    --danger-light: #FAB1A0;
    --info: #74B9FF;

    --bg-dark: #0f0f23;
    --bg-card: #1a1a2e;
    --bg-sidebar: #16213e;
    --bg-code: #1e1e2e;
    --bg-input: #252538;
    --border: #2d2d4a;
    --text: #e0e0e0;
    --text-dim: #8888aa;
    --text-muted: #666688;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);

    --radius: 10px;
    --radius-sm: 6px;
    --transition: all 0.3s ease;
}

/* Light theme */
[data-theme="light"] {
    --bg-dark: #f8f9fa;
    --bg-card: #ffffff;
    --bg-sidebar: #f0f2f5;
    --bg-code: #2d2d2d;
    --bg-input: #eef0f4;
    --border: #d1d5db;
    --text: #1f2937;
    --text-dim: #6b7280;
    --text-muted: #9ca3af;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    padding-top: 28px; /* space for disclaimer banner */
}

/* ============================================================
   TOP NAVBAR
   ============================================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--primary-light);
    font-weight: 700;
    font-size: 1.2rem;
}

.navbar-brand .logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
}

.navbar-end {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-end a, .navbar-end button {
    color: var(--text-dim);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

.navbar-end a:hover, .navbar-end button:hover {
    color: var(--text);
    background: var(--bg-input);
}

.theme-toggle {
    font-size: 1.1rem;
}

.user-badge {
    background: var(--primary);
    color: white !important;
    padding: 4px 12px !important;
    border-radius: 20px !important;
    font-size: 0.8rem !important;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 999;
    transition: transform 0.3s ease;
}

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

.sidebar-section {
    padding: 12px 0;
}

.sidebar-heading {
    padding: 8px 16px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text-dim);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.9rem;
    cursor: pointer;
}

.sidebar-item:hover {
    color: var(--text);
    background: rgba(108, 92, 231, 0.1);
}

.sidebar-item.active {
    color: var(--primary-light);
    background: rgba(108, 92, 231, 0.15);
    border-right: 3px solid var(--primary);
}

.sidebar-item .icon {
    width: 22px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-sub {
    padding-left: 20px;
}

.sidebar-sub .sidebar-item {
    font-size: 0.85rem;
    padding: 6px 16px 6px 26px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: 260px;
    margin-top: 56px;
    padding: 24px 32px;
    min-height: calc(100vh - 56px);
}

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero {
    text-align: center;
    padding: 60px 20px 40px;
    background: linear-gradient(135deg, rgba(108,92,231,0.1), rgba(0,184,148,0.1));
    border-radius: var(--radius);
    margin-bottom: 32px;
}

.hero h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
}

.hero p {
    color: var(--text-dim);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto 24px;
}

/* ============================================================
   CARDS GRID
   ============================================================ */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.card-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text);
}

.card p {
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.5;
}

.card .badge {
    display: inline-block;
    background: rgba(108,92,231,0.2);
    color: var(--primary-light);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-top: 8px;
}

.card .card-color-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

/* Image-based cards */
.card-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    margin: -24px -24px 16px -24px;
    width: calc(100% + 48px);
}

/* ============================================================
   TOPIC HEADER (8-sub-image grid) + Responsive Banner
   ============================================================ */
.topic-banner {
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.banner-img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 260px;
    object-fit: cover;
}

.topic-header-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    margin-bottom: 24px;
    border-radius: var(--radius);
    overflow: hidden;
}

.topic-header-cell {
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: transform 0.2s ease;
}

.topic-header-cell:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border-color: var(--primary);
}

.topic-header-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

/* Mobile: 4 columns */
@media (max-width: 480px) {
    .topic-header-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }
    .topic-banner {
        border-radius: var(--radius-sm);
        margin-bottom: 12px;
    }
}

/* Tablet: 6 columns (optional) */
@media (min-width: 481px) and (max-width: 768px) {
    .topic-header-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }
}

/* ============================================================
   LEARNING CONTENT
   ============================================================ */
.lesson-content {
    max-width: 900px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
}

.lesson-content h2 {
    font-size: 1.8rem;
    color: var(--primary-light);
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

.lesson-content h3 {
    font-size: 1.3rem;
    color: var(--secondary-light);
    margin: 20px 0 10px;
}

.lesson-content p {
    margin-bottom: 12px;
    line-height: 1.8;
}

.lesson-content ul, .lesson-content ol {
    margin: 12px 0 12px 24px;
}

.lesson-content li {
    margin-bottom: 6px;
}

.lesson-content pre {
    background: var(--bg-code);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 12px 0;
    overflow-x: auto;
    border: 1px solid var(--border);
}

.lesson-content code {
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.9rem;
}

.lesson-content pre code {
    background: none;
    padding: 0;
}

.lesson-content :not(pre) > code {
    background: rgba(108,92,231,0.15);
    color: var(--primary-light);
    padding: 2px 6px;
    border-radius: 4px;
}

.lesson-content a {
    color: var(--secondary-light);
    text-decoration: none;
}

.lesson-content a:hover {
    text-decoration: underline;
}

.lesson-content blockquote {
    border-left: 3px solid var(--primary);
    padding: 12px 16px;
    margin: 16px 0;
    background: rgba(108,92,231,0.05);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.2);
}

.form-input::placeholder { color: var(--text-muted); }

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666688' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108,92,231,0.4);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-dark);
    box-shadow: 0 4px 12px rgba(0,184,148,0.4);
}

.btn-accent {
    background: var(--accent);
    color: #1a1a2e;
}

.btn-accent:hover {
    background: var(--accent-dark);
    box-shadow: 0 4px 12px rgba(253,203,110,0.4);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-block {
    display: block;
    width: 100%;
    text-align: center;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(225,112,85,0.15);
    border: 1px solid var(--danger);
    color: var(--danger-light);
}

.alert-success {
    background: rgba(0,184,148,0.15);
    border: 1px solid var(--secondary);
    color: var(--secondary-light);
}

.alert-info {
    background: rgba(116,185,255,0.15);
    border: 1px solid var(--info);
    color: var(--info);
}

/* ============================================================
   EXAM SYSTEM
   ============================================================ */
.exam-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    transition: var(--transition);
}

.exam-card:hover {
    border-color: var(--primary);
}

.exam-question {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

.exam-question h4 {
    margin-bottom: 16px;
    font-size: 1rem;
}

.exam-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.exam-option:hover {
    border-color: var(--primary);
    background: rgba(108,92,231,0.05);
}

.exam-option input[type="radio"] {
    accent-color: var(--primary);
}

.exam-option.selected {
    border-color: var(--primary);
    background: rgba(108,92,231,0.1);
}

.exam-option.correct {
    border-color: var(--secondary);
    background: rgba(0,184,148,0.1);
}

.exam-option.wrong {
    border-color: var(--danger);
    background: rgba(225,112,85,0.1);
}

.exam-timer {
    position: fixed;
    top: 70px;
    right: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 20px;
    z-index: 998;
    font-weight: 600;
}

/* ============================================================
   CERTIFICATE
   ============================================================ */
.certificate {
    max-width: 700px;
    margin: 40px auto;
    background: var(--bg-card);
    border: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    position: relative;
}

.certificate::before {
    content: '🏆';
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
}

.certificate h2 {
    color: var(--accent);
    font-size: 2rem;
    margin-bottom: 8px;
}

.certificate .cert-code {
    font-family: monospace;
    font-size: 1.2rem;
    color: var(--primary-light);
    background: rgba(108,92,231,0.1);
    padding: 4px 16px;
    border-radius: 4px;
    display: inline-block;
    margin: 12px 0;
}

.certificate .cert-level {
    display: inline-block;
    padding: 4px 16px;
    border-radius: 20px;
    font-weight: 600;
    margin: 8px 0;
}

.cert-level.beginner { background: rgba(0,184,148,0.2); color: var(--secondary-light); }
.cert-level.intermediate { background: rgba(253,203,110,0.2); color: var(--accent); }
.cert-level.advanced { background: rgba(225,112,85,0.2); color: var(--danger-light); }
.cert-level.expert { background: rgba(108,92,231,0.2); color: var(--primary-light); }

/* ============================================================
   CTF PAGE
   ============================================================ */
.ctf-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.ctf-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(253,203,110,0.1);
}

.ctf-flag-input {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.ctf-flag-input input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: monospace;
}

.ctf-flag-input input:focus {
    border-color: var(--accent);
    outline: none;
}

.difficulty-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.difficulty-easy { background: rgba(0,184,148,0.2); color: var(--secondary-light); }
.difficulty-medium { background: rgba(253,203,110,0.2); color: var(--accent); }
.difficulty-hard { background: rgba(225,112,85,0.2); color: var(--danger-light); }
.difficulty-expert { background: rgba(225,112,85,0.4); color: #ff6b6b; }

.scoreboard-table {
    width: 100%;
    border-collapse: collapse;
}

.scoreboard-table th, .scoreboard-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.scoreboard-table th {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scoreboard-table tr:hover td {
    background: rgba(108,92,231,0.03);
}

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
    display: flex;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--text-dim);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary-light);
}

/* ============================================================
   PAGINATION / SECTION INFO
   ============================================================ */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-header h2 {
    font-size: 1.5rem;
    color: var(--text);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    .hero h1 {
        font-size: 1.8rem;
    }
    .card-grid {
        grid-template-columns: 1fr;
    }
    .topic-header-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .exam-timer {
        position: static;
        margin-bottom: 16px;
    }
    .navbar-brand span {
        display: none;
    }
}

@media (max-width: 480px) {
    .topic-header-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   HAMBURGER MENU
   ============================================================ */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px;
}

@media (max-width: 768px) {
    .hamburger {
        display: block;
    }
}

/* ============================================================
   MISC
   ============================================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-dim); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-fill.good { background: var(--secondary); }
.progress-fill.warn { background: var(--accent); }
.progress-fill.bad { background: var(--danger); }
.progress-fill.primary { background: var(--primary); }

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
}

.data-table th {
    padding: 12px 16px;
    background: var(--bg-sidebar);
    color: var(--text-dim);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(108,92,231,0.03);
}

/* Tag / Token display */
.token-tag {
    display: inline-block;
    padding: 2px 10px;
    background: rgba(108,92,231,0.15);
    color: var(--primary-light);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8rem;
}

/* Access restriction badge */
.restricted-badge {
    display: inline-block;
    padding: 2px 10px;
    background: rgba(225,112,85,0.15);
    color: var(--danger-light);
    border-radius: 4px;
    font-size: 0.75rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}
