/* public/assets/css/style.css */
@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

:root {
    --primary-color: #2563eb;
    --text-color: #1f2937;
    --bg-color: #f3f4f6;
    --nav-bg: #ffffff;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --sidebar-width: 260px;
    --transition-speed: 0.3s;
}

[data-theme="dark"] {
    --primary-color: #60a5fa;
    --text-color: #f3f4f6;
    --bg-color: #111827;
    --nav-bg: #1f2937;
    --card-bg: #1f2937;
    --border-color: #374151;
}

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

body {
    font-family: 'Vazirmatn', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    direction: rtl;
    line-height: 1.6;
    overflow-x: clip; /* جلوگیری از اسکرول افقی بدون به هم زدن sticky */
}

/* ==========================================
   نوار بالا (Navbar)
   ========================================== */
.navbar {
    background-color: var(--nav-bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 60px;
    transition: background-color var(--transition-speed);
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    order: 2;
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 50%;
    width: 35px;
    height: 35px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s;
}

.theme-toggle-btn:hover {
    background: var(--border-color);
}

.nav-links {
    display: flex;
    gap: 20px;
    list-style: none;
    order: 1;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color var(--transition-speed);
}

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

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

/* ==========================================
   کانتینر اصلی و سایدبار (دسکتاپ)
   ========================================== */
.main-container {
    display: flex;
    min-height: calc(100vh - 60px);
    width: 100%;
    align-items: flex-start;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--card-bg);
    border-left: 1px solid var(--border-color);
    padding: 20px;
    transition: transform var(--transition-speed) ease-in-out;
    position: sticky;
    top: 60px; 
    align-self: flex-start;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    
    /* تنظیمات اسکرول سمت راست */
    direction: ltr; 
}

.sidebar > * {
    direction: rtl; 
}

/* زیباسازی اسکرول سایدبار */
.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-color);
}

.content-area {
    flex: 1;
    padding: 30px;
    background-color: var(--bg-color);
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* ==========================================
   استایل‌های محتوای Markdown
   ========================================== */
.content-area table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background-color: var(--card-bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
    color: var(--text-color);
}

.content-area table th,
.content-area table td {
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    text-align: right;
}

.content-area table th {
    background-color: var(--bg-color);
    font-weight: bold;
    color: var(--primary-color);
}

.content-area table tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .content-area table tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05);
}

/* هاور روی ردیف‌ها در حالت روشن */
.content-area table tr:hover {
    background-color: rgba(37, 99, 235, 0.1) !important; 
}

/* هاور روی ردیف‌ها در حالت تاریک (اولویت بالاتر برای غلبه بر رنگ ردیف‌های زوج) */
[data-theme="dark"] .content-area table tr:hover {
    background-color: rgba(96, 165, 250, 0.2) !important; 
}

.content-area blockquote {
    border-right: 4px solid var(--primary-color);
    background-color: var(--bg-color);
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 4px;
    color: var(--text-color);
}

/* .content-area pre {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    direction: ltr !important;
    text-align: left !important;
    margin: 20px 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
} */

/* .content-area pre code {
    background: transparent !important;
    color: inherit !important;
    padding: 0;
    font-family: inherit;
} */

.content-area code:not(pre code) {
    background-color: #f1f5f9;
    color: #e11d48;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    direction: ltr;
    display: inline-block;
}

.content-area ul, 
.content-area ol {
    padding-right: 25px;
    margin: 15px 0;
}

.content-area li {
    margin-bottom: 8px;
}

.content-area h1,
.content-area h2,
.content-area h3,
.content-area h4 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: var(--text-color); 
    line-height: 1.4;
}

.content-area h1 { font-size: 2rem; border-bottom: 2px solid var(--primary-color); padding-bottom: 10px; }
.content-area h2 { font-size: 1.6rem; }
.content-area h3 { font-size: 1.3rem; }
.content-area h4 { font-size: 1.1rem; }

.content-area a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px dashed var(--primary-color);
}

