/* ── Teacher-authored HTML (exam questions, assignment texts) ───────────────
   Loaded globally from base.html. Two jobs:
   1. style the tags the server-side sanitizer allows, so a table/image in a
      question looks the same in the builder preview and on the student page;
   2. style the «ویرایش HTML» bar that static/js/rich-html.js injects.
   Inline style attributes are deliberately stripped server-side, so these
   rules are the only presentation layer. */

.rich-content { line-height: 1.95; }
.rich-content > :first-child { margin-top: 0; }
.rich-content > :last-child { margin-bottom: 0; }
.rich-content h1, .rich-content h2, .rich-content h3,
.rich-content h4, .rich-content h5, .rich-content h6 {
    font-weight: 700; margin: .75rem 0 .4rem; line-height: 1.5;
}
.rich-content h1 { font-size: 1.35rem; }
.rich-content h2 { font-size: 1.2rem; }
.rich-content h3 { font-size: 1.08rem; }
.rich-content h4, .rich-content h5, .rich-content h6 { font-size: 1rem; }
.rich-content p { margin: 0 0 .6rem; }
.rich-content ul, .rich-content ol { margin: 0 0 .6rem; padding-inline-start: 1.6rem; }
.rich-content li { margin-bottom: .25rem; }
.rich-content blockquote {
    margin: .6rem 0; padding: .35rem .9rem;
    border-inline-start: 3px solid var(--primary, #4f46e5);
    background: #f8fafc; color: #475569;
}
.rich-content hr { border: 0; border-top: 1px solid var(--border, #e2e8f0); margin: .9rem 0; }
.rich-content mark { background: #fef08a; padding: 0 .15em; }
.rich-content small { font-size: .82em; }
.rich-content pre {
    background: #f8fafc; border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px; padding: .6rem .8rem; direction: ltr; text-align: left;
    overflow-x: auto; font-size: .85rem; line-height: 1.6;
}
.rich-content code { direction: ltr; unicode-bidi: embed; }
.rich-content a { color: var(--primary, #4f46e5); text-decoration: underline; }
.rich-content img {
    max-width: 100%; height: auto; border-radius: 6px; margin: .35rem 0;
    border: 1px solid var(--border, #e2e8f0); background: #fff;
}
.rich-content figure { margin: .6rem 0; }
.rich-content figcaption { font-size: .8rem; color: #64748b; text-align: center; margin-top: .25rem; }
.rich-content table {
    width: 100%; border-collapse: collapse; margin: .6rem 0;
    font-size: .92rem; background: #fff;
}
.rich-content caption { caption-side: top; font-weight: 600; padding-bottom: .3rem; }
.rich-content th, .rich-content td {
    border: 1px solid var(--border, #cbd5e1); padding: 7px 10px;
    vertical-align: top; text-align: start;
}
.rich-content thead th { background: #f1f5f9; font-weight: 700; }
.rich-content tbody tr:nth-child(even) { background: #fafbfc; }

/* The student exam page / result / assignment pages render question and
   description HTML inside these wrappers. */
.q-body.rich-content { font-size: 1rem; }

/* ── HTML source bar (static/js/rich-html.js) ───────────────────────────── */
.eb-htmlbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin: 4px 0 0; font-size: .8rem;
}
.eb-htmltoggle, .eb-htmlfile {
    display: inline-flex; align-items: center; gap: 4px;
    border: 1px dashed var(--border, #cbd5e1); background: #fff;
    color: #475569; border-radius: 6px; padding: 3px 9px;
    font-size: .78rem; cursor: pointer; margin: 0; line-height: 1.5;
}
.eb-htmltoggle:hover, .eb-htmlfile:hover {
    color: var(--primary, #4f46e5); border-color: var(--primary, #4f46e5);
    background: #eef2ff;
}
.eb-htmltoggle:focus-visible, .eb-htmlfile:focus-visible,
.eb-htmlapply:focus-visible, .eb-htmlclose:focus-visible {
    outline: 2px solid var(--primary, #4f46e5); outline-offset: 1px;
}
.eb-htmlhint { color: #059669; font-size: .76rem; }
.eb-htmlhint.is-error { color: #dc2626; }
.eb-htmlpane { margin-top: 6px; }
.eb-htmlsrc {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    direction: ltr; text-align: left; font-size: .82rem; line-height: 1.65;
    background: #f8fafc; color: #0f172a; border-radius: 8px;
}
.eb-htmlpane-actions {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin-top: 6px;
}
.eb-preview .rich-content table, .eb-preview table {
    width: 100%; border-collapse: collapse; margin: .5rem 0;
}
.eb-preview .rich-content th, .eb-preview .rich-content td,
.eb-preview table th, .eb-preview table td {
    border: 1px solid #cbd5e1; padding: 5px 8px; vertical-align: top;
}
.eb-preview img { max-width: 100%; height: auto; }
