/* ========== CSS Variables ========== */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #1c2128;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --accent-bg: rgba(88, 166, 255, 0.1);
    --green: #3fb950;
    --green-bg: rgba(63, 185, 80, 0.1);
    --yellow: #d29922;
    --yellow-bg: rgba(210, 153, 34, 0.1);
    --red: #f85149;
    --purple: #bc8cff;
    --purple-bg: rgba(188, 140, 255, 0.1);
    --sidebar-width: 300px;
    --header-height: 56px;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

/* ========== Reset ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
}

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

/* ========== Mobile Header ========== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    align-items: center;
    padding: 0 16px;
    z-index: 100;
    gap: 12px;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sidebar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

.mobile-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ========== Sidebar ========== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 200;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    font-size: 1.4rem;
}

.logo-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Search */
.search-box {
    padding: 12px 16px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-bg);
}

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

.search-results {
    position: absolute;
    top: 100%;
    left: 16px;
    right: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 10;
    box-shadow: var(--shadow);
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.search-result-item:last-child {
    border-bottom: none;
}

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

.search-result-item .result-topic {
    font-size: 0.7rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-result-item .result-title {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-top: 2px;
}

.search-result-item .result-snippet {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Progress */
.progress-card {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.progress-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

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

/* Navigation */
.nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.nav::-webkit-scrollbar {
    width: 4px;
}

.nav::-webkit-scrollbar-track {
    background: transparent;
}

.nav::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 2px;
}

.nav-empty {
    padding: 20px 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

.nav-topic {
    margin-bottom: 4px;
}

.nav-topic-header {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--transition);
    gap: 8px;
    user-select: none;
}

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

.nav-topic-header .arrow {
    font-size: 0.6rem;
    transition: transform var(--transition);
}

.nav-topic-header.expanded .arrow {
    transform: rotate(90deg);
}

.nav-topic-header .topic-count {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.nav-lessons {
    display: none;
    padding-bottom: 4px;
}

.nav-lessons.expanded {
    display: block;
}

.nav-lesson {
    display: flex;
    align-items: center;
    padding: 6px 16px 6px 36px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: var(--transition);
    gap: 8px;
    border-left: 2px solid transparent;
}

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

.nav-lesson.active {
    color: var(--accent);
    background: var(--accent-bg);
    border-left-color: var(--accent);
}

.nav-lesson .lesson-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.nav-lesson.active .lesson-dot {
    background: var(--accent);
}

.nav-lesson.completed .lesson-dot {
    background: var(--green);
}

.nav-summary {
    display: flex;
    align-items: center;
    padding: 6px 16px 6px 36px;
    cursor: pointer;
    color: var(--purple);
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    gap: 8px;
    border-left: 2px solid transparent;
}

.nav-summary:hover {
    background: var(--purple-bg);
}

.nav-summary.active {
    background: var(--purple-bg);
    border-left-color: var(--purple);
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
}

/* ========== Main Content ========== */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    height: 100vh;
}

.content::-webkit-scrollbar {
    width: 6px;
}

.content::-webkit-scrollbar-track {
    background: transparent;
}

.content::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

/* Welcome */
.welcome {
    max-width: 600px;
    margin: 80px auto 0;
    text-align: center;
}

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

.welcome h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.welcome > p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.welcome-stats {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 100px;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.welcome-hint {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    text-align: left;
}

.welcome-hint p {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-hint ol {
    padding-left: 20px;
    color: var(--text-secondary);
}

.welcome-hint ol li {
    margin-bottom: 6px;
    font-size: 0.9rem;
}

/* ========== Lesson Page ========== */
.lesson-page {
    max-width: 800px;
    margin: 0 auto;
}

.lesson-breadcrumb {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

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

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

.lesson-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.lesson-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
}

.lesson-section {
    margin-bottom: 32px;
}

.lesson-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.lesson-screenshot {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.lesson-screenshot:hover {
    border-color: var(--accent);
}

.lesson-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.8;
}

.lesson-text p {
    margin-bottom: 12px;
}

.lesson-text code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.85em;
    color: var(--accent);
}

.lesson-text pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 12px;
}

.lesson-text pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.6;
}

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

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

/* Key Takeaways */
.takeaways-box {
    background: var(--green-bg);
    border: 1px solid rgba(63, 185, 80, 0.3);
    border-radius: var(--radius);
    padding: 20px;
}

.takeaways-box h4 {
    color: var(--green);
    font-size: 0.9rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.takeaways-box ul {
    list-style: none;
    padding: 0;
}

.takeaways-box ul li {
    padding: 6px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding-left: 20px;
    position: relative;
}

.takeaways-box ul li::before {
    content: "\2713";
    position: absolute;
    left: 0;
    color: var(--green);
    font-weight: 700;
}

/* Laravel Analogy Box */
.analogy-box {
    background: var(--yellow-bg);
    border: 1px solid rgba(210, 153, 34, 0.3);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
}

.analogy-box h4 {
    color: var(--yellow);
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.analogy-box p {
    color: var(--text-secondary);
    font-size: 0.88rem;
}

/* ========== Summary Page ========== */
.summary-page {
    max-width: 800px;
    margin: 0 auto;
}

.summary-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--purple);
}

.summary-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 32px;
}

.summary-section {
    margin-bottom: 32px;
}

.summary-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.summary-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.8;
}

