/* استایل مشترک متن غنی (مقاله، درس و هر محتوای HTML دیگر)
   استفاده: <div class="prose prose-lg max-w-none rich-text">{{ content|safe }}</div>
   قبلاً این قواعد فقط داخل قالب مقاله بود و صفحه درس از آن بی‌بهره می‌ماند. */

.rich-text {
    max-width: none;
    color: #1f2937;
    line-height: 1.9;
}

/* --- تیترها --- */
.rich-text h2 {
    color: #111827;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.5;
    margin-top: 2.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f3f4f6;
}

.rich-text h3 {
    color: #111827;
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
}

.rich-text h4 {
    color: #111827;
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

/* --- متن --- */
.rich-text p {
    margin-top: 1.1rem;
    margin-bottom: 1.1rem;
    line-height: 1.9;
}

.rich-text strong,
.rich-text b {
    font-weight: 700;
    color: #111827;
}

.rich-text a {
    color: #2563eb;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.rich-text a:hover {
    color: #FEA000;
}

.rich-text hr {
    border: 0;
    border-top: 1px solid #e5e7eb;
    margin: 2rem 0;
}

/* --- فهرست‌ها --- */
.rich-text ul {
    list-style-type: disc;
    padding-right: 1.5rem;
    margin: 1.1rem 0;
}

.rich-text ol {
    list-style-type: decimal;
    padding-right: 1.5rem;
    margin: 1.1rem 0;
}

.rich-text li {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    line-height: 1.85;
}

.rich-text li > ul,
.rich-text li > ol {
    margin-top: 0.35rem;
    margin-bottom: 0.35rem;
}

/* --- بلوک کد --- */
.rich-text pre {
    direction: ltr;
    text-align: left;
    background-color: #272822;
    color: #f8f8f2;
    padding: 1.25rem;
    border-radius: 0.75rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    font-family: 'Fira Code', Consolas, Monaco, 'Andale Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    tab-size: 4;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.rich-text pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    border-radius: 0;
    font-size: inherit;
    direction: ltr;
    display: block;
    white-space: pre;
}

/* کد درون‌خطی */
.rich-text code {
    background: #272822;
    color: #f8f8f2;
    padding: 0.15em 0.4em;
    border-radius: 0.35rem;
    font-family: 'Fira Code', Consolas, Monaco, 'Andale Mono', monospace;
    font-size: 0.875em;
    direction: ltr;
    display: inline-block;
    unicode-bidi: embed;
}

/* --- رنگ‌بندی سینتکس (hljs) --- */
.rich-text .hljs {
    background-color: #272822;
    padding: 0;
}

.hljs-keyword { color: #f92672; }
.hljs-string { color: #e6db74; }
.hljs-number { color: #ae81ff; }
.hljs-comment { color: #75715e; }
.hljs-function { color: #a6e22e; }
.hljs-class { color: #a6e22e; }
.hljs-variable { color: #f8f8f2; }
.hljs-operator { color: #f92672; }
.hljs-title { color: #a6e22e; }
.hljs-built_in { color: #66d9ef; }
.hljs-attr { color: #a6e22e; }
.hljs-tag { color: #f92672; }

/* --- نقل‌قول --- */
.rich-text blockquote {
    border-right: 4px solid #FEA000;
    background: #f9fafb;
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin: 1.5rem 0;
    color: #374151;
}

.rich-text blockquote p:first-child { margin-top: 0; }
.rich-text blockquote p:last-child { margin-bottom: 0; }

/* --- جدول --- */
.rich-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.75rem 0;
    font-size: 0.95rem;
    display: block;
    overflow-x: auto;
}

.rich-text thead {
    background: #f3f4f6;
}

.rich-text th {
    background: #f3f4f6;
    font-weight: 700;
    text-align: right;
    padding: 0.75rem 1rem;
    border: 1px solid #e5e7eb;
}

.rich-text td {
    padding: 0.75rem 1rem;
    border: 1px solid #e5e7eb;
}

/* --- تصویر و شکل --- */
.rich-text img {
    border-radius: 1rem;
    max-width: 100%;
    height: auto;
    margin: 1.5rem 0;
}

.rich-text figure {
    margin: 1.75rem 0;
}

.rich-text figcaption {
    font-size: 0.85rem;
    color: #6b7280;
    text-align: center;
    margin-top: 0.5rem;
}

@media (max-width: 640px) {
    .rich-text h2 { font-size: 1.3rem; }
    .rich-text h3 { font-size: 1.1rem; }
    .rich-text pre { font-size: 0.82rem; padding: 1rem; }
}
