/* ═══════════════════════════════════════════════════════════
   PDF-Editor — wiederverwendbares Modul
   Wird sowohl von Posteingang-KI-Tool.html als auch von
   DMS-System.html eingebunden. Nutzt CSS-Variablen aus dem
   einbettenden Dokument (--surface, --border, --green, ...).
   ═══════════════════════════════════════════════════════════ */

/* ── PDF EDITOR MODAL ─────────────────────────────── */
#pdf-editor-modal .modal-box {
  width: 98vw; max-width: 1200px; height: 96vh;
}
.editor-layout {
  display: flex; height: 100%; overflow: hidden;
}
/* Left: tools panel */
.editor-tools {
  width: 250px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  background: var(--surface2); overflow-y: auto;
}
.editor-tools-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.editor-tools-section h4 {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.tool-btn {
  display: flex; align-items: center; gap: 7px;
  width: 100%; padding: 6px 8px; margin-bottom: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 2px; cursor: pointer; font-size: 12px;
  font-family: 'IBM Plex Sans', sans-serif; color: var(--text);
  transition: all 0.15s; text-align: left;
}
.tool-btn:hover { background: var(--surface2); border-color: var(--border2); }
.tool-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tool-btn.danger { color: var(--red); border-color: var(--red); }
.tool-btn.danger:hover { background: #fff0f0; }
.tool-btn .tool-icon { font-size: 14px; flex-shrink: 0; }
/* Quality sliders */
.slider-row { margin-bottom: 8px; }
.slider-row label {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text2); margin-bottom: 3px;
  font-family: 'IBM Plex Mono', monospace;
}
.slider-row label span { color: var(--green); font-weight: 600; }
.slider-row input[type=range] {
  width: 100%; accent-color: var(--green);
}
.quality-apply-btn {
  width: 100%; padding: 6px; background: var(--green);
  color: white; border: none; border-radius: 2px;
  font-size: 12px; cursor: pointer; margin-top: 4px;
  font-family: 'IBM Plex Sans', sans-serif; transition: background 0.15s;
}
.quality-apply-btn:hover { background: var(--green-dark, #166348); }
/* Right: pages canvas */
.editor-pages {
  flex: 1; overflow-y: auto; padding: 16px;
  background: #E8E8E4;
  display: flex; flex-wrap: wrap;
  align-content: flex-start; gap: 12px;
}
.editor-page-wrap {
  position: relative; cursor: pointer;
  transition: transform 0.15s;
  user-select: none;
}
.editor-page-wrap:hover { transform: scale(1.02); }
.editor-page-wrap.selected .editor-page-canvas {
  outline: 3px solid var(--green);
}
.editor-page-wrap.deleted { opacity: 0.3; }
.editor-page-wrap.deleted .editor-page-canvas {
  outline: 3px solid var(--red);
}
.editor-page-canvas {
  display: block; border: 1px solid var(--border2);
  border-radius: 2px; background: white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
/* Notizen-Werkzeug aktiv: Cursor zeigt Klick-Bereitschaft */
.editor-page-wrap.note-mode-active { cursor: crosshair; }
.editor-page-wrap.note-mode-active .editor-page-canvas { cursor: crosshair; }
/* Notiz-Etikett: gelb hinterlegter Text direkt auf der Seite */
.editor-note-label {
  position: absolute;
  background: #FFE99B;
  border: 1.5px solid #D4A017;
  border-radius: 3px;
  padding: 3px 6px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 11px;
  color: #1A1A18;
  line-height: 1.3;
  max-width: 280px;
  word-wrap: break-word;
  white-space: pre-wrap;
  cursor: move;
  user-select: none;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.editor-note-label:hover {
  border-color: #1A1A18;
  z-index: 6;
}
.editor-note-label.empty {
  background: rgba(255, 233, 155, 0.5);
  border-style: dashed;
  font-style: italic;
  color: #6B6B66;
  min-width: 60px;
}
.editor-note-label .note-del {
  position: absolute;
  top: -8px; right: -8px;
  width: 16px; height: 16px;
  background: var(--red);
  color: white;
  border-radius: 50%;
  font-size: 11px; font-weight: bold;
  line-height: 1;
  display: none;
  align-items: center; justify-content: center;
  cursor: pointer;
  border: none;
}
.editor-note-label:hover .note-del { display: flex; }
.editor-note-label .note-del:hover { background: #C82020; }

/* Edit-Popup für Notiz-Text */
.editor-note-popup {
  position: fixed;
  z-index: 1100;
  width: 240px;
  background: #FFE99B;
  border: 2px solid #D4A017;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  padding: 8px;
  font-family: 'IBM Plex Sans', sans-serif;
}
.editor-note-popup textarea {
  width: 100%;
  min-height: 70px;
  border: none;
  background: transparent;
  outline: none;
  resize: vertical;
  font-family: inherit;
  font-size: 12px;
  color: #1A1A18;
  line-height: 1.4;
}
.editor-note-popup .popup-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(212,160,23,0.4);
}
.editor-note-popup .popup-footer button {
  background: transparent;
  border: 1px solid #D4A017;
  color: #5A4000;
  border-radius: 3px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}
.editor-note-popup .popup-footer button:hover { background: rgba(255,255,255,0.5); }
.editor-note-popup .popup-footer .popup-delete {
  border-color: var(--red);
  color: var(--red);
}
.editor-note-popup .popup-footer .popup-delete:hover {
  background: var(--red);
  color: white;
}
.editor-page-num {
  text-align: center; font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; color: var(--text3); margin-top: 4px;
}
.page-overlay-btns {
  position: absolute; top: 4px; right: 4px;
  display: none; gap: 3px;
}
.editor-page-wrap:hover .page-overlay-btns,
.editor-page-wrap.selected .page-overlay-btns { display: flex; }
.page-ov-btn {
  width: 22px; height: 22px; border-radius: 2px;
  border: none; cursor: pointer; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(26,26,24,0.75); color: white;
  transition: background 0.15s;
}
.page-ov-btn:hover { background: rgba(26,26,24,0.95); }
.page-ov-btn.del { background: rgba(180,40,40,0.85); }
.page-ov-btn.del:hover { background: rgba(180,40,40,1); }
/* Editor footer */
.editor-footer {
  padding: 10px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface2); flex-shrink: 0; gap: 10px;
}
.editor-info {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--text3);
}
.editor-info span { color: var(--green); font-weight: 600; }

/* ── CROP MODAL ──────────────────────────────────── */
#crop-modal {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(0,0,0,0.85);
  display: none; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
}
#crop-modal.open { display: flex; }
#crop-container {
  position: relative; cursor: crosshair;
  user-select: none; -webkit-user-select: none;
}
#crop-img { display: block; max-width: 90vw; max-height: 75vh; }
#crop-overlay {
  position: absolute; inset: 0; pointer-events: none;
}
#crop-rect {
  position: absolute;
  border: 2px solid #5DC8A0;
  background: rgba(93,200,160,0.15);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
  display: none;
}
.crop-footer {
  display: flex; gap: 12px; align-items: center;
}
.crop-info {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  color: #9B9B95;
}

