/* ============================================================
   OS-2045 Briefe — WYSIWYG Editor styles
   ============================================================
   Styles the toolbar, contenteditable body, status bar, image
   modal and templates dialog. Scoped to body[data-theme-mode]
   so the win311 theme remains untouched.
   ============================================================ */

body[data-theme-mode="os2045"] .brief-editor-wrap {
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    background: #0e0e10;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ---------- Toolbar ---------- */
body[data-theme-mode="os2045"] .brief-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px;
    background: linear-gradient(180deg, #1a1a1d 0%, #131316 100%);
    border-bottom: 1px solid #2a2a2a;
    position: sticky;
    top: 0;
    z-index: 5;
}

body[data-theme-mode="os2045"] .brief-tb-group {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 0 4px;
    border-right: 1px solid #2a2a2a;
}
body[data-theme-mode="os2045"] .brief-tb-group:last-child {
    border-right: 0;
}

body[data-theme-mode="os2045"] .brief-tb-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #d0d0d0;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.3;
    min-height: 26px;
    transition: background 0.1s, border-color 0.1s;
}
body[data-theme-mode="os2045"] .brief-tb-btn:hover {
    background: #2a2a2d;
    border-color: #3a3a3d;
}
body[data-theme-mode="os2045"] .brief-tb-btn:active,
body[data-theme-mode="os2045"] .brief-tb-btn[aria-pressed="true"] {
    background: #2f5b2f;
    border-color: #4f8a4f;
    color: #b6e6b6;
}

body[data-theme-mode="os2045"] .brief-toolbar select {
    background: #0a0a0c;
    color: #d0d0d0;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 12px;
    min-height: 26px;
}

body[data-theme-mode="os2045"] .brief-tb-color {
    gap: 3px;
}
body[data-theme-mode="os2045"] .brief-tb-label {
    font-size: 10px;
    color: #888;
    margin-right: 2px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
body[data-theme-mode="os2045"] .brief-tb-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid #444;
    cursor: pointer;
    padding: 0;
    font-size: 10px;
    color: #888;
    line-height: 1;
}
body[data-theme-mode="os2045"] .brief-tb-swatch:hover {
    transform: scale(1.1);
    border-color: #0f0;
}

/* ---------- Word-style page metaphor: dark workspace, white A4 page ----- */
/* The editor wrapper around .brief-wysiwyg gets the "desk" look — a darker
   background that sets off the white sheet of paper in the middle. */
body[data-theme-mode="os2045"] .brief-editor-wrap {
    background: #2a2c34 !important;
}

/* The contenteditable becomes the page itself: white, with shadow + max
   width like an A4 sheet, centered in the workspace. */
