/* ============================================
   ARTICLE LAYOUT
   ============================================ */
   .article-wrapper {
    display: flex;
    gap: 2.5rem;
    margin-top: 20px;
    align-items: flex-start;
}

/* ===== SIDEBAR (TOC) ===== */
.sidebar {
    position: sticky;
    top: 100px;
    align-self: start;
    flex-shrink: 0;
    width: 240px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

html[dir="rtl"] .sidebar {
    order: -1;
    margin-left: 0;
    margin-right: auto;
}

html[dir="ltr"] .sidebar {
    order: -1;
    margin-right: 0;
    margin-left: auto;
}

.sidebar .toc {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: background 0.3s, border-color 0.3s;
}

.sidebar .toc h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar .toc h3 i {
    color: var(--accent);
    font-size: 0.9rem;
}

.sidebar .toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar .toc ul li {
    margin-bottom: 0.2rem;
}

.sidebar .toc ul li a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.82rem;
    transition: var(--transition);
    display: block;
    padding: 0.15rem 0;
    border-right: 2px solid transparent;
    padding-right: 0.6rem;
    line-height: 1.4;
}

html[dir="ltr"] .sidebar .toc ul li a {
    border-right: none;
    border-left: 2px solid transparent;
    padding-right: 0;
    padding-left: 0.6rem;
}

.sidebar .toc ul li a:hover,
.sidebar .toc ul li a.active-toc {
    color: var(--accent);
    border-right-color: var(--accent);
    font-weight: 600;
}

html[dir="ltr"] .sidebar .toc ul li a:hover,
html[dir="ltr"] .sidebar .toc ul li a.active-toc {
    border-left-color: var(--accent);
    border-right-color: transparent;
}

.sidebar .toc ul li ul {
    padding-right: 1rem;
    font-size: 0.75rem;
    list-style: none;
}

html[dir="ltr"] .sidebar .toc ul li ul {
    padding-right: 0;
    padding-left: 1rem;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--bg-body);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    min-width: 0;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 3rem 3.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
    overflow-wrap: break-word;
}

/* ============================================
   BLOG HEADER - استایل بهبودیافته
   ============================================ */
.blog-header {
    margin-bottom: 3rem;
    padding-top: 0.5rem;
    position: relative;
}

.blog-header h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.blog-header p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 550px;
    line-height: 1.7;
    font-weight: 400;
}

/* ============================================
   ARTICLE HEADER
   ============================================ */
