/* ==========================================================================
   AI Engineer Interview Prep Platform - Minimalist Light Mode Theme
   Clean, Professional, Human-Crafted Minimalist UI/UX
   Font: Vazirmatn (FA) / Inter (EN)
   ========================================================================== */

@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    /* Pure Minimalist Light Palette */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-subtle: #f1f5f9;
    
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --border-active: #2563eb;
    
    --text-heading: #0f172a;
    --text-main: #334155;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    /* Brand Accents - Clean Professional Slate & Blue */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    
    --accent-indigo: #4f46e5;
    --accent-green: #059669;
    --accent-amber: #d97706;
    --accent-red: #dc2626;
    
    /* Difficulty Badges */
    --badge-beginner-bg: #ecfdf5;
    --badge-beginner-color: #047857;
    --badge-intermediate-bg: #eff6ff;
    --badge-intermediate-color: #1d4ed8;
    --badge-advanced-bg: #fef2f2;
    --badge-advanced-color: #b91c1c;
    
    /* Layout Tokens */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --transition-fast: 0.15s ease;
}

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

body {
    font-family: 'Vazirmatn', 'Vazir', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-feature-settings: "ss01";
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    direction: rtl;
    min-height: 100vh;
}

/* LTR Support for English */
html[lang="en"] body {
    direction: ltr;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html[lang="en"] .cat-item,
html[lang="en"] #search-input,
html[lang="en"] .stat-info {
    text-align: left;
}

html[lang="en"] .search-icon {
    right: auto;
    left: 14px;
}

html[lang="en"] .clear-btn {
    left: auto;
    right: 12px;
}

html[lang="en"] #search-input {
    padding: 11px 36px 11px 40px;
}

html[lang="en"] .modal-close {
    left: auto;
    right: 16px;
}

html[lang="en"] .cat-item.active {
    border-right: none;
    border-left: 3px solid var(--primary-color);
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Navbar */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    min-height: 72px;
}

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

.brand-logo {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.brand-text h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.3;
    margin-bottom: 2px;
    white-space: nowrap;
}

.brand-text h1 span:last-child {
    color: var(--primary-color);
}

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

.mobile-filter-btn {
    display: none !important;
}

.desktop-only-action {
    display: inline-flex;
}

.sidebar-overlay {
    display: none;
}

.sidebar-mobile-header {
    display: none;
}

.mobile-tools-box {
    display: none;
}

.drawer-actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 6px;
    width: 100%;
}

