/* ==========================================================================
   REDIS INTERACTIVE LEARNING PLATFORM - DESIGN SYSTEM & STYLES
   Author: Antigravity Team
   Theme: Redis Red & Sleek Dark Glassmorphism
   ========================================================================== */

:root {
    --redis-red: #dc382d;
    --redis-red-hover: #ef4444;
    --redis-dark-red: #991b1b;
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: #1f2937;
    --bg-card-hover: #374151;
    --border-color: #374151;
    --border-highlight: #dc382d;
    
    --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: 320px;
    --header-height: 70px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(220, 56, 45, 0.15);
}

/* 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(--redis-red);
}

/* Header Component */
.app-header {
    height: var(--header-height);
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(12px);
    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(--redis-red) 0%, #b91c1c 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(220, 56, 45, 0.4);
}

.brand-icon svg {
    width: 24px;
    height: 24px;
    color: #ffffff;
}

.brand-text h1 {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #ffffff, #fca5a5);
    -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: 450px;
    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(--redis-red);
    box-shadow: 0 0 0 3px rgba(220, 56, 45, 0.2);
}

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

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

.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(--redis-red) 0%, var(--accent-amber) 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(--redis-red) 0%, #b91c1c 100%);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(220, 56, 45, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ef4444 0%, var(--redis-red) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(220, 56, 45, 0.4);
}

.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-red { background: rgba(220, 56, 45, 0.18); color: #fca5a5; border: 1px solid rgba(220, 56, 45, 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(--redis-red);
    color: #ffffff;
    border-color: var(--redis-red);
}

.sidebar-exam-btn {
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #000000;
    font-weight: 800;
    font-size: 0.82rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.sidebar-exam-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
}

/* 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(--redis-red);
    transform: translateX(3px);
    background: var(--bg-card-hover);
}

.chapter-card.active {
    border-color: var(--redis-red);
    background: rgba(220, 56, 45, 0.08);
    box-shadow: inset 3px 0 0 var(--redis-red);
}

.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(--redis-red);
}

.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(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
}

/* 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.9) 0%, rgba(17, 24, 39, 0.95) 100%);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--redis-red);
    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(--redis-red);
    border-bottom-color: var(--redis-red);
}

/* 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: 700;
    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: 600;
    color: #fca5a5;
    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(--accent-emerald); color: #d1e7dd; }
.callout-warning { background: rgba(245, 158, 11, 0.1); border-color: var(--accent-amber); color: #fff3cd; }
.callout-danger { background: rgba(220, 56, 45, 0.1); border-color: var(--redis-red); color: #f8d7da; }

/* 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(--redis-red);
}

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(220, 56, 45, 0.15);
    color: #fca5a5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    border: 1px solid rgba(220, 56, 45, 0.2);
}

/* 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 & Interactive CLI Terminal */
.playground-container {
    display: grid;
    grid-template-columns: 1fr;
    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: #67e8f9;
    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(--redis-red);
    background: rgba(220, 56, 45, 0.15);
    color: #ffffff;
}

/* Redis Terminal Window */
.terminal-window {
    background: #05070c;
    border: 1px solid #1e293b;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 380px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

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

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

.term-cmd { color: #38bdf8; font-weight: 600; }
.term-reply-ok { color: #4ade80; font-weight: 600; }
.term-reply-val { color: #fef08a; }
.term-reply-nil { color: #94a3b8; font-style: italic; }
.term-reply-err { color: #f87171; font-weight: 600; }
.term-info { color: #a7f3d0; }

.terminal-input-row {
    display: flex;
    align-items: center;
    background: #0f172a;
    padding: 8px 12px;
    border-top: 1px solid #1e293b;
    gap: 8px;
}

.terminal-prompt {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--redis-red);
    font-weight: 700;
    white-space: nowrap;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #ffffff;
    font-family: var(--font-mono);
    font-size: 0.88rem;
}

.terminal-input:focus {
    outline: none;
}

/* 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: 12px;
}

.quiz-question {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

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

.quiz-option-label:hover {
    border-color: var(--redis-red);
    background: var(--bg-card-hover);
}

.quiz-option-label input[type="radio"] {
    accent-color: var(--redis-red);
    width: 16px;
    height: 16px;
}

.quiz-feedback {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    display: none;
}

.quiz-feedback.correct {
    display: block;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--accent-emerald);
    color: #6ee7b7;
}

.quiz-feedback.incorrect {
    display: block;
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid var(--error-color);
    color: #fca5a5;
}

/* Notes Textarea */
.notes-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.notes-textarea {
    width: 100%;
    min-height: 220px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.92rem;
    resize: vertical;
}

.notes-textarea:focus {
    outline: none;
    border-color: var(--redis-red);
}

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

/* Modal Overlay & Exam Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    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);
    width: 100%;
    max-width: 750px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

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

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

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--redis-red);
    color: #ffffff;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 0.88rem;
    font-weight: 600;
    z-index: 2000;
    animation: slideUp 0.3s ease;
}

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

/* Responsive Styles */
@media (max-width: 992px) {
    .app-container { flex-direction: column; }
    .app-sidebar { width: 100%; height: auto; position: relative; top: 0; }
    .header-center { display: none; }
}
