/* ═══════════════════════════════════════════════════════════════
   CSS Variables & Reset (Phase 1)
═══════════════════════════════════════════════════════════════ */
:root {
    /* Color Palette - Dark Theme Default */
    --bg-main: #0f172a;        /* Slate 900 */
    --bg-surface: #1e293b;     /* Slate 800 */
    --bg-surface-hover: #334155; /* Slate 700 */
    
    --text-main: #f8fafc;      /* Slate 50 */
    --text-muted: #94a3b8;     /* Slate 400 */
    
    --primary: #3b82f6;        /* Blue 500 */
    --primary-hover: #2563eb;  /* Blue 600 */
    --accent: #8b5cf6;         /* Violet 500 */
    --success: #10b981;        /* Emerald 500 */
    
    --border: #334155;
    --border-light: rgba(255, 255, 255, 0.1);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    
    /* Layout Dimensions */
    --sidebar-width: 320px;
    --header-height: 70px;
    --content-max-width: 900px;
    
    /* Transitions */
    --trans-fast: 0.2s ease;
    --trans-normal: 0.3s ease;
    --trans-theme: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
    
    /* Typography System (Phase 1, Step 4) */
    --font-fa: 'Vazirmatn', system-ui, -apple-system, sans-serif;
    --font-en: 'Inter', system-ui, -apple-system, sans-serif;
    --font-code: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="light"] {
    /* Color Palette - Light Theme */
    --bg-main: #f8fafc;        /* Slate 50 */
    --bg-surface: #ffffff;     /* White */
    --bg-surface-hover: #f1f5f9; /* Slate 100 */
    
    --text-main: #0f172a;      /* Slate 900 */
    --text-muted: #475569;     /* Slate 600 */
    
    --primary: #3b82f6;        /* Blue 500 */
    --primary-hover: #2563eb;  /* Blue 600 */
    --accent: #8b5cf6;         /* Violet 500 */
    --success: #059669;        /* Emerald 600 */
    
    --border: #e2e8f0;         /* Slate 200 */
    --border-light: rgba(0, 0, 0, 0.05);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: var(--font-fa); /* Base font is Persian */
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: var(--trans-theme);
    font-size: 16px;
}

/* ═══════════════════════════════════════════════════════════════
   Global Typography Styles
═══════════════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-main);
}

p {
    margin-bottom: 1.2rem;
    color: var(--text-main);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--trans-fast);
}

a:hover {
    color: var(--primary-hover);
}

/* English/LTR content wrappers */
.en-text {
    font-family: var(--font-en);
    direction: ltr;
    display: inline-block;
}

/* Code Typography */
code {
    font-family: var(--font-code);
    background-color: var(--bg-main);
    color: #e2e8f0; /* Default code color, will be enhanced in phase 2 */
    padding: 0.2em 0.4em;
    border-radius: 6px;
    font-size: 0.85em;
    border: 1px solid var(--border);
    direction: ltr;
    display: inline-block;
}

[data-theme="light"] code {
    color: #0f172a;
    background-color: #f1f5f9;
}

/* ═══════════════════════════════════════════════════════════════
   Main Layout Structure
═══════════════════════════════════════════════════════════════ */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden; /* Prevent body scroll */
}

/* ═══════════════════════════════════════════════════════════════
   Sidebar
═══════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all var(--trans-normal), var(--trans-theme);
    z-index: 50;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    transition: var(--trans-theme);
}

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





.sidebar-search {
    padding: 20px;
}

.sidebar-search input {
    width: 100%;
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 8px;
    font-family: var(--font-fa);
    font-size: 0.95rem;
    transition: border-color var(--trans-fast), var(--trans-theme);
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
}

/* Custom Scrollbar for sidebar */
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.nav-section {
    margin-bottom: 24px;
}

.nav-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0px;
    margin-bottom: 12px;
    font-weight: 700;
}

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

.sidebar-nav li {
    margin-bottom: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: all var(--trans-fast);
}

.sidebar-nav a:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-main);
}

.sidebar-nav li.active a {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    font-weight: 500;
}