.drawer-action-btn {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: 8px 4px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.text-amber {
    color: var(--accent-amber);
}

.text-blue {
    color: var(--primary-color);
}

.lang-btn {
    font-weight: 700;
    padding: 7px 14px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--primary-color);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

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

.btn-secondary:hover {
    background: #e2e8f0;
    color: var(--text-heading);
}

.btn-outline {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Hero Section */
.hero-section {
    padding: 36px 0 28px 0;
    text-align: center;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 28px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--primary-light);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 20px;
    color: var(--primary-color);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.hero-content h2 {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-heading);
    margin-bottom: 10px;
    line-height: 1.35;
}

.hero-content h2 span {
    color: var(--primary-color);
}

.hero-desc {
    max-width: 720px;
    margin: 0 auto 28px auto;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    max-width: 1040px;
    margin: 0 auto;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.icon-blue { background: #eff6ff; color: #2563eb; }
.icon-purple { background: #f5f3ff; color: #7c3aed; }
.icon-green { background: #ecfdf5; color: #059669; }
.icon-amber { background: #fffbeb; color: #d97706; }

.stat-info {
    text-align: right;
}

.stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-heading);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Layout & Sidebar */
.main-layout {
    display: grid;
    grid-template-columns: 290px 1fr;
    gap: 24px;
    margin-top: 50px;
    padding-bottom: 60px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-box {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sidebar-box h3 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.sidebar-header h3 {
    margin-bottom: 0;
}

.text-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.text-btn:hover {
    text-decoration: underline;
}

/* Category Nav */
.category-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: right;
    transition: all var(--transition-fast);
    gap: 8px;
}

.cat-item-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    text-align: right;
}

html[lang="en"] .cat-item-main {
    text-align: left;
}

.cat-icon {
    width: 18px;
    text-align: center;
    font-size: 0.92rem;
    color: var(--primary-color);
    flex-shrink: 0;
}

.cat-title-text {
    font-size: 0.82rem;
    line-height: 1.3;
    color: var(--text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cat-item:hover {
    background: var(--bg-subtle);
}

.cat-item:hover .cat-title-text {
    color: var(--primary-color);
}

.cat-item.active {
    background: var(--primary-light);
    border-right: 3px solid var(--primary-color);
}

.cat-item.active .cat-title-text {
    color: var(--primary-color);
    font-weight: 700;
}

.cat-count {
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--bg-subtle);
    padding: 2px 7px;
    border-radius: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Difficulty Chips */
.filter-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    width: 100%;
}

.filter-chip {
    flex: 1 1 0px;
    min-width: 0;
    cursor: pointer;
    user-select: none;
    text-align: center;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    width: auto;
}

.filter-chip .badge {
    width: 100%;
    padding: 6px 4px;
    font-size: 0.73rem;
}

/* Inactive Badges */
.badge-all {
    background: #f8fafc;
    color: #64748b;
    border-color: #e2e8f0;
}

.badge-beginner {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.badge-intermediate {
    background: #f0f9ff;
    color: #1e40af;
    border-color: #bae6fd;
}

.badge-advanced {
    background: #fff1f2;
    color: #9f1239;
    border-color: #fecdd3;
}

/* Active Badge Transformations (Mellow, Soft & Harmonious) */
.filter-chip.active .badge-all {
    background: #475569;
    color: #ffffff;
    border-color: #475569;
    box-shadow: 0 2px 5px rgba(71, 85, 105, 0.18);
}

.filter-chip.active .badge-beginner {
    background: #10b981;
    color: #ffffff;
    border-color: #10b981;
    box-shadow: 0 2px 5px rgba(16, 185, 129, 0.18);
}

.filter-chip.active .badge-intermediate {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 2px 5px rgba(59, 130, 246, 0.18);
}

.filter-chip.active .badge-advanced {
    background: #f43f5e;
    color: #ffffff;
    border-color: #f43f5e;
    box-shadow: 0 2px 5px rgba(244, 63, 94, 0.18);
}

.filter-chip:not(.active):hover .badge {
    transform: translateY(-1px);
}

.category-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--primary-light);
    color: var(--primary-color);
    white-space: nowrap;
}

/* GitHub Sidebar Profile Link */
.github-profile-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-heading);
    transition: all var(--transition-fast);
}

.github-profile-link:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.github-link-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.github-link-icon {
    font-size: 1.3rem;
    color: #0f172a;
}

.github-profile-link:hover .github-link-icon {
    color: var(--primary-color);
}

.github-user-info {
    display: flex;
    flex-direction: column;
}

.github-username {
    font-weight: 700;
    font-size: 0.88rem;
    line-height: 1.2;
}

.github-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.external-icon {
    font-size: 0.78rem;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.github-profile-link:hover .external-icon {
    color: var(--primary-color);
    transform: translate(-2px, -2px);
}

html[lang="en"] .github-profile-link:hover .external-icon {
    transform: translate(2px, -2px);
}

/* Content Area & Search */
.content-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.search-wrapper {
    position: relative;
    flex: 1;
}

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

#search-input {
    width: 100%;
    padding: 10px 38px 10px 34px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-heading);
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    transition: all var(--transition-fast);
}

#search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.clear-btn {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
}

.sorting-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Custom Professional Select Styling */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 10px center;
    padding: 8px 12px 8px 30px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-heading);
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all var(--transition-fast);
}

