/* ==========================================================================
   rich-editor.css — toolbar, source area and preview pane for the composer.
   Pairs with assets/js/rich-editor.js. Output styling lives in rich-content.css.
   ========================================================================== */

.re-shell {
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: var(--radius-md, 16px);
    background: var(--surface-1, rgba(15, 23, 42, 0.65));
    overflow: visible;
    transition: border-color .18s ease, box-shadow .18s ease;
}
.re-shell:focus-within {
    border-color: var(--accent, #3b82f6);
    box-shadow: 0 0 0 3px var(--accent-ring, rgba(59, 130, 246, 0.35));
}

/* ---- Toolbar ------------------------------------------------------------- */
.re-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(148, 163, 184, 0.06);
    border-radius: var(--radius-md, 16px) var(--radius-md, 16px) 0 0;
}
.re-sep {
    width: 1px;
    height: 20px;
    margin: 0 5px;
    background: rgba(148, 163, 184, 0.25);
    flex: 0 0 auto;
}
.re-tool-wrap { position: relative; display: inline-flex; }
.re-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 13px;
    color: var(--text-secondary, #94a3b8);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    cursor: pointer;
    transition: all .13s ease;
}
.re-tool:hover {
    color: var(--text-primary, #f8fafc);
    background: rgba(148, 163, 184, 0.14);
    border-color: rgba(148, 163, 184, 0.2);
}
.re-tool:active { transform: scale(0.93); }
.re-tool:focus-visible { outline: 2px solid var(--accent, #3b82f6); outline-offset: 1px; }
.re-badge {
    font-size: 8px;
    font-weight: 800;
    margin-left: 1px;
    bottom: -0.3em;
    opacity: 0.85;
}

/* ---- Dropdown menus ------------------------------------------------------ */
.re-menu {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    z-index: 60;
    min-width: 130px;
    padding: 5px;
    /* Opaque, not the translucent surface token: a menu floating over a
       textarea has to hide the text behind it. */
    background-color: #1a2338;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: var(--radius-sm, 10px);
    box-shadow: var(--shadow-lg, 0 14px 38px rgba(0,0,0,.45));
}
.re-menu.is-open { display: block; }
.re-menu-lang {
    max-height: 260px;
    overflow-y: auto;
    columns: 2;
    column-gap: 4px;
    min-width: 230px;
}
.re-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 5px 9px;
    font: inherit;
    font-size: 12.5px;
    color: var(--text-secondary, #94a3b8);
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    break-inside: avoid;
}
.re-menu-item:hover { color: var(--text-primary, #fff); background: var(--accent-soft, rgba(59,130,246,.15)); }
.re-menu-color { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; min-width: auto; }
.re-swatch {
    width: 22px;
    height: 22px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    transition: transform .12s ease;
}
.re-swatch:hover { transform: scale(1.15); }

/* ---- Tabs ---------------------------------------------------------------- */
.re-tabs { margin-left: auto; display: inline-flex; gap: 2px; }
.re-tab {
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 4px 11px;
    cursor: pointer;
    transition: all .13s ease;
}
.re-tab:hover { color: var(--text-primary, #f8fafc); background: rgba(148, 163, 184, 0.12); }
.re-tab.is-active {
    color: var(--text-primary, #f8fafc);
    background: rgba(148, 163, 184, 0.16);
    border-color: rgba(148, 163, 184, 0.24);
}

/* ---- Body: source + preview share one slot ------------------------------- */
.re-body { position: relative; }
/* Two-class selector on purpose: several pages style their composer textarea
   from an inline <style> block in the body, which would otherwise win on source
   order and draw a second border inside the editor shell. */
.re-shell .re-textarea {
    display: block;
    width: 100%;
    min-height: 130px;
    max-height: 640px;
    padding: 13px 15px;
    font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--text-primary, #f8fafc);
    background: transparent;
    border: 0;
    border-radius: 0 0 var(--radius-md, 16px) var(--radius-md, 16px);
    resize: vertical;
    outline: none;
}
.re-shell .re-textarea::placeholder { color: var(--text-quaternary, #475569); }
.re-shell.is-previewing .re-textarea { display: none; }

.re-preview {
    display: none;
    padding: 14px 16px;
    min-height: 130px;
    max-height: 640px;
    overflow-y: auto;
}
.re-shell.is-previewing .re-preview { display: block; }
.re-preview.is-loading { opacity: 0.5; }
.re-preview-empty,
.re-preview-error,
.re-preview-note {
    font-size: 13.5px;
    color: var(--text-tertiary, #64748b);
    font-style: italic;
}
.re-preview-error { color: var(--danger, #f43f5e); font-style: normal; }
.re-preview-note { margin-top: 10px; }

/* ---- Help strip ---------------------------------------------------------- */
.re-help {
    padding: 7px 14px;
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--text-tertiary, #64748b);
    border-top: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(148, 163, 184, 0.04);
    border-radius: 0 0 var(--radius-md, 16px) var(--radius-md, 16px);
}
.re-help code {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 11px;
    background: rgba(148, 163, 184, 0.15);
    padding: 1px 5px;
    border-radius: 4px;
    color: var(--text-secondary, #94a3b8);
}

/* ---- Compact variant (replies, comments) --------------------------------- */
.re-compact .re-bar { padding: 4px 6px; }
.re-compact .re-tool { width: 27px; height: 27px; font-size: 12px; }
.re-compact .re-body .re-textarea { min-height: 84px; font-size: 13px; padding: 10px 12px; }
.re-compact .re-preview { min-height: 84px; padding: 10px 12px; }
.re-compact .re-help { display: none; }

/* ---- Small screens ------------------------------------------------------- */
@media (max-width: 640px) {
    .re-bar { gap: 0; padding: 5px 5px; }
    .re-sep { margin: 0 3px; }
    .re-tool { width: 28px; height: 28px; }
    .re-help { font-size: 10.5px; padding: 6px 10px; }
    .re-menu-lang { columns: 1; min-width: 150px; }
}

/* ---- Light theme --------------------------------------------------------- */
[data-theme="light"] .re-shell { background: #fff; border-color: rgba(15, 23, 42, 0.14); }
[data-theme="light"] .re-bar { background: rgba(15, 23, 42, 0.03); border-bottom-color: rgba(15, 23, 42, 0.1); }
[data-theme="light"] .re-menu { background-color: #fff; border-color: rgba(15, 23, 42, 0.14); }
[data-theme="light"] .re-shell .re-textarea { color: #0f172a; }