/* Cheatsheet */
.cheatsheet {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.cheatsheet-item {
    display: flex;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
    gap: 16px;
}

.cheatsheet-item:last-child {
    border-bottom: none;
}

.cheatsheet-cmd {
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--accent);
    min-width: 200px;
    flex-shrink: 0;
}

.cheatsheet-desc {
    color: var(--text-secondary);
}

/* Comparison Table */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.88rem;
}

.comparison-table th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

.comparison-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

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

/* Quiz */
.quiz-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.quiz-question {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.quiz-question h4 {
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 12px;
}

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

.quiz-option {
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.88rem;
    transition: var(--transition);
}

.quiz-option:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

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

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

.quiz-explanation {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: none;
}

.quiz-explanation.show {
    display: block;
}

/* Common Mistakes */
.mistakes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mistake-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.mistake-item .mistake-bad {
    color: var(--red);
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.mistake-item .mistake-good {
    color: var(--green);
    font-size: 0.85rem;
}

/* ========== Screenshot Lightbox ========== */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ========== Sidebar Overlay (mobile) ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
}

/* ========== Lab Page ========== */
.lab-page {
    max-width: 800px;
    margin: 0 auto;
}

.lab-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #f0883e;
}

.lab-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 32px;
}

.lab-task {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.lab-task-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.lab-task-number {
    background: #f0883e;
    color: #000;
    font-weight: 700;
    font-size: 0.75rem;
    min-width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.lab-task-desc {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.lab-task-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.lab-btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.lab-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.lab-btn.hint-btn {
    border-color: var(--yellow);
    color: var(--yellow);
}

.lab-btn.hint-btn:hover {
    background: var(--yellow-bg);
}

.lab-btn.solution-btn {
    border-color: var(--green);
    color: var(--green);
}

.lab-btn.solution-btn:hover {
    background: var(--green-bg);
}

.lab-hint, .lab-solution {
    display: none;
    margin-top: 12px;
    padding: 14px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    line-height: 1.7;
}

.lab-hint.show {
    display: block;
    background: var(--yellow-bg);
    border: 1px solid rgba(210, 153, 34, 0.3);
    color: var(--text-secondary);
}

.lab-solution.show {
    display: block;
    background: var(--green-bg);
    border: 1px solid rgba(63, 185, 80, 0.3);
    color: var(--text-secondary);
}

.lab-hint pre, .lab-solution pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    overflow-x: auto;
    margin: 8px 0;
}

.lab-hint code, .lab-solution code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    color: var(--accent);
}

/* Nav Lab Link */
.nav-lab {
    display: flex;
    align-items: center;
    padding: 6px 16px 6px 36px;
    cursor: pointer;
    color: #f0883e;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
    gap: 8px;
    border-left: 2px solid transparent;
    text-decoration: none;
}

.nav-lab:hover {
    background: rgba(240, 136, 62, 0.1);
}

.nav-lab.active {
    background: rgba(240, 136, 62, 0.1);
    border-left-color: #f0883e;
}

/* Topic Card on Home Page */
.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.topic-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.topic-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.topic-card-stage {
    font-size: 0.7rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.topic-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.topic-card-lessons {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.topic-card-status {
    margin-top: 12px;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    display: inline-block;
}

.topic-card-status.not-started {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.topic-card-status.in-progress {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.topic-card-status.completed {
    background: var(--green-bg);
    color: var(--green);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

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

    .content {
        padding: 16px;
        padding-top: calc(var(--header-height) + 16px);
    }

    .welcome {
        margin-top: 20px;
    }

    .welcome-stats {
        flex-direction: column;
        align-items: center;
    }

    .stat-card {
        width: 100%;
        max-width: 200px;
    }

    .lesson-title, .summary-title {
        font-size: 1.3rem;
    }

    .cheatsheet-item {
        flex-direction: column;
        gap: 4px;
    }

    .cheatsheet-cmd {
        min-width: auto;
    }
}
