/* ===========================
   RESET & BASE
=========================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary:       #4f46e5;
    --primary-light: #6366f1;
    --primary-dark:  #3730a3;
    --accent:        #06b6d4;
    --success:       #10b981;
    --warning:       #f59e0b;
    --danger:        #ef4444;
    --bg:            #f1f5f9;
    --surface:       #ffffff;
    --surface2:      #f8fafc;
    --border:        #e2e8f0;
    --text:          #1e293b;
    --text-muted:    #64748b;
    --text-light:    #94a3b8;
    --sidebar-w:     300px;
    --header-h:      0px;
    --radius:        12px;
    --radius-sm:     8px;
    --shadow:        0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
    --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 10px 30px rgba(0,0,0,.1);
    --transition:    .25s ease;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.7;
    font-size: 15px;
}

/* ===========================
   LAYOUT
=========================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===========================
   SIDEBAR
=========================== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-left: 1px solid var(--border);
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 900;
    transition: transform var(--transition);
    box-shadow: var(--shadow-md);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    flex-shrink: 0;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.logo-text h1 { font-size: 18px; font-weight: 700; }
.logo-text p  { font-size: 12px; opacity: .8; margin-top: 2px; }

/* Progress */
.sidebar-progress {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.progress-track {
    height: 6px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 99px;
    transition: width .5s ease;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* Chapter header */
.nav-chapter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    cursor: pointer;
    transition: background var(--transition);
    user-select: none;
}

.nav-chapter-header:hover { background: var(--surface2); }

.nav-chapter-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chapter-badge {
    width: 28px;
    height: 28px;
    background: var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all var(--transition);
}

.nav-chapter.open .chapter-badge,
.nav-chapter.active .chapter-badge {
    background: var(--primary);
    color: white;
}

.chapter-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.chapter-arrow {
    font-size: 11px;
    color: var(--text-light);
    transition: transform var(--transition);
}

.nav-chapter.open .chapter-arrow { transform: rotate(-90deg); }

/* Sub items */
.nav-sub-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height .35s ease;
    background: var(--surface2);
}

.nav-chapter.open .nav-sub-list { max-height: 400px; }

.nav-sub-item {
    padding: 10px 20px 10px 20px;
    padding-right: 52px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition);
    border-right: 3px solid transparent;
}

.nav-sub-item i { font-size: 7px; color: var(--text-light); flex-shrink: 0; }

.nav-sub-item:hover {
    background: #ede9fe;
    color: var(--primary);
    border-right-color: var(--primary-light);
}

.nav-sub-item:hover i { color: var(--primary); }

.nav-sub-item.active {
    background: #ede9fe;
    color: var(--primary);
    font-weight: 600;
    border-right-color: var(--primary);
}

.nav-sub-item.active i { color: var(--primary); }

/* Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.instructor-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #f0f4ff, #faf5ff);
    border-radius: var(--radius-sm);
    border: 1px solid #e0e7ff;
}

.instructor-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.instructor-info {
    display: flex;
    flex-direction: column;
}

.instructor-title {
    font-size: 11px;
    color: var(--text-light);
}

.instructor-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-dark);
}

/* ===========================
   MAIN CONTENT
=========================== */
.main-content {
    flex: 1;
    margin-right: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-right var(--transition);
}

/* ===========================
   WELCOME SCREEN
=========================== */
.welcome-screen {
    padding: 48px 48px 64px;
}

.welcome-hero {
    text-align: center;
    padding: 64px 32px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border-radius: 20px;
    color: white;
    margin-bottom: 40px;
    position: relative;
    overflow: hidden;
}

.welcome-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,.05) 0%, transparent 60%);
}

.hero-icon {
    font-size: 72px;
    margin-bottom: 20px;
    opacity: .9;
}

.welcome-hero h1 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 12px;
}

.welcome-hero p {
    font-size: 16px;
    opacity: .85;
    margin-bottom: 32px;
}

.btn-start {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 36px;
    background: white;
    color: var(--primary);
    border: none;
    border-radius: 99px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 4px 20px rgba(0,0,0,.2);
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,.25);
}

/* Stats */
.course-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px 16px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.stat-card i {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-num {
    font-size: 28px;
    font-weight: 800;
	    color: var(--primary-dark);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Overview Grid */
.chapters-overview h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.overview-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow);
}

.overview-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.ov-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    flex-shrink: 0;
}

.ov-info { flex: 1; }
.ov-info h3 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.ov-info p  { font-size: 12px; color: var(--text-muted); }

.ov-arrow {
    color: var(--text-light);
    font-size: 14px;
    transition: transform var(--transition);
}

.overview-card:hover .ov-arrow { transform: translateX(-4px); }

/* ===========================
   CONTENT AREA
=========================== */
.content-area {
    padding: 40px 48px 64px;
}

.content-header {
    margin-bottom: 32px;padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.content-breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;display: flex;
    align-items: center;
    gap: 6px;
}

.content-breadcrumb i { font-size: 10px; }

.content-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
}

.content-subtitle {
    font-size: 15px;
    color: var(--text-muted);
}

/* ===========================
   CONCEPT BLOCKS
=========================== */
.concept-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.concept-block h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.concept-block h3 i {
    color: var(--primary);
    font-size: 16px;
}

.concept-block p {
    color: var(--text-muted);
    line-height: 1.8;
    margin-bottom: 12px;
}

.concept-block p:last-child { margin-bottom: 0; }

/* Info / Warning / Tip boxes */
.info-box, .warning-box, .tip-box {
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin: 16px 0;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font-size: 14px;
    line-height: 1.7;
}

