/* ═══════════════════════════════════════════════════════════════
   BE:KI Direct – Word-Light-Editor (portiert aus BE:KI Frame)
   Ribbon-Interface, A4-Seitenansicht, Druck- und .docx-Export.
   ═══════════════════════════════════════════════════════════════ */

#word-editor-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: #d0d4d8;
  margin: -28px -28px -48px;
}

.schr-editor-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #dde3ec;
}

.schr-text-erstellen {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #dde3ec;
}
.schr-text-erstellen .form-group { flex: 1; margin-bottom: 0; }
.schr-text-erstellen textarea { resize: vertical; min-height: 40px; }

#result-loading {
  position: absolute;
  inset: 0;
  background: rgba(208,212,216,.88);
  z-index: 200;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 13.5px;
  color: #6b7a8d;
}
#result-loading .spin { animation: we-spin 1s linear infinite; }
@keyframes we-spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════
   RIBBON
   ══════════════════════════════════════════════════════════════ */
#ribbon {
  flex-shrink: 0;
  background: #f4f7fb;
  border-bottom: 2px solid rgba(22,72,166,.4);
  position: relative;
  z-index: 10;
}

#ribbon-tabs {
  display: flex;
  align-items: stretch;
  background: rgba(22,72,166,.68);
  backdrop-filter: blur(8px);
  height: 30px;
}

