/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #1c2128;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --border: #30363d;
    --accent-blue: #58a6ff;
    --accent-green: #3fb950;
    --accent-orange: #d29922;
    --accent-purple: #bc8cff;
    --accent-red: #f85149;
    --beginner: #3fb950;
    --intermediate: #d29922;
    --advanced: #f85149;
    --sidebar-width: 300px;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    overflow-x: hidden;
}

/* ===== Layout ===== */
.app {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.progress-bar-container {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
    border-radius: 3px;
    width: 0%;
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 12px;
    color: var(--text-muted);
}

.user-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.user-name {
    color: var(--text-primary);
    font-weight: 500;
    flex: 1;
}

.admin-link, .logout-link, .pwd-link {
    color: var(--accent-blue);
    cursor: pointer;
    text-decoration: none;
    font-size: 12px;
}

.admin-link:hover, .logout-link:hover, .pwd-link:hover {
    text-decoration: underline;
}

.logout-link {
    color: var(--text-muted);
}

.pwd-link {
    color: var(--text-secondary);
}

/* Password Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
}
.modal-body { padding: 24px; }
.modal-body .form-group { margin-bottom: 16px; }
.modal-body .form-group label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.modal-body .form-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.modal-body .form-group input:focus { border-color: var(--accent-blue); }
.pwd-error {
    background: rgba(248,81,73,0.1);
    border: 1px solid rgba(248,81,73,0.3);
    color: var(--accent-red);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
}
.btn-pwd-submit {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn-pwd-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(88,166,255,0.3);
}
.pwd-success {
    background: rgba(63,185,80,0.1);
    border: 1px solid rgba(63,185,80,0.3);
    color: var(--accent-green);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
}

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

.phase-group {
    margin-bottom: 8px;
}

.phase-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 20px;
    color: var(--text-muted);
}

.phase-title.phase-beginner { color: var(--beginner); }
.phase-title.phase-intermediate { color: var(--intermediate); }
.phase-title.phase-advanced { color: var(--advanced); }

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    padding: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    cursor: pointer;
    border-left: 3px solid transparent;
    background: none;
    border-top: none;
    border-right: none;
    border-bottom: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-link.active {
    background: rgba(88, 166, 255, 0.1);
    color: var(--accent-blue);
    border-left-color: var(--accent-blue);
}

.nav-link.completed {
    color: var(--text-secondary);
}

.nav-link .day-num {
    font-size: 11px;
    font-weight: 600;
    min-width: 28px;
    color: var(--text-muted);
}

.nav-link .day-title-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-link .check {
    margin-left: auto;
    font-size: 14px;
    min-width: 18px;
    text-align: center;
}

.nav-link.completed .check {
    color: var(--accent-green);
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    padding: 40px 60px;
    max-width: 960px;
}

/* ===== Welcome Page ===== */
.welcome-hero {
    text-align: center;
    padding: 60px 0 40px;
}

.welcome-hero h1 {
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.welcome-hero p {
    font-size: 18px;
    color: var(--text-secondary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin: 40px 0;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

.stat-number {
    font-size: 32px;
    font-weight: 800;
    color: var(--accent-blue);
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.roadmap {
    margin: 48px 0;
}

.roadmap h2 {
    font-size: 24px;
    margin-bottom: 24px;
    text-align: center;
}

.roadmap-phases {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.roadmap-phase {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    border-top: 3px solid;
}

.roadmap-phase.beginner { border-top-color: var(--beginner); }
.roadmap-phase.intermediate { border-top-color: var(--intermediate); }
.roadmap-phase.advanced { border-top-color: var(--advanced); }

.roadmap-phase h3 {
    font-size: 18px;
    margin-bottom: 4px;
}

.roadmap-phase p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.roadmap-phase ul {
    list-style: none;
    font-size: 14px;
    color: var(--text-secondary);
}

.roadmap-phase ul li {
    padding: 4px 0;
}

.roadmap-phase ul li::before {
    content: "→ ";
    color: var(--text-muted);
}

.btn-start {
    display: block;
    margin: 40px auto;
    padding: 14px 40px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(88, 166, 255, 0.3);
}

/* ===== Day Top Bar ===== */
.day-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.btn-back {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-back:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* ===== Check-in ===== */
.btn-checkin {
    padding: 8px 20px;
    background: linear-gradient(135deg, var(--accent-orange), var(--accent-red));
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-checkin:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(210, 153, 34, 0.3);
}

.checkin-done {
    color: var(--accent-orange);
    font-size: 14px;
    font-weight: 500;
}

.streak-badge {
    background: rgba(210, 153, 34, 0.12);
    color: var(--accent-orange);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}

/* ===== Day Content ===== */
.day-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.day-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.day-badge.beginner { background: rgba(63,185,80,0.15); color: var(--beginner); }
.day-badge.intermediate { background: rgba(210,153,34,0.15); color: var(--intermediate); }
.day-badge.advanced { background: rgba(248,81,73,0.15); color: var(--advanced); }

.day-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.day-meta {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.day-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Content sections */
.content-section {
    margin-bottom: 32px;
}

.content-section h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 8px;
}

.content-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 16px 0 8px;
    color: var(--text-primary);
}

.content-section h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 14px 0 6px;
    color: var(--text-primary);
}

.content-section p {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 15px;
}

.content-section ul, .content-section ol {
    padding-left: 20px;
    margin-bottom: 12px;
}

.content-section li {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 6px;
}

/* Code blocks */
.code-block {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 12px 0;
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.code-block pre {
    padding: 16px;
    overflow-x: auto;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Info boxes */
.info-box {
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 16px 0;
    border-left: 4px solid var(--accent-blue);
    background: rgba(88,166,255,0.06);
    font-size: 14px;
}

.info-box strong {
    color: var(--text-primary);
}

.info-box p {
    color: var(--text-secondary);
    margin: 4px 0;
}

.info-box ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.info-box li {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

/* Practice section */
.practice-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin: 12px 0;
}

.practice-item h4 {
    font-size: 15px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.practice-item p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* ===== Tasks Section ===== */
.tasks-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.tasks-container {
    margin: 16px 0;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
}

.task-item:hover {
    background: var(--bg-tertiary);
}

.task-item input[type="checkbox"] {
    display: none;
}

.task-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.task-item.done .task-checkbox {
    background: var(--accent-green);
    border-color: var(--accent-green);
}

.task-item.done .task-checkbox::after {
    content: "✓";
    color: white;
    font-size: 13px;
    font-weight: bold;
}

.task-text {
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.task-item.done .task-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 16px;
}

.task-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
    border-radius: 3px;
    transition: width 0.4s ease;
}

.task-progress-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: right;
}

/* ===== Quiz Section ===== */
.quiz-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.quiz-result-banner {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.quiz-result-banner.perfect {
    background: rgba(63, 185, 80, 0.12);
    color: var(--accent-green);
}

.quiz-result-banner.good {
    background: rgba(88, 166, 255, 0.12);
    color: var(--accent-blue);
}

.quiz-result-banner.retry {
    background: rgba(210, 153, 34, 0.12);
    color: var(--accent-orange);
}

.quiz-item {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.quiz-item:last-of-type {
    border-bottom: none;
    margin-bottom: 16px;
}

.quiz-question {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: var(--text-secondary);
}

.quiz-option:hover {
    border-color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.05);
}

.quiz-option.selected {
    border-color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.1);
    color: var(--text-primary);
}

.quiz-option.correct {
    border-color: var(--accent-green);
    background: rgba(63, 185, 80, 0.1);
    color: var(--accent-green);
}

.quiz-option.wrong {
    border-color: var(--accent-red);
    background: rgba(248, 81, 73, 0.1);
    color: var(--accent-red);
}

.quiz-option input[type="radio"] {
    display: none;
}

.quiz-radio {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.2s;
    position: relative;
}

.quiz-option.selected .quiz-radio {
    border-color: var(--accent-blue);
}

.quiz-option.selected .quiz-radio::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 8px;
    height: 8px;
    background: var(--accent-blue);
    border-radius: 50%;
}

.quiz-option.correct .quiz-radio {
    border-color: var(--accent-green);
    background: var(--accent-green);
}

.quiz-option.correct .quiz-radio::after {
    content: "✓";
    position: absolute;
    top: -2px;
    left: 2px;
    color: white;
    font-size: 11px;
    font-weight: bold;
    background: none;
    width: auto;
    height: auto;
    border-radius: 0;
}

.quiz-option.wrong .quiz-radio {
    border-color: var(--accent-red);
    background: var(--accent-red);
}

.quiz-option.wrong .quiz-radio::after {
    content: "✗";
    position: absolute;
    top: -2px;
    left: 2px;
    color: white;
    font-size: 11px;
    font-weight: bold;
    background: none;
    width: auto;
    height: auto;
    border-radius: 0;
}

.quiz-feedback {
    display: none;
    margin-top: 8px;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 4px;
}

.feedback-correct {
    color: var(--accent-green);
}

.feedback-wrong {
    color: var(--accent-red);
}

.btn-quiz-submit {
    display: block;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-quiz-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(88, 166, 255, 0.3);
}

.btn-quiz-submit.submitted {
    background: var(--bg-tertiary);
    cursor: default;
}

/* ===== Day Footer ===== */
.day-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.day-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.nav-btn {
    padding: 10px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
}

.nav-btn.prev {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.nav-btn.prev:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.nav-btn.next {
    background: var(--accent-blue);
    border: none;
    color: white;
}

.nav-btn.next:hover {
    background: #4c9aed;
}

.btn-complete {
    padding: 10px 24px;
    background: var(--accent-green);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-complete:hover {
    background: #2ea043;
}

.btn-complete.done {
    background: var(--bg-tertiary);
    color: var(--accent-green);
    border: 1px solid var(--accent-green);
}

/* Checklist in content */
.checklist {
    list-style: none;
    padding: 0;
}

.checklist li {
    padding: 6px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.checklist li::before {
    content: "☐ ";
    color: var(--text-muted);
}

/* ===== Mobile Toggle ===== */
.menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    font-size: 20px;
    cursor: pointer;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 24px 20px;
    }
    .menu-toggle {
        display: block;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .roadmap-phases {
        grid-template-columns: 1fr;
    }
    .day-top-bar {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    .day-navigation {
        flex-direction: column;
        gap: 8px;
    }
    .day-navigation .nav-btn,
    .day-navigation .btn-complete {
        width: 100%;
        text-align: center;
    }
}
