/* ==========================================================================
   FASTAPI INTERACTIVE LEARNING PLATFORM - DESIGN SYSTEM & STYLES
   Author: Antigravity Team
   Theme: FastAPI Emerald Teal & Sleek Dark Glassmorphism
   ========================================================================== */

:root {
    --fastapi-teal: #059669;
    --fastapi-emerald: #10b981;
    --fastapi-dark-teal: #047857;
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: #1f2937;
    --bg-card-hover: #374151;
    --border-color: #374151;
    --border-highlight: #10b981;
    
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-purple: #8b5cf6;
    --accent-amber: #f59e0b;
    --success-color: #10b981;
    --error-color: #f43f5e;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;
    
    --sidebar-width: 330px;
    --header-height: 70px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 30px rgba(16, 185, 129, 0.2);
}

/* Reset & Global Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--fastapi-emerald);
}

/* Header Component */
.app-header {
    height: var(--header-height);
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--fastapi-dark-teal) 0%, var(--fastapi-emerald) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.35);
}

.brand-icon svg {
    width: 26px;
    height: 26px;
}

.brand-text h1 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #ffffff, #a7f3d0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
}

.header-center {
    flex: 1;
    max-width: 480px;
    margin: 0 24px;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 9px 12px 9px 36px;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: var(--font-sans);
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--fastapi-emerald);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.progress-widget {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 170px;
}

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

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--fastapi-dark-teal) 0%, var(--fastapi-emerald) 100%);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    font-family: var(--font-sans);
}

.btn-primary {
    background: linear-gradient(135deg, var(--fastapi-dark-teal) 0%, var(--fastapi-teal) 100%);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--fastapi-emerald) 0%, var(--fastapi-dark-teal) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-secondary);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-teal { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-cyan { background: rgba(6, 182, 212, 0.18); color: #67e8f9; border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-purple { background: rgba(139, 92, 246, 0.18); color: #c4b5fd; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-amber { background: rgba(245, 158, 11, 0.18); color: #fde047; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-emerald { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.3); }

/* Main App Layout */
.app-container {
    display: flex;
    min-height: calc(100vh - var(--header-height));
}

/* Sidebar Styling */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 14px;
    height: calc(100vh - var(--header-height));
    position: sticky;
    top: var(--header-height);
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.category-filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.category-pill {
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.74rem;
    font-weight: 600;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-pill:hover, .category-pill.active {
    background: var(--fastapi-dark-teal);
    color: #ffffff;
    border-color: var(--fastapi-emerald);
}

.sidebar-exam-btn {
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--fastapi-teal) 0%, #065f46 100%);
    color: #ffffff;
    font-weight: 800;
    font-size: 0.82rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}

.sidebar-exam-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
}

/* Chapter List Cards */
#chapterListContainer {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chapter-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.chapter-card:hover {
    border-color: var(--fastapi-emerald);
    transform: translateX(3px);
    background: var(--bg-card-hover);
}

.chapter-card.active {
    border-color: var(--fastapi-emerald);
    background: rgba(16, 185, 129, 0.08);
    box-shadow: inset 3px 0 0 var(--fastapi-emerald);
}

.chapter-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chapter-card-num {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--fastapi-emerald);
}

.chapter-card-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.chapter-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.completed {
    background: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

/* Chapter Header Banner */
.chapter-header {
    background: linear-gradient(135deg, rgba(31, 41, 55, 0.95) 0%, rgba(17, 24, 39, 0.98) 100%);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--fastapi-emerald);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-md);
}

.chapter-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.video-timestamp {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.chapter-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.3;
    color: var(--text-primary);
}

.chapter-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

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

/* Tabs Navigation */
.tabs-nav {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 2px;
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--fastapi-emerald);
    border-bottom-color: var(--fastapi-emerald);
}

/* Tab Panels */
.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Article & Theory Content Styling */
.article-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    line-height: 1.7;
    font-size: 0.96rem;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.article-content h3 {
    font-size: 1.25rem;
    font-weight: 800;
    color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.article-content h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--fastapi-emerald);
    margin-top: 8px;
}