.rtab {
  padding: 0 16px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,.75);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .02em;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.rtab:hover { background: rgba(255,255,255,.12); color: #fff; }
.rtab.rtab-active {
  background: #f4f7fb;
  color: var(--navy);
  border-radius: 4px 4px 0 0;
  margin-top: 3px;
}

.ribbon-panel {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 8px;
  min-height: 60px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: visible;
}

.rgroup {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 4px 8px 4px;
}
.rgroup-btns { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.rgroup-label { font-size: 9.5px; color: #9ba8bb; text-align: center; width: 100%; letter-spacing: .03em; }

.rsep { width: 1px; background: #dde3ec; align-self: stretch; margin: 4px 2px; flex-shrink: 0; }

.rb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1px;
  min-width: 30px;
  height: 34px;
  padding: 0 6px;
  border: 1.5px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #1e293b;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background .1s, border-color .1s;
  white-space: nowrap;
  flex-shrink: 0;
}
#ribbon .rb svg { width: 18px; height: 18px; }
.rb:hover { background: #e8eef8; border-color: #c8d4ea; }
.rb.rb-active { background: #dce8f8; border-color: var(--navy); color: var(--navy); }
.rb:disabled { opacity: .4; cursor: not-allowed; }

.rb.rb-large, .rb.rb-action {
  flex-direction: column;
  height: 50px;
  min-width: 50px;
  padding: 4px 7px;
  font-size: 11px;
  gap: 3px;
}
.rb.rb-large span, .rb.rb-action span { font-size: 10.5px; color: #4b5a6e; }
.rb.rb-large:hover span, .rb.rb-action:hover span { color: var(--navy); }
.rb.rb-action.copied { border-color: var(--teal-d); background: #f0faf5; }
#ribbon .rb.rb-large svg, #ribbon .rb.rb-action svg { width: 20px; height: 20px; }

.rs {
  height: 26px;
  border: 1.5px solid #dde3ec;
  border-radius: 4px;
  background: #fff;
  color: #1e293b;
  font-size: 12px;
  cursor: pointer;
  padding: 0 4px;
  font-family: inherit;
  transition: border-color .12s;
}
.rs:hover, .rs:focus { border-color: var(--navy); outline: none; }
.rs-font  { min-width: 96px; max-width: 110px; }
.rs-size  { width: 44px; }
.rs-style { min-width: 110px; }

.rb-color-wrap { display: inline-flex; border: 1.5px solid transparent; border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.rb-color-wrap:hover { border-color: #c8d4ea; background: #e8eef8; }
.rb-color-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; padding: 0 3px; border: none; background: transparent; cursor: pointer; gap: 1px;
}
.rb-color-arrow {
  width: 13px; height: 26px; border: none; border-left: 1px solid #dde3ec;
  background: transparent; font-size: 9px; cursor: pointer; color: #6b7a8d; padding: 0;
}
.rb-color-arrow:hover { background: #dce8f8; }

.rb-dropdown-wrap { position: relative; }
.rb-dropdown {
  position: fixed;
  background: #fff;
  border: 1.5px solid #dde3ec;
  border-radius: 8px;
  padding: 4px 0;
  min-width: 160px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 9200;
}
.rdd-item { padding: 7px 14px; font-size: 12.5px; cursor: pointer; color: #1e293b; transition: background .1s; }
.rdd-item:hover { background: #eef4ff; }
.rdd-item.rb-dd-active { color: var(--navy); font-weight: 600; }

/* ── Lineal ──────────────────────────────────────────────────── */
#ruler { background: #e8ecf0; border-bottom: 1px solid #c8d0dc; padding: 2px 0; flex-shrink: 0; overflow: hidden; }
#ruler-inner {
  width: 210mm; height: 18px; margin: 0 auto; background: #fff;
  border: 1px solid #c8d0dc; border-radius: 2px; position: relative;
  background: linear-gradient(to bottom, #f4f7fb 0%, #fff 100%);
}

/* ── Seitenbereich ───────────────────────────────────────────── */
#editor-page-area {
  flex: 1;
  overflow-y: auto;
  padding: 28px 0 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #d0d4d8;
  transform-origin: top center;
}

#editor-page {
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,.22);
  border-radius: 1px;
  padding: 2.5cm;
  box-sizing: border-box;
  flex-shrink: 0;
  transition: padding .2s;
  position: relative;
}

#tiptap-editor {
  outline: none;
  min-height: 200px;
  font-family: Calibri, sans-serif;
  font-size: 12pt;
  line-height: 1.5;
  color: #1e293b;
  caret-color: var(--navy);
  word-break: break-word;
}
#tiptap-editor:focus { outline: none; }
#tiptap-editor .ProseMirror { outline: none !important; border: none !important; box-shadow: none !important; }
#tiptap-editor ::selection { background-color: rgba(22,72,166,.18); color: inherit; }
#tiptap-editor p { margin: 0 0 0.5em; }
#tiptap-editor h1 { font-size: 2em;   font-weight: 700; margin: .5em 0 .3em; color: var(--navy); }
#tiptap-editor h2 { font-size: 1.5em; font-weight: 700; margin: .4em 0 .25em; color: var(--navy-d); }
#tiptap-editor h3 { font-size: 1.2em; font-weight: 700; margin: .35em 0 .2em; color: #1e293b; }
#tiptap-editor ul, #tiptap-editor ol { padding-left: 1.6em; margin: .3em 0; }
#tiptap-editor li { margin-bottom: .15em; }
#tiptap-editor blockquote { border-left: 3px solid var(--navy); margin: .5em 0; padding: .3em 1em; color: #4b5a6e; font-style: italic; }
#tiptap-editor code { font-family: 'Courier New', monospace; background: #f4f7fb; border: 1px solid #dde3ec; border-radius: 3px; padding: 1px 4px; font-size: .9em; }
#tiptap-editor pre { background: #f4f7fb; border: 1px solid #dde3ec; border-radius: 6px; padding: 12px 16px; overflow-x: auto; }
#tiptap-editor hr { border: none; border-top: 2px solid #dde3ec; margin: 1em 0; }
#tiptap-editor table { border-collapse: collapse; width: 100%; margin: 1em 0; }
#tiptap-editor td, #tiptap-editor th { border: 1px solid #aaa; padding: 6px 10px; min-width: 60px; vertical-align: top; }
#tiptap-editor th { background: #eef4ff; font-weight: 700; }
#tiptap-editor td.selectedCell, #tiptap-editor th.selectedCell { background: rgba(22,72,166,.08); }
#tiptap-editor img { max-width: 100%; height: auto; display: block; margin: 6px 0; cursor: pointer; border-radius: 2px; }
#tiptap-editor img.ProseMirror-selectednode { outline: 2px solid var(--navy); }
#tiptap-editor mark { padding: 0.06em 0.12em; border-radius: 2px; mix-blend-mode: multiply; }

/* ── Überarbeiten-Bereich (KI) ─────────────────────────────────── */
#revision-section { width: 210mm; margin-top: 20px; flex-shrink: 0; margin-bottom: 20px; }
.revision-label { font-size: 12px; font-weight: 600; color: #6b7a8d; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.revision-inner { display: flex; gap: 10px; align-items: flex-end; background: #fff; border: 1.5px solid #dde3ec; border-radius: 12px; padding: 14px 16px; }
.revision-inner textarea { flex: 1; min-height: 44px; max-height: 120px; }

/* ── Statusleiste ──────────────────────────────────────────────── */
#status-bar {
  display: flex;
  align-items: center;
  padding: 4px 16px;
  background: rgba(22,72,166,.68);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
  gap: 8px;
}
.sb-zoom-btn {
  width: 22px; height: 22px; border: 1.5px solid rgba(255,255,255,.3); border-radius: 4px;
  background: rgba(255,255,255,.1); color: #fff; font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sb-zoom-btn:hover { background: rgba(255,255,255,.2); }
#zoom-label { color: #fff !important; }
#word-count { color: rgba(255,255,255,.65) !important; }

/* ── Find & Replace / Custom-Margin Modals (leichtgewichtig) ───── */
.we-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 9300; display: none; align-items: center; justify-content: center;
}
.we-modal-box {
  background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}
.we-modal-box h3 { font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 14px; }
.we-modal-box .form-actions { margin-top: 14px; }

/* ── Drucklayout ─────────────────────────────────────────────── */
@media print {
  body > *:not(#page-outlet) { display: none !important; }
  #sidebar, #topbar, #app-footer, #sidebar-overlay { display: none !important; }
  #page-outlet { padding: 0 !important; margin: 0 !important; overflow: visible !important; }
  #word-editor-wrap { background: none !important; position: static !important; margin: 0 !important; }
  #ribbon, #ruler, #revision-section, #result-loading, #status-bar { display: none !important; }
  #editor-page-area { padding: 0 !important; overflow: visible !important; display: block !important; transform: none !important; background: none !important; }
  #editor-page { width: 100% !important; min-height: auto !important; box-shadow: none !important; padding: 2cm !important; border-radius: 0 !important; }
}

@media (max-width: 900px) {
  #editor-page, #revision-section { width: 100%; }
  #ruler-inner { width: 100%; }
  .rs-font { min-width: 80px; }
}
