/* CKEditor 5 uses its own color system. Map it to a readable dark palette when
   Bootstrap's global color mode is dark; this also covers floating panels. */
/* Keep the editor UI and editable Persian content consistent with the portal font. */
.ck.ck-editor,
.ck.ck-editor__editable,
.ck.ck-editor__editable_inline,
.ck.ck-dropdown__panel,
.ck.ck-list,
.ck.ck-balloon-panel {
    font-family: Vazir, Tahoma, sans-serif !important;
}

.ck.ck-editor__main > .ck-editor__editable {
    font-size: 1rem;
    line-height: 1.9;
}

html[data-bs-theme="dark"] {
    --ck-color-base-foreground: #202a36;
    --ck-color-base-background: #171f29;
    --ck-color-base-border: #3b4858;
    --ck-color-base-border-light: #2d3946;
    --ck-color-base-action: #4b8fbd;
    --ck-color-base-action-hover: #5ba0ce;
    --ck-color-base-action-muted: #263c4c;
    --ck-color-base-action-disabled: #405969;
    --ck-color-base-focus: #70b8e5;
    --ck-color-base-text: #e5ebf2;
    --ck-color-base-text-light: #aab7c5;
    --ck-color-base-active: #70b8e5;
    --ck-color-base-active-focus: #8bc8ef;
    --ck-color-base-hover: #2a3745;
    --ck-color-base-hover-strong: #344353;
    --ck-color-base-selected: #253a4e;
    --ck-color-base-selected-hover: #2d4860;
    --ck-color-base-focus-shadow: #70b8e538;
    --ck-color-base-focus-shadow-faded: #70b8e51a;
    --ck-color-base-error-shadow: #4b292d;
    --ck-color-base-success: #55bd91;
    --ck-color-base-warning: #e5b45e;
    --ck-color-interactive-primary-text: #fff;
    --ck-color-engine-placeholder-text: #9aa9b9;
    --ck-color-link-default: #8fc8f0;
    --ck-color-code-block-label-background: #344353;
    --ck-color-table-focused-cell-background: #253a4e;
}

html[data-bs-theme="dark"] .ck.ck-editor__top .ck-toolbar {
    background: var(--ck-color-base-foreground);
    border-color: var(--ck-color-base-border);
}

html[data-bs-theme="dark"] .ck.ck-editor__main > .ck-editor__editable {
    background: var(--ck-color-base-background);
    border-color: var(--ck-color-base-border);
    color: var(--ck-color-base-text);
}

html[data-bs-theme="dark"] .ck.ck-editor__editable.ck-focused,
html[data-bs-theme="dark"] .ck.ck-editor__main > .ck-editor__editable.ck-focused {
    border-color: var(--ck-color-base-focus);
}

html[data-bs-theme="dark"] .ck.ck-editor__editable > p,
html[data-bs-theme="dark"] .ck.ck-editor__editable > h1,
html[data-bs-theme="dark"] .ck.ck-editor__editable > h2,
html[data-bs-theme="dark"] .ck.ck-editor__editable > h3,
html[data-bs-theme="dark"] .ck.ck-editor__editable li,
html[data-bs-theme="dark"] .ck.ck-editor__editable blockquote {
    color: var(--ck-color-base-text);
}

html[data-bs-theme="dark"] .ck.ck-editor__editable blockquote {
    border-color: var(--ck-color-base-border);
}

html[data-bs-theme="dark"] .ck.ck-editor__editable pre {
    background: #111820;
    border-color: var(--ck-color-base-border);
    color: var(--ck-color-base-text);
}

html[data-bs-theme="dark"] .ck.ck-editor__editable table th {
    background: var(--ck-color-base-foreground);
}

html[data-bs-theme="dark"] .ck.ck-editor__editable table td,
html[data-bs-theme="dark"] .ck.ck-editor__editable table th {
    border-color: var(--ck-color-base-border);
}
.ccsc-reference{display:inline;padding:.05rem .3rem;border-radius:.3rem;background:var(--bs-primary-bg-subtle,#e7f1ff);color:var(--bs-primary-text-emphasis,#084298);text-decoration:none;border:1px solid var(--bs-primary-border-subtle,#b6d4fe)}
.ccsc-reference-suggestion{display:flex;gap:.6rem;align-items:center;direction:rtl;text-align:right;max-width:32rem;white-space:normal}
.ccsc-reference-suggestion small{flex-shrink:0;color:var(--bs-secondary-color,#667085);font-size:.75rem}
.chat-composer .ck-editor{width:100%;min-width:0}.chat-composer .ck-editor__top{display:none}.chat-composer .ck-editor__editable{min-height:42px!important;max-height:160px;overflow-y:auto}.chat-composer .ck-editor__editable p{margin:0}

.ck.ck-mentions { max-height: 320px; overflow-y: auto; }