.article-content p {
    color: #d1d5db;
}

.article-content ul, .article-content ol {
    padding-left: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #d1d5db;
}

.article-content li strong {
    color: #ffffff;
}

/* Callout Box / Alert Box */
.callout {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    border-left: 4px solid;
    margin: 8px 0;
    font-size: 0.92rem;
}

.callout-info { background: rgba(6, 182, 212, 0.1); border-color: var(--accent-cyan); color: #cff4fc; }
.callout-tip { background: rgba(16, 185, 129, 0.1); border-color: var(--fastapi-emerald); color: #a7f3d0; }
.callout-warning { background: rgba(245, 158, 11, 0.1); border-color: var(--accent-amber); color: #fde68a; }
.callout-danger { background: rgba(244, 63, 94, 0.1); border-color: var(--error-color); color: #fca5a5; }

/* Code Blocks & Command Snippets */
.code-container {
    position: relative;
    background: #090d16;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: 12px 0;
    overflow: hidden;
}

.code-header {
    background: #111827;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--fastapi-emerald);
}

pre {
    padding: 16px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: #e2e8f0;
    line-height: 1.5;
}

code {
    font-family: var(--font-mono);
}

p code, li code {
    background: rgba(16, 185, 129, 0.15);
    color: #a7f3d0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

/* Video Player Container */
.video-player-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    background: #000000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.video-player-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.video-meta-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 16px;
}

/* Playground & FastAPI Simulator */
.playground-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.playground-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.playground-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.snippet-buttons-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-snippet {
    background: #111827;
    border: 1px solid var(--border-color);
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-snippet:hover {
    border-color: var(--fastapi-emerald);
    background: rgba(16, 185, 129, 0.15);
    color: #ffffff;
}

.editor-textarea {
    width: 100%;
    height: 280px;
    background: #05070c;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    color: #f3f4f6;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.5;
    resize: vertical;
}

.editor-textarea:focus {
    outline: none;
    border-color: var(--fastapi-emerald);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* FastAPI Output Split View */
.fastapi-preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 900px) {
    .fastapi-preview-grid {
        grid-template-columns: 1fr;
    }
}

.preview-box {
    background: #05070c;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 320px;
}

.box-header {
    background: #111827;
    padding: 8px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 6px;
}

.rendered-preview-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    font-size: 0.88rem;
    font-family: var(--font-mono);
    color: #e5e7eb;
}

.terminal-body {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.84rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #05070c;
}

.term-line {
    word-break: break-all;
    line-height: 1.4;
}

.term-info { color: #38bdf8; }
.term-success { color: #4ade80; font-weight: 600; }
.term-warn { color: #fbbf24; }
.term-error { color: #f87171; font-weight: 600; }

/* Quiz Section */
.quiz-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.quiz-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.quiz-question {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
}

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

.quiz-option {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.quiz-option:hover {
    border-color: var(--fastapi-emerald);
    background: var(--bg-card-hover);
}

.quiz-option.selected {
    border-color: var(--fastapi-emerald);
    background: rgba(16, 185, 129, 0.15);
}

.quiz-option.correct {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.15);
    color: #ffffff;
}

.quiz-option.incorrect {
    border-color: var(--error-color);
    background: rgba(244, 63, 94, 0.15);
    color: #ffffff;
}

.quiz-explanation {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid var(--fastapi-emerald);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    color: #d1d5db;
    display: none;
}

/* Notes Container */
.notes-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notes-textarea {
    width: 100%;
    height: 220px;
    background: #05070c;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.92rem;
    line-height: 1.5;
    resize: vertical;
}

.notes-textarea:focus {
    outline: none;
    border-color: var(--fastapi-emerald);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Footer Navigation */
.footer-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}

.modal-close:hover {
    color: #ffffff;
}

/* Responsive Adjustments */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    .app-sidebar {
        width: 100%;
        height: auto;
        position: static;
    }
    .header-center {
        display: none;
    }
}