.info-box {
    background: #eff6ff;
    border-right: 4px solid #3b82f6;
    color: #1e40af;
}

.warning-box {
    background: #fffbeb;
    border-right: 4px solid var(--warning);
    color: #92400e;
}

.tip-box {
    background: #f0fdf4;
    border-right: 4px solid var(--success);
    color: #166534;
}

.info-box i    { color: #3b82f6; margin-top: 2px; flex-shrink: 0; }
.warning-box i { color: var(--warning); margin-top: 2px; flex-shrink: 0; }
.tip-box i     { color: var(--success); margin-top: 2px; flex-shrink: 0; }

/* ===========================
   CODE BLOCKS
=========================== */
.code-block {
    background: #1e1e2e;
    border-radius: var(--radius);
    overflow: hidden;
    margin: 20px 0;
    box-shadow: var(--shadow-md);
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #2a2a3e;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.code-lang {
    font-size: 12px;
    color: #a78bfa;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.code-lang i { font-size: 14px; }

.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 6px;
    color: #94a3b8;
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
}

.copy-btn:hover {
    background: rgba(255,255,255,.15);
    color: white;
}

.copy-btn.copied {
    background: rgba(16,185,129,.2);
    border-color: var(--success);
    color: var(--success);
}

.code-block pre {
    margin: 0;
    padding: 20px;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.7;
}

.code-block pre::-webkit-scrollbar { height: 4px; }
.code-block pre::-webkit-scrollbar-track { background: transparent; }
.code-block pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 99px; }

/* Output block */
.output-block {
    background: #0f172a;
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-top: -12px;
    margin-bottom: 20px;
    border: 1px solid #1e293b;
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

.output-label {
    font-size: 11px;
    color: var(--success);
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.output-block code {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #e2e8f0;
    white-space: pre;
    display: block;
}

/* ===========================
   CODE DIRECTION FIX
=========================== */
.code-block pre,
.code-block code,
.output-block code {
    direction: ltr;
    text-align: left;
}


/* ===========================
   EXERCISE BLOCKS
=========================== */
.exercise-block {
    background: linear-gradient(135deg, #faf5ff, #f0f4ff);
    border: 1px solid #e0e7ff;
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
}

.exercise-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.exercise-badge {
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 99px;
}

.exercise-header h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.exercise-block p {
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.8;
}

/* ===========================
   SECTION NAVIGATION
=========================== */
.section-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    gap: 16px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    transition: all var(--transition);
    text-decoration: none;
}

.nav-btn:hover {
    background: var(--primary);
    color: white;border-color: var(--primary);
}

.nav-btn.disabled {
    opacity: .4;
    pointer-events: none;
}

/* ===========================
   MOBILE TOGGLE
=========================== */
.menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    align-items: center;
    justify-content: center;
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 800;
    backdrop-filter: blur(2px);
}

/* ===========================
   RESPONSIVE
=========================== */
@media (max-width: 1024px) {
    .course-stats { grid-template-columns: repeat(2, 1fr); }
    .overview-grid { grid-template-columns: 1fr; }
    .welcome-screen { padding: 32px 24px 48px; }
    .content-area { padding: 32px 24px 48px; }
}

@media (max-width: 768px) {
    .menu-toggle { display: flex; }

    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .overlay.open { display: block; }

    .main-content {
        margin-right: 0;
    }

    .welcome-hero h1 { font-size: 22px; }
    .course-stats { grid-template-columns: repeat(2, 1fr); }
    .content-title { font-size: 22px; }
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400 900;
    font-display: swap;
}


.playground-block {
    background: #1e1e2e;
    border-radius: 12px;
    overflow: hidden;
    margin: 1.5rem 0;
    border: 1px solid #313244;
}

.playground-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    background: #313244;
    color: #cdd6f4;
    font-size: 0.9rem;
}

.playground-actions button {
    background: #45475a;
    color: #cdd6f4;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 0.4rem;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.playground-actions button:hover { background: #585b70; }
.playground-actions button:first-child { background: #a6e3a1; color: #1e1e2e; }
.playground-actions button:first-child:hover { background: #94d084; }

.code-editor {
    width: 100%;
    min-height: 140px;
    background: #1e1e2e;
    color: #cdd6f4;
    border: none;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    direction: ltr;
    text-align: left;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
}


#playground-output {
    padding: 1rem;
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    direction: ltr;
    text-align: left;
    min-height: 50px;
    white-space: pre-wrap;
    border-top: 1px solid #313244;color: #f0f0f0;
}

.playground-output.success { color: #a6e3a1; }
.playground-output.error   { color: #f38ba8; }
.playground-output.warning { color: #fab387; }

.playground-block .code-editor,
.playground-block .playground-output {
    direction: ltr;
    text-align: left;
}

@media (max-width: 768px) {
    .sidebar{
    position: fixed;
    top:0;
    right:0;
    height:100dvh;
    width:min(85vw,320px);
    transform:translateX(100%);
    transition:transform .3s ease;
}

.sidebar.open{
    transform:translateX(0);
}

    .sidebar-nav {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .main-content{
    width:100%;
    overflow-x:hidden;
}

    .welcome-screen,
    .content-area {
        padding-top: 72px;
    }

    .menu-toggle.active {
        background: var(--danger);
    }

    .nav-chapter.open .nav-sub-list {
        max-height: 1000px;
    }
}

body.menu-open {
    overflow: hidden;
}

html, body {
    overflow-x: hidden;
}
