/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f8fafc; color: #334155; line-height: 1.6; min-height: 100vh;
}
a { color: #6366f1; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Top Nav === */
.topnav {
    background: #fff; border-bottom: 1px solid #e2e8f0; padding: 0 24px;
    height: 56px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 100;
}
.nav-brand { font-weight: 700; font-size: 1.05rem; color: #6366f1; }
.nav-brand:hover { text-decoration: none; }
.nav-right { display: flex; align-items: center; gap: 16px; font-size: .88rem; }
.nav-email { color: #64748b; }
.nav-link { color: #6366f1; font-weight: 500; }

/* === Container (for pages that use it) === */
.container { max-width: 860px; margin: 0 auto; padding: 32px 24px; }

/* === Buttons & Badges === */
.btn {
    display: inline-block; padding: 10px 20px; border-radius: 8px;
    font-size: .9rem; font-weight: 600; text-decoration: none; transition: all .2s;
}
.btn-primary { background: #6366f1; color: #fff; }
.btn-primary:hover { background: #4f46e5; text-decoration: none; }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; text-decoration: none; }

.badge {
    display: inline-block; padding: 4px 12px; border-radius: 20px;
    font-size: .8rem; font-weight: 600;
}
.badge-done { background: #d1fae5; color: #065f46; }
.badge-progress { background: #e0e7ff; color: #3730a3; }
.badge-new { background: #f1f5f9; color: #64748b; }

/* === Login === */
.login-wrapper { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 120px); }
.login-card {
    background: #fff; border-radius: 16px; padding: 48px 40px; max-width: 420px; width: 100%;
    box-shadow: 0 4px 24px rgba(0,0,0,.06); text-align: center;
}
.login-card h1 { font-size: 1.5rem; color: #1e293b; margin-bottom: .5rem; }
.login-subtitle { color: #64748b; margin-bottom: 2rem; font-size: .95rem; }
.login-form { text-align: left; }
.login-form label { display: block; font-weight: 600; font-size: .88rem; color: #475569; margin-bottom: .4rem; }
.login-form input {
    width: 100%; padding: 12px 14px; border: 2px solid #e2e8f0; border-radius: 8px;
    font-size: 1rem; margin-bottom: 1rem; transition: border .2s;
}
.login-form input:focus { border-color: #6366f1; outline: none; }
.login-form .btn { width: 100%; text-align: center; padding: 12px; font-size: 1rem; cursor: pointer; border: none; }
.login-hint { color: #94a3b8; font-size: .82rem; margin-top: 1rem; }
.login-success { background: #d1fae5; color: #065f46; padding: 12px; border-radius: 8px; margin-bottom: 1rem; }
.login-error { background: #fee2e2; color: #991b1b; padding: 12px; border-radius: 8px; margin-bottom: 1rem; }

/* === Dashboard === */
.dashboard-container { max-width: 900px; margin: 0 auto; padding: 48px 24px; }
.dashboard-header { text-align: center; margin-bottom: 2.5rem; }
.dashboard-header h1 { font-size: 1.75rem; color: #1e293b; font-weight: 700; }
.dashboard-subtitle { color: #64748b; font-size: 1.05rem; margin-top: .5rem; }

.course-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.5rem;
}
.course-tile {
    background: #fff; border: 2px solid #e2e8f0; border-radius: 16px;
    padding: 28px; text-decoration: none; color: inherit;
    display: flex; gap: 20px; align-items: flex-start;
    transition: all .2s ease;
}
.course-tile:hover {
    border-color: #6366f1; box-shadow: 0 8px 30px rgba(99,102,241,.12);
    transform: translateY(-2px); text-decoration: none;
}
.course-tile-badge { font-size: 2.5rem; flex-shrink: 0; margin-top: 4px; }
.course-tile-body { flex: 1; }
.course-tile-body h2 { font-size: 1.2rem; color: #1e293b; margin-bottom: .35rem; }
.course-tile-body p { color: #64748b; font-size: .92rem; margin-bottom: .75rem; line-height: 1.5; }
.course-tile-meta { display: flex; gap: 16px; font-size: .82rem; color: #94a3b8; }
.meta-progress { color: #6366f1; font-weight: 600; }
.tile-progress-bar {
    height: 4px; background: #e2e8f0; border-radius: 4px; margin-top: .75rem; overflow: hidden;
}
.tile-progress-fill { height: 100%; background: #6366f1; border-radius: 4px; transition: width .3s; }

/* === Course Page (module list) === */
.course-header { margin-bottom: 2rem; }
.course-header h1 { font-size: 1.5rem; color: #1e293b; }
.course-subtitle { color: #64748b; margin: .25rem 0 1rem; }
.progress-bar-wrapper { display: flex; align-items: center; gap: 12px; }
.progress-bar { flex: 1; height: 8px; background: #e2e8f0; border-radius: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: #6366f1; border-radius: 8px; transition: width .3s; }
.progress-text { font-size: .85rem; color: #64748b; white-space: nowrap; }

.module-list { display: flex; flex-direction: column; gap: .75rem; }
.module-card {
    display: flex; align-items: flex-start; gap: 16px; padding: 16px 20px;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    text-decoration: none; color: inherit; transition: all .15s;
}
.module-card:hover { border-color: #c7d2fe; box-shadow: 0 2px 12px rgba(99,102,241,.08); text-decoration: none; }
.module-card.completed { border-left: 3px solid #10b981; }
.module-num {
    width: 36px; height: 36px; border-radius: 50%; background: #eef2ff; color: #6366f1;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
    font-size: .9rem; flex-shrink: 0;
}
.module-card.completed .module-num { background: #d1fae5; color: #065f46; }
.checkmark { font-size: 1rem; }
.module-info { flex: 1; }
.module-info h3 { font-size: 1rem; color: #1e293b; margin-bottom: .2rem; }
.module-info p { font-size: .88rem; color: #64748b; margin: 0; }
.module-time { font-size: .78rem; color: #94a3b8; }

/* === Module Page — Sidebar Layout === */
.module-layout {
    display: flex; min-height: calc(100vh - 56px);
}
.module-sidebar {
    width: 280px; min-width: 280px; background: #fff; border-right: 1px solid #e2e8f0;
    padding: 0; position: sticky; top: 56px; height: calc(100vh - 56px);
    overflow-y: auto; flex-shrink: 0;
}
.sidebar-header {
    padding: 16px 20px; border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}
.sidebar-course-link {
    font-weight: 600; color: #6366f1; text-decoration: none; font-size: .9rem;
    display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-course-link:hover { text-decoration: underline; }
.sidebar-nav { display: flex; flex-direction: column; padding: 8px 0; }
.sidebar-item {
    display: flex; align-items: flex-start; gap: 10px; padding: 10px 20px;
    text-decoration: none; color: #475569; font-size: .88rem; line-height: 1.4;
    border-left: 3px solid transparent; transition: all .15s;
}
.sidebar-item:hover { background: #f8fafc; color: #4338ca; text-decoration: none; }
.sidebar-item.active {
    background: #eef2ff; border-left-color: #6366f1; color: #4338ca; font-weight: 600;
}
.sidebar-item.completed .sidebar-num { background: #10b981; color: #fff; }
.sidebar-num {
    width: 26px; height: 26px; border-radius: 50%; background: #eef2ff; color: #6366f1;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; flex-shrink: 0;
}
.sidebar-item.active .sidebar-num { background: #6366f1; color: #fff; }
.sidebar-title { flex: 1; }

/* Module Main Content */
.module-main {
    flex: 1; padding: 32px 40px; max-width: 900px; background: #fff;
    min-height: calc(100vh - 56px);
}
.module-header { margin-bottom: 1.5rem; }
.module-header h1 { font-size: 1.5rem; color: #1e293b; margin-bottom: .5rem; }
.module-desc { color: #64748b; font-size: .95rem; }

.video-wrapper {
    margin-bottom: 1.5rem; border-radius: 12px; overflow: hidden;
    background: #0f172a;
}
.video-wrapper video { width: 100%; display: block; border-radius: 12px; }

.module-actions {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 0; margin-bottom: 1rem;
}
.module-nav { display: flex; gap: 8px; }

/* === Markdown Content === */
.markdown-body {
    line-height: 1.75; color: #334155; font-size: 1rem;
    padding-top: 2rem; border-top: 1px solid #e2e8f0;
}
.markdown-body h1 { font-size: 1.5rem; color: #1e293b; margin: 2.5rem 0 1rem; font-weight: 700; }
.markdown-body h2 {
    font-size: 1.3rem; color: #1e293b; margin: 2rem 0 .75rem;
    padding-bottom: .5rem; border-bottom: 1px solid #e2e8f0;
}
.markdown-body h3 { font-size: 1.1rem; color: #334155; margin: 1.5rem 0 .5rem; font-weight: 600; }
.markdown-body h4 { font-size: 1rem; color: #475569; margin: 1.25rem 0 .5rem; font-weight: 600; }
.markdown-body p { margin: .75rem 0; }
.markdown-body ul, .markdown-body ol { margin: .75rem 0; padding-left: 1.75rem; }
.markdown-body li { margin: .4rem 0; }
.markdown-body li > ul, .markdown-body li > ol { margin: .25rem 0; }
.markdown-body code {
    background: #f1f5f9; padding: 2px 7px; border-radius: 4px;
    font-size: .88em; color: #6366f1; font-family: 'SF Mono', Monaco, Consolas, monospace;
}
.markdown-body pre {
    background: #1e293b; color: #e2e8f0; padding: 16px 20px; border-radius: 10px;
    overflow-x: auto; font-size: .88rem; line-height: 1.55; margin: 1.25rem 0;
}
.markdown-body pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
.markdown-body blockquote {
    border-left: 4px solid #6366f1; margin: 1.25rem 0; padding: .75rem 1.25rem;
    background: #eef2ff; color: #475569; border-radius: 0 8px 8px 0; font-size: .95rem;
}
.markdown-body table { border-collapse: collapse; width: 100%; margin: 1.25rem 0; }
.markdown-body th, .markdown-body td {
    border: 1px solid #e2e8f0; padding: 10px 14px; text-align: left; font-size: .9rem;
}
.markdown-body th { background: #f8fafc; font-weight: 600; color: #1e293b; }
.markdown-body strong { color: #1e293b; }
.markdown-body em { color: #475569; }
.markdown-body a { color: #6366f1; }
.markdown-body hr { border: none; border-top: 1px solid #e2e8f0; margin: 2rem 0; }
.markdown-body img { max-width: 100%; border-radius: 8px; margin: 1rem 0; }

/* === Admin === */
.admin-stats { display: flex; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.stat-card {
    background: #fff; padding: 16px 20px; border-radius: 12px;
    border: 1px solid #e2e8f0; flex: 1; min-width: 140px;
}
.stat-card h3 { font-size: .78rem; text-transform: uppercase; color: #94a3b8; letter-spacing: .05em; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; color: #1e293b; }

.invite-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    padding: 20px; margin-bottom: 2rem;
}
.invite-card h2 { font-size: 1.1rem; margin-bottom: 1rem; color: #1e293b; }
.invite-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.invite-form label { display: block; font-size: .85rem; font-weight: 600; color: #475569; margin-bottom: .3rem; }
.invite-form input {
    padding: 10px 12px; border: 2px solid #e2e8f0; border-radius: 8px; font-size: .95rem;
    min-width: 240px;
}
.invite-form input:focus { border-color: #6366f1; outline: none; }
.course-checkboxes { display: flex; gap: 12px; flex-wrap: wrap; }
.checkbox-label {
    display: flex; align-items: center; gap: 6px; font-size: .88rem; color: #475569;
    cursor: pointer;
}
.checkbox-label input { accent-color: #6366f1; }

table.admin-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.admin-table th, table.admin-table td {
    padding: 10px 14px; text-align: left; border-bottom: 1px solid #e2e8f0;
}
table.admin-table th { color: #64748b; font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.section-heading { font-size: 1.1rem; color: #1e293b; margin: 2rem 0 1rem; }

/* === Mobile === */
@media (max-width: 768px) {
    .container { padding: 20px 16px; }
    .module-layout { flex-direction: column; }
    .module-sidebar {
        width: 100%; min-width: unset; position: relative; top: auto;
        height: auto; max-height: none; border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    .sidebar-nav { flex-direction: row; overflow-x: auto; padding: 8px 12px; gap: 4px; }
    .sidebar-item {
        flex-direction: column; align-items: center; padding: 8px 12px;
        white-space: nowrap; min-width: auto; border-left: none;
        border-bottom: 3px solid transparent; font-size: .78rem;
    }
    .sidebar-item.active { border-bottom-color: #6366f1; border-left: none; background: transparent; }
    .sidebar-title { display: none; }
    .module-main { padding: 20px 16px; }
    .course-grid { grid-template-columns: 1fr; }
    .dashboard-container { padding: 24px 16px; }
    .course-tile { padding: 20px; }
    .invite-form { flex-direction: column; }
    .topnav { padding: 0 16px; }
}

/* === Interactive Quiz === */
.quiz-section {
    background: #f8fafc; border: 2px solid #e2e8f0; border-radius: 16px;
    padding: 28px; margin: 2rem 0;
}
.quiz-section h2 { font-size: 1.3rem; color: #1e293b; margin: 0 0 .5rem; border: none; padding: 0; }
.quiz-section > p { color: #64748b; font-size: .95rem; margin-bottom: 1.5rem; }

.quiz-question { margin-bottom: 1.5rem; }
.quiz-q-text { font-weight: 600; color: #1e293b; margin-bottom: .75rem; font-size: .95rem; line-height: 1.5; }

.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option {
    display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px;
    background: #fff; border: 2px solid #e2e8f0; border-radius: 10px;
    cursor: pointer; transition: all .15s; user-select: none;
}
.quiz-option:hover { border-color: #c7d2fe; background: #eef2ff; }
.quiz-option.selected { border-color: #6366f1; background: #eef2ff; }
.quiz-option.correct { border-color: #10b981; background: #d1fae5; }
.quiz-option.incorrect { border-color: #ef4444; background: #fee2e2; }
.quiz-option.correct .quiz-letter { background: #10b981; color: #fff; }
.quiz-option.incorrect .quiz-letter { background: #ef4444; color: #fff; }

.quiz-letter {
    width: 28px; height: 28px; border-radius: 50%; background: #eef2ff; color: #6366f1;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; flex-shrink: 0;
}
.quiz-option.selected .quiz-letter { background: #6366f1; color: #fff; }
.quiz-text { font-size: .9rem; color: #334155; line-height: 1.45; padding-top: 3px; }

.quiz-actions { margin-top: 1.5rem; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.quiz-submit { cursor: pointer; border: none; }
.quiz-result {
    font-size: .95rem; padding: 10px 16px; border-radius: 8px; display: none;
}
.quiz-result.quiz-pass { display: block; background: #d1fae5; color: #065f46; }
.quiz-result.quiz-retry { display: block; background: #fef3c7; color: #92400e; }