html[lang="en"] select {
    background-position: right 10px center;
    padding: 8px 30px 8px 12px;
}

select:hover {
    border-color: #cbd5e1;
    background-color: #f8fafc;
}

select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

select option {
    background-color: #ffffff;
    color: #0f172a;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 10px;
}

/* Active Tags Bar */
.active-tags-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-light);
    border: 1px solid rgba(37, 99, 235, 0.15);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}

.active-tags-label {
    font-weight: 700;
    color: var(--primary-color);
}

.tags-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-heading);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.tag-pill i {
    cursor: pointer;
    color: var(--text-muted);
}

.tag-pill i:hover {
    color: var(--accent-red);
}

/* Questions Cards Feed */
.questions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.q-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.q-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.q-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.q-badges {
    display: flex;
    align-items: center;
    gap: 6px;
}

.q-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.45;
}

.q-summary {
    color: var(--text-muted);
    font-size: 0.88rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.q-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.q-tag {
    font-size: 0.72rem;
    color: var(--primary-color);
    background: var(--primary-light);
    padding: 2px 7px;
    border-radius: 4px;
}

.q-card-bottom {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--bg-subtle);
}

.read-more-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary-color);
    border: 1px solid rgba(37, 99, 235, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.read-more-btn:hover {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

/* Pagination Bar */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    margin-top: 8px;
    flex-wrap: wrap;
    gap: 14px;
}

.pagination-info {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.pagination-info span {
    color: var(--text-heading);
    font-weight: 700;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-nav-btn {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all var(--transition-fast);
}

.page-nav-btn:hover:not(:disabled) {
    background: var(--primary-light);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.page-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-numbers {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    min-width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.page-btn:hover {
    background: var(--bg-subtle);
    color: var(--text-heading);
}

.page-btn.active {
    background: var(--primary-color);
    color: #ffffff;
    font-weight: 700;
    border-color: var(--primary-color);
}

.page-dots {
    color: var(--text-muted);
    padding: 0 4px;
    font-size: 0.85rem;
}

.page-size-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-muted);
}



/* Highlight */
mark.highlight {
    background: #fef08a;
    color: #854d0e;
    padding: 0 3px;
    border-radius: 2px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    background: #ffffff;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
}

.empty-icon {
    font-size: 2.5rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-heading);
    margin-bottom: 6px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 16px;
    font-size: 0.88rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-container {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 820px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-close {
    position: absolute;
    top: 18px;
    left: 18px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 20;
}

[dir="ltr"] .modal-close {
    left: auto;
    right: 18px;
}

.modal-close:hover {
    background: var(--primary-light);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.modal-header {
    padding: 22px 24px 18px 24px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.modal-badges {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-left: 45px;
}

[dir="ltr"] .modal-badges {
    padding-left: 0;
    padding-right: 45px;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-heading);
    line-height: 1.4;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    font-size: 0.94rem;
    line-height: 1.75;
}

/* Modal Content Styling */
.modal-section {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.modal-section h4 {
    font-size: 0.92rem;
    color: var(--primary-color);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Key Takeaway Box */
.tip-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.tip-box h4 {
    color: var(--accent-amber);
    font-size: 0.9rem;
    font-weight: 800;
    margin-bottom: 4px;
}

/* Code Snippet Box */
.code-container {
    position: relative;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin: 8px 0;
    direction: ltr;
    text-align: left;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1e293b;
    padding: 6px 14px;
    font-size: 0.75rem;
    color: #94a3b8;
    font-family: monospace;
}

.copy-code-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #e2e8f0;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.72rem;
    font-family: inherit;
}

.copy-code-btn:hover {
    background: var(--primary-color);
    color: #ffffff;
}

.code-block {
    padding: 14px;
    overflow-x: auto;
    font-family: 'Consolas', 'Fira Code', Monaco, monospace;
    font-size: 0.85rem;
    color: #f8fafc;
    line-height: 1.5;
}

/* SVG Diagram Box */
.diagram-box {
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    overflow-x: auto;
}

.diagram-box svg {
    max-width: 100%;
    height: auto;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
}

.modal-nav-full {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Quiz Modal */
.quiz-container {
    max-width: 680px;
}

.quiz-header {
    padding: 20px 24px 10px 24px;
}

.quiz-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-subtle);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 10%;
    transition: width 0.3s ease;
}

.quiz-counter {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.quiz-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.quiz-card h3 {
    font-size: 1.15rem;
    color: var(--text-heading);
    line-height: 1.45;
}

.quiz-hint-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-light);
    border: 1px solid rgba(37, 99, 235, 0.2);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--primary-color);
    font-size: 0.85rem;
}

.quiz-answer-container {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 8px;
}

.quiz-answer-container h4 {
    margin-bottom: 8px;
}

.quiz-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    background: #ffffff;
}

.copyright {
    margin-top: 4px;
    font-size: 0.78rem;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   Mobile & Responsive Optimization Rules (Flawless Mobile UX)
   ========================================================================== */

/* Base Overflow & Box Containment Safety */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Tablet & Smaller Layouts (< 960px) */
@media (max-width: 960px) {
    .container {
        padding: 0 16px;
        width: 100%;
        max-width: 100%;
    }

    .header-container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        max-width: 100%;
    }

    .mobile-filter-btn {
        display: inline-flex !important;
        align-items: center;
        gap: 6px;
        font-weight: 700;
    }

    .desktop-only-action {
        display: none !important;
    }

    .mobile-tools-box {
        display: block !important;
    }

    .main-layout {
        display: block;
        margin-top: 16px;
        padding-bottom: 40px;
        width: 100%;
        max-width: 100%;
    }

    /* Mobile Backdrop Overlay */
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 23, 42, 0.55);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Mobile Slide-Out Drawer Sidebar */
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 320px;
        max-width: 85vw;
        height: 100vh;
        height: 100dvh;
        background: #ffffff;
        z-index: 1000;
        overflow-y: auto;
        padding: 18px 16px;
        display: flex;
        flex-direction: column;
        gap: 16px;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: -6px 0 24px rgba(0, 0, 0, 0.15);
    }

    html[lang="en"] .sidebar {
        right: auto;
        left: 0;
        transform: translateX(-100%);
        box-shadow: 6px 0 24px rgba(0, 0, 0, 0.15);
    }

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

    .sidebar-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-mobile-header h3 {
        font-size: 1rem;
        font-weight: 700;
        color: var(--text-heading);
        display: flex;
        align-items: center;
        gap: 8px;
    }

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

    .mobile-close-btn:hover {
        background: var(--primary-light);
        color: var(--primary-color);
        border-color: var(--primary-color);
    }

    .sidebar-box {
        padding: 14px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
        border-radius: var(--radius-md);
    }

    .sidebar-header {
        margin-bottom: 10px;
    }

    /* Vertical Category Nav in Drawer */
    .category-nav {
        display: flex;
        flex-direction: column;
        gap: 6px;
        width: 100%;
        max-width: 100%;
        overflow: visible;
        padding: 0;
        margin: 0;
    }

    .cat-item {
        white-space: normal;
        flex-shrink: 0;
        width: 100%;
        border-radius: var(--radius-sm);
        padding: 9px 12px;
        border: 1px solid var(--border-color);
        background: #ffffff;
        font-size: 0.86rem;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        text-align: right;
        box-shadow: none;
    }

    html[lang="en"] .cat-item {
        text-align: left;
    }

    .cat-item.active {
        border: 1px solid var(--primary-color);
        background: var(--primary-light);
        box-shadow: none;
        border-right: 3px solid var(--primary-color);
    }

    html[lang="en"] .cat-item.active {
        border-right: 1px solid var(--primary-color);
        border-left: 3px solid var(--primary-color);
    }

    .cat-item.active .cat-title-text {
        font-weight: 700;
        color: var(--primary-color);
    }

    /* Difficulty Filters 4-Column Responsive Grid */
    .filter-group {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        width: 100%;
        max-width: 100%;
    }

    .filter-chip {
        width: 100%;
        min-width: 0;
    }

    .filter-chip .badge {
        width: 100%;
        padding: 8px 2px;
        font-size: 0.76rem;
        text-align: center;
        justify-content: center;
        min-height: 36px;
        border-radius: var(--radius-sm);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        box-sizing: border-box;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        width: 100%;
        max-width: 100%;
    }

    .hero-section {
        padding: 24px 0 20px 0;
        margin-bottom: 20px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .hero-content h2 {
        font-size: 1.45rem;
    }

    .hero-desc {
        font-size: 0.88rem;
        margin-bottom: 20px;
    }
}

/* Standard Mobile Devices (< 640px) */
@media (max-width: 640px) {
    .container {
        padding: 0 16px;
        width: 100%;
        max-width: 100%;
    }

    /* Mobile Header Layout: Spacious Premium Header */
    .header-container {
        height: auto;
        min-height: 64px;
        padding: 25px 20px 20px 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .brand {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        flex: 1;
        overflow: hidden;
    }

    .brand-logo {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
        flex-shrink: 0;
    }

    .brand-text {
        min-width: 0;
        overflow: hidden;
    }

    .brand-text h1 {
        font-size: 0.88rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.25;
    }

    .header-actions {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }

    .mobile-filter-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
        min-height: 36px;
        border-radius: var(--radius-sm);
        flex-shrink: 0;
    }

    .btn {
        padding: 5px 8px;
        font-size: 0.76rem;
        min-height: 34px;
        border-radius: var(--radius-sm);
        white-space: nowrap;
        gap: 4px;
    }

    .lang-btn {
        padding: 5px 7px;
        font-size: 0.76rem;
    }

    /* Controls Bar: Single-Row Search & Sort on Mobile */
    .controls-bar {
        display: flex;
        flex-direction: row;
        gap: 6px;
        align-items: center;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .search-wrapper {
        flex: 1;
        min-width: 0;
    }

    #search-input {
        padding: 7px 30px 7px 28px;
        font-size: 0.8rem;
        min-height: 38px;
        width: 100%;
        box-sizing: border-box;
    }

    html[lang="en"] #search-input {
        padding: 7px 28px 7px 30px;
    }

    .search-icon {
        font-size: 0.85rem;
    }

    .sorting-wrapper {
        display: flex;
        align-items: center;
        gap: 4px;
        flex-shrink: 0;
        min-width: 0;
    }

    .sorting-wrapper label span[data-i18n="sortLabel"] {
        display: none; /* Hide 'مرتب‌سازی:' text label on mobile to fit in 1 single row */
    }

    select {
        background-position: left 10px center;
        padding: 6px 10px 6px 28px;
        font-size: 0.78rem;
        min-height: 36px;
        box-sizing: border-box;
    }

    html[lang="en"] select {
        background-position: right 10px center;
        padding: 6px 28px 6px 10px;
    }

    /* Active Filter Tags */
    .active-tags-bar {
        padding: 8px 12px;
        font-size: 0.78rem;
        flex-wrap: wrap;
        width: 100%;
    }

    .tag-pill {
        padding: 3px 8px;
        font-size: 0.75rem;
    }

    /* Mobile Question Feed */
    .content-area {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .questions-grid {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        gap: 10px;
    }

    .q-card {
        padding: 14px;
        gap: 8px;
        border-radius: var(--radius-md);
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        overflow: hidden;
    }

    .q-card-top {
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }

    .q-title {
        font-size: 0.95rem;
        line-height: 1.45;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .q-summary {
        font-size: 0.84rem;
        line-height: 1.55;
        -webkit-line-clamp: 3;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .read-more-btn {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
    }

    /* Mobile Pagination Bar */
    .pagination-bar {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
        padding: 12px 10px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .pagination-info {
        font-size: 0.8rem;
    }

    .pagination-controls {
        width: 100%;
        justify-content: center;
        gap: 4px;
        flex-wrap: wrap;
    }

    .page-nav-btn {
        padding: 6px 10px;
        font-size: 0.78rem;
        min-height: 36px;
    }

    .page-numbers {
        gap: 3px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .page-btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.78rem;
    }

    .page-size-wrapper {
        font-size: 0.8rem;
        gap: 6px;
        margin-top: 2px;
    }

    /* Mobile Modals (100dvh) */
    .modal-overlay {
        padding: 10px;
    }

    .modal-container {
        width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
        border-radius: var(--radius-md);
    }

    .modal-close {
        top: 14px;
        left: 14px;
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
    }

    html[lang="en"] .modal-close {
        left: auto;
        right: 14px;
    }

    .modal-header {
        padding: 14px 14px 12px 50px;
    }

    html[lang="en"] .modal-header {
        padding: 14px 50px 12px 14px;
    }

    .modal-badges {
        padding-left: 0;
        margin-bottom: 6px;
    }

    html[lang="en"] .modal-badges {
        padding-right: 0;
    }

    .modal-header h2 {
        font-size: 1rem;
        line-height: 1.4;
    }

    .modal-body {
        padding: 14px;
        gap: 12px;
        font-size: 0.88rem;
        line-height: 1.65;
        overflow-x: hidden;
    }

    .modal-section {
        padding: 12px;
    }

    /* Containment for Tables and Code blocks in Modal */
    .modal-body table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-collapse: collapse;
        margin: 10px 0;
    }

    .modal-body th, .modal-body td {
        padding: 6px 8px;
        font-size: 0.8rem;
        border: 1px solid var(--border-color);
        white-space: nowrap;
    }

    .code-container {
        margin: 8px 0;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
    }

    .code-block {
        font-size: 0.78rem;
        padding: 10px;
    }

    .diagram-box {
        padding: 10px;
        max-width: 100%;
        overflow-x: auto;
    }

    .modal-footer {
        padding: 10px 14px;
    }

    .modal-nav-full {
        gap: 6px;
    }

    .modal-nav-full .btn {
        flex: 1;
        padding: 7px 6px;
        font-size: 0.76rem;
        justify-content: center;
    }

    .quiz-container {
        max-height: 90vh;
        max-height: 90dvh;
    }

    .quiz-header {
        padding: 14px 14px 8px 14px;
    }

    .quiz-card {
        padding: 14px;
        gap: 10px;
    }

    .quiz-card h3 {
        font-size: 0.95rem;
        line-height: 1.4;
    }

    .quiz-hint-box {
        padding: 8px 10px;
        font-size: 0.78rem;
    }

    .quiz-footer {
        padding: 10px 14px;
        flex-direction: column;
        gap: 8px;
    }

    .quiz-footer .btn {
        width: 100%;
    }

    .quiz-navigation {
        width: 100%;
    }
}

/* Compact Mobile Screens (< 480px) */
@media (max-width: 480px) {
    .filter-group {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    .filter-chip .badge {
        padding: 6px 2px;
        font-size: 0.72rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .stat-card {
        padding: 8px 10px;
        gap: 6px;
    }

    .stat-value {
        font-size: 0.9rem;
    }

    .stat-label {
        font-size: 0.68rem;
    }

    .brand-text h1 {
        font-size: 0.88rem;
    }

    .q-title {
        font-size: 0.92rem;
    }

    .cat-item {
        padding: 6px 12px;
        font-size: 0.78rem;
    }
}