.nav-icon {
    margin-left: 10px;
    font-size: 1.1rem;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    background-color: var(--border-light);
    transition: var(--trans-theme);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.progress-bar {
    height: 6px;
    background-color: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary);
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ═══════════════════════════════════════════════════════════════
   Main Wrapper & Header
═══════════════════════════════════════════════════════════════ */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Important for flex child truncation */
}

.topbar {
    height: var(--header-height);
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 40;
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

[data-theme="light"] .topbar {
    background-color: rgba(255, 255, 255, 0.8);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none; /* Hidden on desktop */
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
}

.breadcrumbs {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.crumb.current {
    color: var(--primary);
    font-weight: 500;
}

.topbar-actions {
    display: flex;
    gap: 12px;
}

.icon-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all var(--trans-fast);
}

.icon-btn:hover {
    background: var(--bg-surface-hover);
    border-color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════
   Content Area
═══════════════════════════════════════════════════════════════ */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 40px 30px;
    scroll-behavior: smooth;
}

.content-container {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.chapter-badge {
    display: inline-block;
    background-color: rgba(139, 92, 246, 0.15);
    color: var(--accent);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 16px;
    color: var(--text-main);
}

.page-description {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 40px;
    line-height: 1.8;
}

.lesson-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-sm);
    transition: var(--trans-theme);
}

.lesson-card h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
    color: var(--primary);
}

code {
    background-color: var(--bg-main);
    color: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    border: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   Educational Alert Boxes (Phase 2, Step 10)
═══════════════════════════════════════════════════════════════ */
.edu-box {
    display: flex;
    gap: 16px;
    padding: 20px;
    border-radius: 10px;
    margin: 24px 0;
    line-height: 1.7;
    position: relative;
    overflow: hidden;
    transition: var(--trans-theme);
}

.edu-box::before {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 4px;
}

.edu-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
    line-height: 1;
}

.edu-content {
    flex: 1;
}

.edu-title {
    display: block;
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 6px;
}