.content-area a:hover {
    border-bottom-style: solid;
}

.content-area img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 15px 0;
}

/* ==========================================
   استایل پوشه‌های بازشونده در فهرست دروس
   ========================================== */
.folder-header {
    font-weight: bold;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.folder-header:hover {
    color: var(--primary-color);
}

.folder-arrow {
    font-size: 0.8rem;
    color: var(--primary-color);
    display: inline-block;
    width: 15px;
    text-align: center;
}

/* ==========================================
   استایل‌های ریسپانسیو (موبایل)
   ========================================== */

/* مخفی کردن لیست دروس موبایل در دسکتاپ (باید قبل از مدیاکوئری باشد) */
.mobile-lessons-container {
    display: none;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    /* مخفی کردن سایدبار در موبایل (چون از منوی همبرگری استفاده می‌کنیم) */
    .sidebar {
        display: none !important; 
    }

    /* نمایش لیست دروس در منوی موبایل */
    .mobile-lessons-container {
        display: block;
        width: 100%;
    }

    /* منوی همبرگری در موبایل */
    .nav-links {
        display: none;
    }
    
    .nav-links.active {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 60px;
        right: 0;
        width: 100%;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
        background-color: var(--nav-bg);
        padding: 20px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        z-index: 1000;
        align-items: flex-start;
    }

    .nav-links > li {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .nav-links > li > a {
        display: block;
        padding: 10px 0;
        border-bottom: 1px solid var(--border-color);
    }

    /* اصلاحات محتوای صفحه در موبایل */
    .content-area {
        padding: 10px !important;
    }
    
    .content-area > div {
        padding: 15px !important;
        box-shadow: none !important;
    }

    .content-area table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }

    .content-area pre {
        font-size: 0.8rem;
        padding: 12px;
        max-width: 100%;
    }

    .content-area h1 { font-size: 1.5rem; }
    .content-area h2 { font-size: 1.3rem; }
    .content-area h3 { font-size: 1.1rem; }
}

/* ==========================================
   اصلاحات نهایی Prism.js برای VS Code & RTL
   ========================================== */

.content-area pre {
    direction: ltr !important; 
    text-align: left !important;
    background-color: #1e1e1e !important; /* پس‌زمینه VS Code */
    color: #d4d4d4 !important;
    padding: 20px !important;
    border-radius: 8px;
    margin: 20px 0;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    border: 1px solid #333;
}

.content-area pre code {
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
    font-family: inherit;
}

/* استایل شماره خطوط */
.content-area pre.line-numbers {
    position: relative;
    padding-left: 3.8em !important;
    counter-reset: linenumber;
}

.content-area pre.line-numbers > code {
    position: relative;
    white-space: inherit;
}

.line-numbers .line-numbers-rows {
    position: absolute;
    pointer-events: none;
    top: 0;
    font-size: 100%;
    left: -3.8em;
    width: 3em;
    letter-spacing: -1px;
    border-right: 1px solid #4b5563;
    user-select: none;
}

.line-numbers-rows > span {
    display: block;
    counter-increment: linenumber;
}

.line-numbers-rows > span:before {
    content: counter(linenumber);
    color: #858585; /* رنگ خاکستری شماره خطوط */
    display: block;
    padding-right: 0.8em;
    text-align: right;
}

/* ==========================================
   استایل دکمه کپی کد
   ========================================== */

/* موقعیت‌دهی نسبی برای بلوک کد تا دکمه داخل آن قرار بگیرد */
.content-area pre {
    position: relative;
}

/* استایل خود دکمه */
.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px; /* چون کدها چپ‌چین هستند، دکمه در بالای سمت چپ قرار می‌گیرد */
    background: rgba(255, 255, 255, 0.1);
    color: #a3a3a3;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: 'Vazirmatn', sans-serif;
    transition: all 0.2s ease;
    z-index: 10;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.copy-code-btn.copied {
    background: #10b981; /* رنگ سبز برای تایید */
    color: white;
    border-color: #10b981;
}