body[data-theme-mode="os2045"] .brief-wysiwyg {
    /* Workspace inset around the page */
    margin: 24px auto;
    /* A4 proportions: 210mm wide, ~96 dpi → ~794px. Keep responsive. */
    max-width: 794px;
    width: calc(100% - 48px);
    min-height: 60vh;
    padding: 56px 72px;     /* echte Seitenränder wie in Word */
    background: #ffffff;
    color: #1c1c1f;
    font-family: 'Calibri', 'Segoe UI', 'Inter', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 2px;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.03),
        0 8px 24px rgba(0,0,0,0.55),
        0 2px 6px rgba(0,0,0,0.3);
    overflow-y: auto;
    outline: none;
    cursor: text;
    box-sizing: border-box;
}
body[data-theme-mode="os2045"] .brief-wysiwyg:focus {
    background: #ffffff;
    box-shadow:
        0 0 0 2px var(--theme-accent, #5fd1ff),
        0 8px 24px rgba(0,0,0,0.55);
}
body[data-theme-mode="os2045"] .brief-wysiwyg p { margin: 0 0 10px; }
body[data-theme-mode="os2045"] .brief-wysiwyg h1 { font-size: 1.7em; margin: 0 0 12px; color: #1c1c1f; font-weight: 600; }
body[data-theme-mode="os2045"] .brief-wysiwyg h2 { font-size: 1.4em; margin: 14px 0 8px; color: #1c1c1f; font-weight: 600; }
body[data-theme-mode="os2045"] .brief-wysiwyg h3 { font-size: 1.2em; margin: 12px 0 8px; color: #2c2c2f; font-weight: 600; }
body[data-theme-mode="os2045"] .brief-wysiwyg a { color: #2563eb; }
body[data-theme-mode="os2045"] .brief-wysiwyg table { border-collapse: collapse; }
body[data-theme-mode="os2045"] .brief-wysiwyg td,
body[data-theme-mode="os2045"] .brief-wysiwyg th { border: 1px solid #c8ccd6; padding: 6px 10px; }
body[data-theme-mode="os2045"] .brief-wysiwyg th { background: #f1f3f7; }
body[data-theme-mode="os2045"] .brief-wysiwyg ul,
body[data-theme-mode="os2045"] .brief-wysiwyg ol { margin: 4px 0 8px 22px; }
body[data-theme-mode="os2045"] .brief-wysiwyg li { margin: 2px 0; }
body[data-theme-mode="os2045"] .brief-wysiwyg blockquote {
    border-left: 3px solid #4f8a4f;
    padding-left: 10px;
    margin: 8px 0;
    color: #c0c0c0;
    font-style: italic;
}
body[data-theme-mode="os2045"] .brief-wysiwyg pre {
    background: #050507;
    border: 1px solid #2a2a2a;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}
body[data-theme-mode="os2045"] .brief-wysiwyg a {
    color: #6cf;
    text-decoration: underline;
}
body[data-theme-mode="os2045"] .brief-wysiwyg table {
    border-collapse: collapse;
    margin: 8px 0;
}
body[data-theme-mode="os2045"] .brief-wysiwyg table td,
body[data-theme-mode="os2045"] .brief-wysiwyg table th {
    border: 1px solid #555;
    padding: 6px 8px;
    min-width: 60px;
}
body[data-theme-mode="os2045"] .brief-wysiwyg img {
    max-width: 100%;
    height: auto;
}
body[data-theme-mode="os2045"] .brief-wysiwyg hr {
    border: 0;
    border-top: 1px solid #444;
    margin: 12px 0;
}

/* Empty-state placeholder */
body[data-theme-mode="os2045"] .brief-wysiwyg:empty::before {
    content: 'Schreibe hier deinen Brief… nutze die Toolbar oder Strg+B/I/U für Formatierung.';
    color: #555;
    font-style: italic;
    pointer-events: none;
}

/* ---------- Status Bar ---------- */
body[data-theme-mode="os2045"] .brief-statusbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: #131316;
    border-top: 1px solid #2a2a2a;
    font-size: 11px;
    color: #888;
}
body[data-theme-mode="os2045"] .brief-statusbar .brief-sep { color: #444; }
body[data-theme-mode="os2045"] #briefSaveIndicator {
    margin-left: auto;
    font-weight: 500;
}
body[data-theme-mode="os2045"] .brief-save-idle    { color: #888; }
body[data-theme-mode="os2045"] .brief-save-pending { color: #ffa030; }
body[data-theme-mode="os2045"] .brief-save-saving  { color: #6cf; }
body[data-theme-mode="os2045"] .brief-save-saved   { color: #6cf76c; }
body[data-theme-mode="os2045"] .brief-save-error   { color: #ff5050; }

/* ---------- Image / Template Modal ---------- */
body[data-theme-mode="os2045"] .brief-img-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
body[data-theme-mode="os2045"] .brief-img-modal-card {
    background: #15151a;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 18px 20px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6);
    color: #d0d0d0;
}
body[data-theme-mode="os2045"] .brief-img-modal-card h4 {
    margin: 0 0 12px;
    color: #b6ffb6;
    font-size: 14px;
}
body[data-theme-mode="os2045"] .brief-img-modal-card input[type="text"],
body[data-theme-mode="os2045"] .brief-img-modal-card input[type="url"],
body[data-theme-mode="os2045"] .brief-img-modal-card input[type="file"] {
    background: #0a0a0c;
    color: #e6e6e6;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 12px;
    width: 100%;
    box-sizing: border-box;
}

/* ---------- Templates list ---------- */
body[data-theme-mode="os2045"] .brief-tpl-list {
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    background: #0a0a0c;
}
body[data-theme-mode="os2045"] .brief-tpl-item {
    padding: 8px 10px;
    border-bottom: 1px solid #1f1f1f;
    cursor: pointer;
    transition: background 0.1s;
}
body[data-theme-mode="os2045"] .brief-tpl-item:last-child { border-bottom: 0; }
body[data-theme-mode="os2045"] .brief-tpl-item:hover { background: #1c1c20; }
body[data-theme-mode="os2045"] .brief-tpl-name { font-size: 13px; color: #e6e6e6; font-weight: 500; }
body[data-theme-mode="os2045"] .brief-tpl-cat  { font-size: 10px; color: #888; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
body[data-theme-mode="os2045"] .brief-tpl-prev { font-size: 11px; color: #aaa; margin-top: 4px; font-style: italic; }

/* ---------- Mobile / narrow window adjustments ---------- */
@media (max-width: 720px) {
    body[data-theme-mode="os2045"] .brief-toolbar {
        padding: 4px;
    }
    body[data-theme-mode="os2045"] .brief-tb-btn {
        padding: 3px 6px;
        font-size: 11px;
    }
    body[data-theme-mode="os2045"] .brief-tb-label { display: none; }
    body[data-theme-mode="os2045"] .brief-wysiwyg {
        max-height: 50vh;
        padding: 10px 12px;
    }
}

/* ------------------------------------------------------------------
 * Keyboard accessibility (a11y / WCAG 2.4.7 — focus visible)
 * Generic outline for all interactive elements inside the briefe
 * (letters) editor. Uses --theme-accent so user accent applies.
 * ------------------------------------------------------------------ */
body[data-theme-mode="os2045"] .brief-editor-wrap button:focus-visible,
body[data-theme-mode="os2045"] .brief-editor-wrap [tabindex]:focus-visible,
body[data-theme-mode="os2045"] .brief-editor-wrap input:focus-visible,
body[data-theme-mode="os2045"] .brief-editor-wrap select:focus-visible,
body[data-theme-mode="os2045"] .brief-editor-wrap textarea:focus-visible,
body[data-theme-mode="os2045"] .brief-editor-wrap [contenteditable="true"]:focus-visible,
body[data-theme-mode="os2045"] .brief-btn:focus-visible {
    outline: 2px solid var(--theme-accent, #5fd1ff);
    outline-offset: 2px;
}