/* 1. Pro Tip (Blue/Violet) */
.edu-pro {
    background-color: rgba(59, 130, 246, 0.08);
}
.edu-pro::before { background-color: var(--primary); }
.edu-pro .edu-title { color: var(--primary); }
[data-theme="dark"] .edu-pro .edu-title { color: #60a5fa; } /* Lighter blue in dark mode */

/* 2. Warning / Important (Orange/Yellow) */
.edu-warn {
    background-color: rgba(245, 158, 11, 0.08);
}
.edu-warn::before { background-color: #f59e0b; }
.edu-warn .edu-title { color: #d97706; }
[data-theme="dark"] .edu-warn .edu-title { color: #fbbf24; }

/* 3. Note / Info (Teal/Emerald) */
.edu-info {
    background-color: rgba(16, 185, 129, 0.08);
}
.edu-info::before { background-color: var(--success); }
.edu-info .edu-title { color: var(--success); }
[data-theme="dark"] .edu-info .edu-title { color: #34d399; }

/* 4. Danger / Do Not Do This (Red/Rose) */
.edu-danger {
    background-color: rgba(225, 29, 72, 0.08);
}
.edu-danger::before { background-color: #e11d48; }
.edu-danger .edu-title { color: #be123c; }
[data-theme="dark"] .edu-danger .edu-title { color: #fb7185; }

/* Deprecate old pro-tip to use new system */
.pro-tip { display: none; }

.btn-nav {
    font-family: var(--font-fa);
    font-size: 0.95rem;
    font-weight: 500;
}

.btn-nav:hover {
    filter: brightness(1.1);
}

/* ═══════════════════════════════════════════════════════════════
   Animations
═══════════════════════════════════════════════════════════════ */
.fade-enter {
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* ═══════════════════════════════════════════════════════════════
   Live Code Editor (Phase 2, Step 6)
═══════════════════════════════════════════════════════════════ */
.live-editor {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin: 32px 0;
    box-shadow: var(--shadow-md);
    background: var(--bg-main);
    transition: var(--trans-theme);
}

.le-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    direction: ltr; /* Keep mac dots on left */
    transition: var(--trans-theme);
}

.le-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-en);
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.mac-dots { 
    display: flex; 
    gap: 8px; 
}
.mac-dot { 
    width: 12px; 
    height: 12px; 
    border-radius: 50%; 
}
.mac-dot.red { background: #ff5f56; }
.mac-dot.yellow { background: #ffbd2e; }
.mac-dot.green { background: #27c93f; }

.le-actions { 
    direction: rtl; 
    display: flex;
    gap: 8px;
}
.le-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: var(--font-fa);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--trans-fast);
}
.le-btn:hover { 
    background: var(--bg-surface-hover); 
    border-color: var(--text-muted);
}
.le-btn:active {
    transform: scale(0.95);
}
.le-btn.primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.le-btn.primary:hover {
    background: var(--primary-hover);
}
.btn-icon {
    font-size: 1rem;
    line-height: 1;
}

.le-body {
    display: flex;
    flex-direction: column;
    min-height: 350px;
}

@media (min-width: 768px) {
    .le-body { 
        flex-direction: row; 
        height: 400px; 
    }
}

.le-code, .le-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.le-code { 
    border-bottom: 1px solid var(--border); 
    display: flex;
    flex-direction: column;
}
@media (min-width: 768px) {
    .le-code { 
        border-bottom: none; 
        border-right: 1px solid var(--border); /* RTL layout */
    }
}

.le-code-wrapper {
    position: relative;
    flex: 1;
    background: #0d1117; /* Hacker Dark Feel */
    overflow: hidden;
}

.le-textarea, .le-highlight {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    padding: 20px;
    margin: 0;
    font-family: var(--font-code);
    font-size: 0.95rem;
    line-height: 1.6;
    tab-size: 4;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
    overflow-y: auto;
    direction: ltr;
    border: none;
}

.le-textarea {
    color: transparent;
    background: transparent;
    caret-color: #f8fafc;
    z-index: 2;
    outline: none;
    resize: none;
}

.le-textarea::selection {
    background: rgba(121, 192, 255, 0.25);
    color: transparent;
}

.le-code-wrapper:focus-within {
    box-shadow: inset 0 0 0 2px var(--primary);
}

.le-highlight {
    color: #c9d1d9; /* Default text color */
    z-index: 1;
    pointer-events: none;
}

/* Syntax Highlighting Colors */
.hl-punct { color: #8b949e; }
.hl-tag { color: #7ee787; }
.hl-attr { color: #79c0ff; }
.hl-string { color: #a5d6ff; }
.hl-comment { color: #8b949e; font-style: italic; }

.le-iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff; /* Iframe always white to match standard web */
}

/* Progress & Completion System */
.btn-complete {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 10px 24px;
    border-radius: 8px;
    font-family: var(--font-fa);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--trans-fast);
}
.btn-complete:hover {
    border-color: var(--success);
    color: var(--success);
}
.btn-complete.is-completed {
    background: rgba(5, 150, 105, 0.1);
    border-color: var(--success);
    color: var(--success);
}
.btn-complete:active {
    transform: scale(0.96);
}

.sidebar-nav li.is-completed a {
    color: var(--success);
}
.sidebar-nav li.is-completed a::after {
    content: '✓';
    margin-right: auto; /* Pushes to left in RTL */
    font-weight: bold;
    font-size: 1.1em;
}

/* ═══════════════════════════════════════════════════════════════
   Quiz System (Phase 3, Step 20)
═══════════════════════════════════════════════════════════════ */
.quiz-container {
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 30px;
    margin: 40px 0;
    box-shadow: var(--shadow-md);
    transition: var(--trans-theme);
}

.quiz-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px dashed var(--border);
}

.quiz-icon {
    font-size: 2rem;
}

.quiz-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.quiz-question {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.6;
}

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

.quiz-option {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background-color: var(--bg-main);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--trans-fast);
    font-weight: 500;
}

.quiz-option:hover:not(.answered) {
    border-color: var(--primary);
    background-color: rgba(59, 130, 246, 0.05);
    transform: translateX(-4px); /* RTL move left */
}

/* Radio button styling */
.quiz-radio {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    margin-left: 16px; /* RTL margin */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all var(--trans-fast);
}

.quiz-option:hover:not(.answered) .quiz-radio {
    border-color: var(--primary);
}

.quiz-radio::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--primary);
    transform: scale(0);
    transition: transform var(--trans-fast);
}

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

.quiz-option.selected .quiz-radio::after {
    transform: scale(1);
}

/* Answer States */
.quiz-option.correct {
    border-color: var(--success);
    background-color: rgba(16, 185, 129, 0.1);
}
.quiz-option.correct .quiz-radio {
    border-color: var(--success);
}
.quiz-option.correct .quiz-radio::after {
    background-color: var(--success);
    transform: scale(1);
}

.quiz-option.wrong {
    border-color: #e11d48;
    background-color: rgba(225, 29, 72, 0.1);
}
.quiz-option.wrong .quiz-radio {
    border-color: #e11d48;
}
.quiz-option.wrong .quiz-radio::after {
    background-color: #e11d48;
    transform: scale(1);
}

.quiz-feedback {
    margin-top: 20px;
    padding: 16px;
    border-radius: 8px;
    display: none;
    font-weight: 500;
    line-height: 1.6;
    animation: fadeIn 0.4s ease;
}

.quiz-feedback.success {
    display: block;
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-right: 4px solid var(--success);
}
[data-theme="dark"] .quiz-feedback.success { color: #34d399; }

.quiz-feedback.error {
    display: block;
    background-color: rgba(225, 29, 72, 0.1);
    color: #be123c;
    border-right: 4px solid #e11d48;
}
[data-theme="dark"] .quiz-feedback.error { color: #fb7185; }

.quiz-submit-wrapper {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
}

.btn-quiz-submit {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--trans-fast);
    opacity: 0.5;
    pointer-events: none; /* Disabled until selection */
}

.btn-quiz-submit.active {
    opacity: 1;
    pointer-events: auto;
}
.btn-quiz-submit.active:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}
.btn-quiz-submit.active:active {
    transform: translateY(0);
}
/* ═══════════════════════════════════════════════════════════════
   Search & Bookmarks (Phase 6)
═══════════════════════════════════════════════════════════════ */
/* Search System */
.search-modal {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    width: 90%;
    max-width: 600px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.search-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.search-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.search-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.search-input-wrapper {
    position: relative;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.search-input-wrapper input {
    width: 100%;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: var(--text-main);
    font-family: var(--font-fa);
    outline: none;
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.search-item {
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--trans-fast);
}

.search-item:hover, .search-item.selected {
    background: rgba(59, 130, 246, 0.1);
}

.search-item-badge {
    font-size: 0.75rem;
    background: var(--border);
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
}

.search-item-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.search-item-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.search-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

/* Shortcut Hint */
.shortcut-hint {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-main);
    border: 1px solid var(--border);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-en);
    pointer-events: none;
}

/* Bookmarks Sidebar Panel */
.bookmarks-panel {
    position: fixed;
    left: -320px; /* Hidden off-screen left */
    transition: left var(--trans-normal);
    top: 0;
    bottom: 0;
    width: 320px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    z-index: 60;
    transition: all var(--trans-normal);
    display: flex;
    flex-direction: column;
    box-shadow: 5px 0 25px rgba(0,0,0,0.5);
}

.bookmarks-panel.open {
    left: 0;
}

.bookmarks-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}

.bookmarks-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.bookmark-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 8px;
    cursor: pointer;
    transition: background var(--trans-fast);
}

.bookmark-item:hover {
    background: var(--bg-main);
    border-color: var(--accent);
}

.bookmark-remove {
    color: #e11d48;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   Cheat Sheet System (Phase 6, Step 44)
═══════════════════════════════════════════════════════════════ */
.cheat-sheet-btn {
    position: fixed;
    bottom: 30px;
    right: 30px; /* RTL right */
    background: var(--accent);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    box-shadow: 0 10px 15px -3px rgba(139, 92, 246, 0.4);
    cursor: pointer;
    z-index: 90;
    transition: all var(--trans-fast);
    border: none;
    outline: none;
}

.cheat-sheet-btn:hover {
    transform: translateY(-5px) scale(1.05);
    background: #7c3aed; /* darker violet */
    box-shadow: 0 20px 25px -5px rgba(139, 92, 246, 0.5);
}

.cheat-sheet-btn:active {
    transform: translateY(0) scale(0.95);
}

.cheat-sheet-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-main);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.cheat-sheet-modal.open {
    transform: translateY(0);
}

.cs-header {
    background: var(--bg-surface);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.cs-title {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
}

.cs-close {
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 40px; height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer;
    transition: all var(--trans-fast);
}

.cs-close:hover {
    background: #e11d48;
    color: white;
    border-color: #e11d48;
    transform: rotate(90deg);
}

.cs-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.cs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    max-width: 1400px;
    margin: 0 auto;
}

.cs-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.cs-card h3 {
    color: var(--primary);
    border-bottom: 2px dashed var(--border);
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.cs-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.cs-tag {
    font-family: var(--font-code);
    color: #7ee787;
    background: rgba(126, 231, 135, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    direction: ltr;
}

.cs-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
}


/* ═══════════════════════════════════════════════════════════════
   Overlays and Media Queries (Final)
═══════════════════════════════════════════════════════════════ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 45;
    opacity: 0;
    transition: opacity var(--trans-normal);
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        right: -320px; /* Hidden by default */
        top: 0;
        bottom: 0;
        transition: right var(--trans-normal);
    }

    .sidebar.open {
        right: 0;
        box-shadow: -5px 0 25px rgba(0,0,0,0.5);
    }

    .menu-toggle {
        display: block;
    }

    

    .topbar {
        padding: 0 20px;
    }
    
    .content-area {
        padding: 30px 20px;
    }

    .cs-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .le-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .le-actions {
        width: 100%;
        justify-content: center;
    }

    .page-title {
        font-size: 2.1rem;
    }
}

@media (max-width: 576px) {
    .page-title {
        font-size: 1.8rem;
    }
    
    .page-description {
        font-size: 1.05rem;
    }

    .breadcrumbs {
        display: none;
    }

    .lesson-card {
        padding: 20px;
    }

    .edu-box {
        flex-direction: column;
        gap: 10px;
    }

    .bookmarks-panel {
        width: 100%;
        left: -100%; 
    }
    
    .bookmarks-panel.open {
        left: 0; 
    }

    .cheat-sheet-btn {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
        bottom: 20px;
        right: 20px;
    }
}

/* Print Styles */
@media print {
    body * { visibility: hidden !important; }
    #certificateNode, #certificateNode * { visibility: visible !important; }
    #certificateNode { position: fixed; left: 0; top: 0; width: 100%; height: 100%; margin: 0; padding: 40px; box-shadow: none; border: none; }
    .cert-border { border-color: #000; }
    .cert-name { color: #000; }
}

/* Polishing */
.le-iframe {
    border-radius: 0 0 12px 12px;
}
@media (min-width: 768px) {
    .le-iframe { border-radius: 0 0 0 12px; }
    .le-code-wrapper { border-radius: 0 0 12px 0; }
}

/* Close Btn Base Fix */




@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }


/* ═══════════════════════════════════════════════════════════════
   Desktop UX Fixes (Panels & Toggles)
═══════════════════════════════════════════════════════════════ */
/* Always show the close button for Bookmarks Panel */
#closeBookmarksBtn {
    display: flex !important;
}

/* Allow toggling main sidebar on desktop */
@media (min-width: 993px) {
    .menu-toggle {
        display: block !important;
    }
    .sidebar.desktop-closed {
        display: none !important;
    }
}

.btn-bookmark-chapter { background: transparent; color: var(--text-muted); border: 1px solid var(--border); padding: 8px 16px; border-radius: 8px; font-family: var(--font-fa); cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all var(--trans-fast); }
.btn-bookmark-chapter:hover { color: var(--accent); border-color: var(--accent); }
.btn-bookmark-chapter.is-bookmarked { background: rgba(236, 72, 153, 0.1); color: var(--accent); border-color: var(--accent); }

.close-btn {
    display: none;
    z-index: 2147483647;
    background: #e11d48 !important;
    border: none !important;
    color: white !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    font-size: 2rem !important;
    line-height: 1 !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2) !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
}
.close-btn:active {
    transform: scale(0.9) !important;
}
@media (max-width: 992px) {
    .close-btn {
        display: flex !important;
    }
}
@media (min-width: 993px) {
    .menu-toggle {
        display: block !important;
    }
    .sidebar.desktop-closed {
        display: none !important;
    }
}