/* ─── STEMPEL (Etappe 13) ───────────────────────────────────────── */
.editor-page-wrap.stamp-mode-active { cursor: crosshair; }
.editor-page-wrap.stamp-mode-active .editor-page-canvas { cursor: crosshair; }

.editor-stamp {
  position: absolute;
  background: rgba(255, 255, 255, 0.5);
  padding: 6px 12px;
  border-style: double;
  border-radius: 3px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  text-align: center;
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
  letter-spacing: 0.06em;
  z-index: 8;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: opacity 0.15s;
  outline: 1px solid rgba(255,255,255,0.4);
  outline-offset: 2px;
}
.editor-stamp:hover {
  filter: brightness(1.05);
}
.editor-stamp .es-text {
  font-size: 13px;
  line-height: 1.1;
  white-space: nowrap;
}
.editor-stamp .es-date {
  font-size: 9px;
  margin-top: 2px;
  opacity: 0.85;
}
.editor-stamp .es-del {
  position: absolute;
  top: -6px; right: -6px;
  width: 16px; height: 16px;
  background: #C0392B;
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
  line-height: 1;
  padding: 0;
}
.editor-stamp:hover .es-del { display: flex; }
.editor-stamp .es-del:hover { background: #a02f24; }

/* ─── TOAST-NOTIFICATION (Bugfix) ───────────────────────────────────
   Der Toast wird nach 3s mit opacity:0 ausgeblendet, bleibt aber als
   unsichtbares Element im DOM mit z-index:9999. Ohne pointer-events:none
   blockiert er Klicks auf darunterliegende Footer-Buttons (z.B.
   "Änderungen übernehmen"). Wird inline im JS gesetzt — diese Regel
   fängt zusätzlich ab, falls eine eigene cfg.toast-Implementierung
   das vergisst. */
#editor-toast {
  pointer-events: none;
}

/* ─── STEMPEL-EDITOR-MODAL (Etappe 13.1) ────────────────────────── */
.stamp-edit-grid {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px 12px;
  align-items: center;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 12px;
}
.stamp-edit-grid label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stamp-edit-grid input[type="text"],
.stamp-edit-grid input[type="date"] {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: inherit;
  font-size: 12px;
  width: 100%;
  box-sizing: border-box;
}
.stamp-edit-grid input[type="color"] {
  width: 56px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  background: white;
}
.stamp-edit-grid input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}
.stamp-edit-slider-row {
  display: flex; align-items: center; gap: 8px;
}
.stamp-edit-slider-row span {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--green);
  font-weight: 600;
  min-width: 44px;
  text-align: right;
}
.stamp-edit-grid .toggle-row {
  display: flex; align-items: center; gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  cursor: pointer;
}
#stamp-edit-preview-box {
  background: #E8E8E4;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  margin-bottom: 14px;
}

/* Modal-Container-Style für Stempel-Modals (.modal-content ist im DMS-System nicht definiert) */
#stamp-edit-modal .modal-content,
#stamp-confirm-modal .modal-content,
#stamp-picker-modal .modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#stamp-edit-modal .modal-header,
#stamp-confirm-modal .modal-header,
#stamp-picker-modal .modal-header {
  padding: 10px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#stamp-edit-modal .modal-title,
#stamp-confirm-modal .modal-title,
#stamp-picker-modal .modal-title {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
#stamp-edit-modal .modal-close,
#stamp-confirm-modal .modal-close,
#stamp-picker-modal .modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text3);
  padding: 4px 8px;
  line-height: 1;
}
#stamp-edit-modal .modal-close:hover,
#stamp-confirm-modal .modal-close:hover,
#stamp-picker-modal .modal-close:hover {
  color: var(--text);
}
