/*
 * SAPify – gemeinsame Bausteine: Text-Editor (sapify-editor.js) und gespeicherte Filter (sapify-filter.js).
 * In allen Apps IDENTISCH (Quelle: SAPify-Portal/client/editor/). Nicht je App anpassen – Abweichungen gehören ins CSS der App.
 * Farben folgen den Variablen der App (--border, --surface, --surface-alt, --surface-hover, --text, --text-muted, --sap-blue,
 * --radius); fehlen sie, gelten die Ersatzwerte. Heissen die Variablen einer App anders, dort Aliase setzen.
 * Die Klassen kb-… entstehen im Server (rich_text.py) aus den Formatierungen des Editors.
 */
/* Artikeltext: ein weisses Blatt in beiden Designs, damit Farben und Markierungen wie im Editor aussehen */
.kb-inhalt { background: #fff; color: #1a1a1a; border: 1px solid var(--border, #c9ced4); border-radius: 6px; padding: 26px 30px; margin-top: 12px; font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.kb-inhalt > :first-child { margin-top: 0; } .kb-inhalt > :last-child { margin-bottom: 0; }
.kb-inhalt p { margin: 0 0 10px; } .kb-inhalt h2, .kb-inhalt h3, .kb-inhalt h4 { color: #1c2b3a; margin: 20px 0 8px; line-height: 1.3; text-transform: none; letter-spacing: 0; }
.kb-inhalt h2 { font-size: 22px; } .kb-inhalt h3 { font-size: 18px; } .kb-inhalt h4 { font-size: 15.5px; }
.kb-inhalt ul, .kb-inhalt ol { margin: 0 0 10px; padding-left: 26px; } .kb-inhalt li { margin-bottom: 3px; }
.kb-inhalt blockquote { margin: 0 0 10px; padding: 6px 14px; border-left: 3px solid #0a6ed1; background: #f3f6fa; color: #32363a; }
.kb-inhalt pre, .kb-inhalt code { font-family: Consolas, "Courier New", monospace; font-size: 13px; background: #f3f6fa; border-radius: 4px; }
.kb-inhalt pre { padding: 10px 12px; white-space: pre-wrap; margin: 0 0 10px; } .kb-inhalt code { padding: 1px 4px; }
.kb-inhalt a { color: #0a6ed1; } .kb-inhalt hr { border: none; border-top: 1px solid #c9ced4; margin: 16px 0; }
.kb-inhalt img { max-width: 100%; height: auto; border: 1px solid #c9ced4; border-radius: 4px; margin: 6px 0; cursor: zoom-in; vertical-align: top; }
.kb-inhalt table { width: 100%; border-collapse: collapse; margin: 0 0 12px; background: #fff; }
.kb-inhalt td, .kb-inhalt th { border: 1px solid #c9ced4; padding: 6px 9px; vertical-align: top; font-size: inherit; color: inherit; background: none; text-transform: none; letter-spacing: 0; min-width: 40px; }
.kb-inhalt th { background: #f3f6fa; font-weight: 700; }
.kb-f-montserrat { font-family: "Montserrat", "Segoe UI", Arial, sans-serif; } .kb-f-arial { font-family: Arial, Helvetica, sans-serif; }
.kb-f-calibri { font-family: Calibri, Carlito, "Segoe UI", sans-serif; } .kb-f-times { font-family: "Times New Roman", Times, serif; }
.kb-f-georgia { font-family: Georgia, serif; } .kb-f-verdana { font-family: Verdana, Tahoma, sans-serif; } .kb-f-courier { font-family: "Courier New", Consolas, monospace; }
.kb-s-1, .kb-inhalt font[size="1"] { font-size: 11px; } .kb-s-2, .kb-inhalt font[size="2"] { font-size: 13px; } .kb-s-3, .kb-inhalt font[size="3"] { font-size: 15px; }
.kb-s-4, .kb-inhalt font[size="4"] { font-size: 18px; } .kb-s-5, .kb-inhalt font[size="5"] { font-size: 22px; } .kb-s-6, .kb-inhalt font[size="6"] { font-size: 28px; }
.kb-s-7, .kb-inhalt font[size="7"] { font-size: 36px; }
.kb-c-000000 { color: #000000; } .kb-c-5a6b78 { color: #5a6b78; } .kb-c-c9302c { color: #c9302c; } .kb-c-e9730c { color: #e9730c; } .kb-c-8a6d00 { color: #8a6d00; }
.kb-c-107e3e { color: #107e3e; } .kb-c-0a6ed1 { color: #0a6ed1; } .kb-c-0854a0 { color: #0854a0; } .kb-c-6f42c1 { color: #6f42c1; } .kb-c-ffffff { color: #ffffff; }
.kb-h-fff2a8, .kb-w.kb-wh-fff2a8 { background: #fff2a8; } .kb-h-c8f0d0, .kb-w.kb-wh-c8f0d0 { background: #c8f0d0; } .kb-h-cfe5ff, .kb-w.kb-wh-cfe5ff { background: #cfe5ff; }
.kb-h-ffd6d6, .kb-w.kb-wh-ffd6d6 { background: #ffd6d6; } .kb-h-e6e0f5, .kb-w.kb-wh-e6e0f5 { background: #e6e0f5; }
.kb-w.kb-wc-000000 { background: #000000; } .kb-w.kb-wc-5a6b78 { background: #5a6b78; } .kb-w.kb-wc-c9302c { background: #c9302c; } .kb-w.kb-wc-e9730c { background: #e9730c; } .kb-w.kb-wc-8a6d00 { background: #8a6d00; }
.kb-w.kb-wc-107e3e { background: #107e3e; } .kb-w.kb-wc-0a6ed1 { background: #0a6ed1; } .kb-w.kb-wc-0854a0 { background: #0854a0; } .kb-w.kb-wc-6f42c1 { background: #6f42c1; }
.kb-a-center { text-align: center; } .kb-a-right { text-align: right; } .kb-a-justify { text-align: justify; }
/* Editor */
.kb-werkzeuge { position: sticky; top: 0; z-index: 15; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 8px 12px; background: var(--surface-alt, #f3f6fa); border-bottom: 1px solid var(--border, #c9ced4); }
.kb-w-gruppe { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 3px; padding-right: 10px; border-right: 1px solid var(--border, #c9ced4); }
.kb-w-gruppe:last-of-type { border-right: none; }
.kb-w { font: inherit; font-size: 12.5px; min-width: 30px; height: 30px; padding: 0 8px; background: var(--surface, #ffffff); color: var(--text, #1a1a1a); border: 1px solid var(--border, #c9ced4); border-radius: 5px; cursor: pointer; white-space: nowrap; }
.kb-w:hover { border-color: var(--sap-blue, #0a6ed1); color: var(--sap-blue, #0a6ed1); }
.kb-w.fett { font-weight: 800; } .kb-w.kursiv { font-style: italic; } .kb-w.unter { text-decoration: underline; } .kb-w.durch { text-decoration: line-through; }
.kb-w-sel { width: auto; height: 30px; padding: 0 8px; font-size: 12.5px; }
.kb-w-farben { display: inline-flex; align-items: center; gap: 3px; } .kb-w-text { font-size: 11.5px; color: var(--text-muted, #5a6b78); margin-right: 3px; }
.kb-w.kb-w-farbe { min-width: 0; width: 20px; height: 20px; padding: 0; border-radius: 50%; border: 1px solid rgba(0,0,0,.35); }
.kb-w.kb-w-farbe:hover { outline: 2px solid var(--sap-blue, #0a6ed1); outline-offset: 1px; }
.kb-editor { margin: 0; border: none; border-radius: 0 0 var(--radius, 8px) var(--radius, 8px); min-height: 420px; outline: none; }
.kb-editor:empty::before { content: attr(data-ph); color: #8a8f94; }
.kb-editor img { cursor: default; }

/* ---- gemeinsamer Editor: Rahmen, Höhen, Link-Zeile, Anzeige, Lightbox */
.se-feld { border: 1px solid var(--border, #c9ced4); border-radius: var(--radius, 8px); overflow: hidden; background: #fff; }
.se-feld .se-leiste { position: static; }
.se-feld .kb-editor { border-radius: 0; }
.kb-editor.se-klein { min-height: 120px; max-height: 320px; overflow: auto; padding: 10px 12px; font-size: 14px; }
.kb-editor.se-mittel { min-height: 200px; max-height: 460px; overflow: auto; padding: 14px 16px; }
.kb-editor.se-gross { min-height: 420px; }
.se-gesperrt { opacity: .6; pointer-events: none; }
.se-link { display: flex; flex: 1 1 100%; gap: 6px; align-items: center; }
.se-link[hidden] { display: none; }
.se-link-feld { flex: 1 1 200px; min-width: 0; height: 30px; padding: 0 8px; font: inherit; font-size: 13px; border: 1px solid var(--border, #c9ced4); border-radius: 5px; background: var(--surface, #fff); color: var(--text, #1a1a1a); }
.kb-inhalt.se-anzeige { margin-top: 0; padding: 14px 16px; font-size: 14px; }
.se-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 2000; display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 24px; }
.se-lightbox img { max-width: 100%; max-height: 100%; border-radius: 4px; background: #fff; }
@media (max-width: 640px) {
  .kb-inhalt { padding: 16px 14px; }
  .kb-w-gruppe { border-right: none; padding-right: 0; } .kb-werkzeuge { gap: 6px; padding: 8px; }
  .kb-w { min-width: 36px; height: 36px; } .kb-w-sel { height: 36px; font-size: 16px; } .kb-w.kb-w-farbe { width: 26px; height: 26px; }
  .kb-editor.se-klein, .kb-editor.se-mittel, .kb-editor.se-gross, .se-link-feld { font-size: 16px; }
  .kb-editor.se-gross { min-height: 280px; }
  .se-lightbox { padding: 12px; }
}

/* ---- gespeicherte Filter */
.sf-leiste { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sf-wahl, .sf-name { height: 34px; padding: 0 8px; font: inherit; font-size: 13px; border: 1px solid var(--border, #c9ced4); border-radius: 6px; background: var(--surface, #fff); color: var(--text, #1a1a1a); min-width: 0; }
.sf-wahl { max-width: 240px; } .sf-name { width: 180px; }
.sf-knopf { height: 34px; padding: 0 10px; font: inherit; font-size: 12.5px; font-weight: 600; border: 1px solid var(--border, #c9ced4); border-radius: 6px; background: var(--surface, #fff); color: var(--text, #1a1a1a); cursor: pointer; white-space: nowrap; }
.sf-knopf:hover { border-color: var(--sap-blue, #0a6ed1); color: var(--sap-blue, #0a6ed1); }
.sf-knopf.sf-ok { background: var(--sap-blue, #0a6ed1); border-color: var(--sap-blue, #0a6ed1); color: #fff; }
.sf-knopf[hidden], .sf-eingabe[hidden] { display: none; }
.sf-eingabe { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sf-standard { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-muted, #5a6b78); white-space: nowrap; }
@media (max-width: 640px) {
  .sf-leiste { width: 100%; } .sf-wahl { flex: 1 1 100%; max-width: none; } .sf-name { flex: 1 1 100%; width: auto; }
  .sf-wahl, .sf-name { height: 40px; font-size: 16px; } .sf-knopf { height: 40px; flex: 1 1 auto; }
}

/* ---- Robustheit: Die Bausteine sollen in jeder App gleich aussehen, auch wenn sie allgemeine Regeln für
        input, select, button, label oder Listen hat. */
.kb-w-gruppe { max-width: 100%; }
.kb-w-farben { flex-wrap: wrap; row-gap: 4px; max-width: 100%; }
.kb-w:hover, .sf-knopf:hover { background: var(--surface-hover, #eef2f6); }
.kb-w.kb-w-farbe:hover { background-clip: border-box; }
.kb-inhalt ul { list-style: disc; } .kb-inhalt ol { list-style: decimal; }
.se-link { min-width: 0; flex-wrap: wrap; }
.se-link-feld { width: auto; }
.sf-wahl { width: auto; }
.sf-standard { flex-direction: row; }
.sf-standard input { width: auto; margin: 0; padding: 0; }
.sf-knopf.sf-ok, .sf-knopf.sf-ok:hover { background: var(--sap-blue, #0a6ed1); color: var(--sf-ok-text, #fff); }
@media (max-width: 640px) { .se-link-feld { height: 36px; flex: 1 1 100%; } }

/* ---- Werkzeugleiste am Handy: nur das Wichtigste, der Rest hinter «Mehr» */
.se-mehr-knopf { display: none; }
@media (max-width: 640px) {
  .se-leiste .se-mehr-knopf { display: inline-block; margin-left: auto; }
  .se-leiste:not(.se-offen) .se-mehr { display: none !important; }
}

/* ---- Farben des «Blatts» als Variablen: hell in beiden Designs gedruckt, im dunklen Design am Bildschirm dunkel.
        Steht formatierter Text in einer App auf einem weissen Dokument (Druckansicht, Report), setzt die App dort
        die hellen Werte zurück (siehe .se-hell). */
.kb-inhalt, .se-feld, .se-hell { --se-blatt: #ffffff; --se-schrift: #1a1a1a; --se-kopf: #1c2b3a; --se-flaeche: #f3f6fa; --se-linie: #c9ced4; --se-link: #0a6ed1; --se-schwarz: #000000; }
[data-theme="dark"] .kb-inhalt, [data-theme="dark"] .se-feld { --se-blatt: var(--surface-alt, #232a33); --se-schrift: var(--text, #e6e9ed); --se-kopf: var(--text, #e6e9ed);
  --se-flaeche: rgba(255, 255, 255, .08); --se-linie: var(--border, #3a4350); --se-link: #6cb4ff; --se-schwarz: var(--text, #e6e9ed); }
[data-theme="dark"] .se-hell, [data-theme="dark"] .se-hell .kb-inhalt { --se-blatt: #ffffff; --se-schrift: #1a1a1a; --se-kopf: #1c2b3a; --se-flaeche: #f3f6fa; --se-linie: #c9ced4; --se-link: #0a6ed1; --se-schwarz: #000000; }
@media print { .kb-inhalt { --se-blatt: #ffffff !important; --se-schrift: #1a1a1a !important; --se-kopf: #1c2b3a !important; --se-flaeche: #f3f6fa !important; --se-linie: #c9ced4 !important; --se-link: #0a6ed1 !important; --se-schwarz: #000000 !important; } }
.kb-inhalt { background: var(--se-blatt); color: var(--se-schrift); }
.se-feld { background: var(--se-blatt); }
.kb-inhalt h2, .kb-inhalt h3, .kb-inhalt h4 { color: var(--se-kopf); }
.kb-inhalt blockquote { background: var(--se-flaeche); color: var(--se-schrift); }
.kb-inhalt pre, .kb-inhalt code, .kb-inhalt th { background: var(--se-flaeche); }
.kb-inhalt table { background: var(--se-blatt); }
.kb-inhalt td, .kb-inhalt th, .kb-inhalt img { border-color: var(--se-linie); }
.kb-inhalt hr { border-top-color: var(--se-linie); }
.kb-inhalt a { color: var(--se-link); }
.kb-inhalt .kb-c-000000 { color: var(--se-schwarz); }
.kb-inhalt [class*="kb-h-"] { color: #1a1a1a; }