.article-header {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.article-header .category-tag {
    display: inline-flex;
    align-items: center;
    background: var(--accent-light);
    padding: 0.15rem 1rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.6rem;
}

.article-header h1 {
    font-size: 2.4rem;
    font-weight: 800;
    line-height: 1.3;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.article-header .article-meta {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    flex-wrap: wrap;
    margin-top: 0.8rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.article-header .tags {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.6rem;
}

.article-header .tags .tag {
    background: var(--border-color);
    padding: 0.05rem 0.9rem;
    border-radius: 20px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.article-header .tags .tag:hover {
    background: var(--accent);
    color: white;
}

/* ============================================
   FEATURED IMAGE
   ============================================ */
.article-featured-image {
    width: 100%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, var(--accent-light), var(--border-color));
}

.article-featured-image img {
    width: 100%;
    height: auto;
    display: block;
}

.article-featured-image .image-caption {
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    background: var(--bg-body);
    border-top: 1px solid var(--border-color);
}

/* ============================================
   FEATURED POST - استایل متمایز
   ============================================ */
.featured-post {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    transition: var(--transition);
    margin-bottom: 2.5rem;
    box-shadow: var(--shadow);
}

.featured-post:hover {
    border-color: var(--accent);
    box-shadow: 0 12px 40px rgba(37, 99, 235, 0.08);
}

.featured-post .post-image {
    height: 100%;
    min-height: 320px;
    background: linear-gradient(135deg, var(--accent-light), var(--border-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    color: var(--accent);
    overflow: hidden;
}

.featured-post .post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.featured-post .post-content {
    padding: 2.8rem 3.2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.featured-post .post-content .category-tag {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    background: var(--accent-light);
    padding: 0.2rem 1.2rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.8rem;
    letter-spacing: 0.3px;
}

.featured-post .post-content h2 {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.3;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.featured-post .post-content h2 a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

.featured-post .post-content h2 a:hover {
    color: var(--accent);
}

.featured-post .post-content p {
    color: var(--text-secondary);
    margin-top: 0.6rem;
    line-height: 1.8;
    font-size: 1rem;
}

.featured-post .post-content .post-meta {
    margin-top: 1.2rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

/* ============================================
   ARTICLE BODY
   ============================================ */
.article-body {
    color: var(--text-secondary);
}

.article-body h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2.2rem;
    margin-bottom: 0.6rem;
    padding-top: 0.5rem;
    scroll-margin-top: 90px;
}

.article-body h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1.6rem;
    margin-bottom: 0.5rem;
    scroll-margin-top: 90px;
}

.article-body p {
    margin-bottom: 1rem;
    line-height: 1.9;
}

.article-body .lead {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.article-body ul,
.article-body ol {
    padding-right: 1.8rem;
    margin-bottom: 1rem;
}

html[dir="ltr"] .article-body ul,
html[dir="ltr"] .article-body ol {
    padding-right: 0;
    padding-left: 1.8rem;
}

.article-body blockquote {
    border-right: 4px solid var(--accent);
    padding: 0.8rem 1.5rem;
    margin: 1.2rem 0;
    background: var(--bg-body);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
    color: var(--text-secondary);
}

html[dir="ltr"] .article-body blockquote {
    border-right: none;
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.article-body .highlight-box {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1.2rem 1.8rem;
    margin: 1.2rem 0;
}

.article-body .highlight-box h4 {
    margin-top: 0;
    color: var(--accent);
}

.article-body .figure {
    margin: 1.8rem 0;
    text-align: center;
}

.article-body .figure img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.article-body .figure figcaption {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.article-body code {
    background: var(--bg-body);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    color: var(--accent);
}

.article-body pre {
    background: var(--bg-body);
    padding: 1.2rem 1.5rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 1.2rem 0;
    border: 1px solid var(--border-color);
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
    direction: ltr;
    text-align: left;
}

.article-body pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* ============================================
   REFERENCES
   ============================================ */
.references {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.references h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.references h3 i {
    color: var(--accent);
}

.references ol {
    padding-right: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

html[dir="ltr"] .references ol {
    padding-right: 0;
    padding-left: 1.5rem;
}

.references ol li {
    margin-bottom: 0.4rem;
}

.references ol li a {
    color: var(--accent);
    text-decoration: none;
}

.references ol li a:hover {
    text-decoration: underline;
}

/* ============================================
   FOOTER NOTE
   ============================================ */
.footer-note {
    margin-top: 2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-muted);
    font-style: italic;
    letter-spacing: 0.3px;
    line-height: 1.8;
}

.footer-note::before {
    content: "✧ ";
    color: var(--accent);
}

.footer-note::after {
    content: " ✧";
    color: var(--accent);
}

/* ============================================
   RESPONSIVE - ARTICLE
   ============================================ */
@media (max-width: 992px) {
    .article-wrapper {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .sidebar {
        position: static;
        width: 100%;
        max-height: none;
        overflow-y: visible;
        order: -1 !important;
        margin: 0 !important;
    }
    
    .sidebar .toc {
        padding: 1rem 1.2rem;
    }
    
    .sidebar .toc ul {
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem 0.6rem;
    }
    
    .sidebar .toc ul li {
        margin-bottom: 0;
    }
    
    .sidebar .toc ul li a {
        border-right: none !important;
        border-left: none !important;
        padding: 0.1rem 0.8rem;
        font-size: 0.78rem;
        background: var(--bg-body);
        border-radius: 20px;
        white-space: nowrap;
    }
    
    .sidebar .toc ul li a:hover,
    .sidebar .toc ul li a.active-toc {
        background: var(--accent);
        color: white;
    }
    
    .sidebar .toc ul li ul {
        display: none;
    }
    
    .main-content {
        padding: 2rem 1.8rem;
    }
    
    .article-header h1 {
        font-size: 1.8rem;
    }
    
    .featured-post {
        grid-template-columns: 1fr;
    }
    
    .featured-post .post-image {
        min-height: 220px;
    }
    
    .featured-post .post-content {
        padding: 2rem 2rem;
    }
    
    .featured-post .post-content h2 {
        font-size: 1.6rem;
    }
    
    .blog-header h1 {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1.5rem 1rem;
        border-radius: var(--radius-sm);
        margin-top: 12px;
    }
    
    .article-header h1 {
        font-size: 1.5rem;
    }
    .article-body h2 {
        font-size: 1.3rem;
    }
    
    .sidebar .toc ul {
        gap: 0.2rem 0.4rem;
    }
    
    .sidebar .toc ul li a {
        font-size: 0.7rem;
        padding: 0.05rem 0.6rem;
    }
    
    .footer-note {
        font-size: 0.85rem;
    }
    
    .featured-post .post-content {
        padding: 1.5rem 1.2rem;
    }
    
    .featured-post .post-content h2 {
        font-size: 1.3rem;
    }
    
    .featured-post .post-image {
        min-height: 180px;
        font-size: 3.5rem;
    }
    
    .blog-header {
        margin-bottom: 2rem;
        padding-top: 0;
    }
    
    .blog-header h1 {
        font-size: 2.2rem;
    }
    
    .blog-header h1::before,
    .blog-header h1::after {
        content: '';
    }
    
    .blog-header p {
        font-size: 1rem;
        padding: 0 0.5rem;
    }
    
    .blog-header::after {
        width: 40px;
        bottom: -0.5rem;
    }
}

@media (max-width: 500px) {
    .main-content {
        padding: 1rem 0.8rem;
        border-radius: 8px;
    }
    .article-header .article-meta {
        font-size: 0.75rem;
        gap: 0.6rem;
    }
    .sidebar .toc ul li a {
        font-size: 0.65rem;
        padding: 0.05rem 0.5rem;
    }
    .footer-note {
        font-size: 0.8rem;
    }
    
    .blog-header h1 {
        font-size: 1.8rem;
    }
    
    .blog-header p {
        font-size: 0.9rem;
    }
}