/**
 * Editor-Styles: 3-Spalten-Shell, Item-Cards, Toolbars, Toasts, Modals.
 */

/* ── Shell ─────────────────────────────────────────────────────── */
.ed-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h, 56px));
  background: var(--bg, #fafaf7);
  color: var(--fg);
}

.ed-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--bg-elev, rgba(0,0,0,0.03));
  border-bottom: 1px solid var(--line, #e5e5e5);
  flex: 0 0 auto;
}
.ed-back, .ed-toolbar-view {
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(0,0,0,0.05);
}
.ed-back:hover, .ed-toolbar-view:hover { background: rgba(0,0,0,0.1); }
.ed-toolbar-slug {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--kr-red, #c92027);
}
.ed-dirty-flag {
  font-size: 12px;
  color: #ffa500;
  font-weight: 600;
}
.ed-dirty-flag.hidden { display: none; }
.ed-save-btn {
  margin-left: auto;
  background: var(--kr-red, #c92027);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  transition: opacity 0.15s ease;
}
.ed-save-btn:hover { opacity: 0.88; }
.ed-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ed-save-btn.ed-save-dirty { box-shadow: 0 0 0 3px rgba(201,32,39,0.25); }

/* ── 3-Spalten-Cols ────────────────────────────────────────────── */
.ed-cols {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 320px 1fr 1fr;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}
.ed-col {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.ed-col-pool { border-right: 1px solid var(--line, #e5e5e5); }
.ed-col-comp { border-right: 1px solid var(--line, #e5e5e5); }

/* Mobile-Fallback: stack */
@media (max-width: 900px) {
  .ed-cols { grid-template-columns: 1fr; }
  .ed-col-pool, .ed-col-comp { border-right: none; border-bottom: 1px solid var(--line); }
}

/* ── Item-Pool (links) ─────────────────────────────────────────── */
.ed-pool { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.ed-pool-head {
  padding: 12px;
  border-bottom: 1px solid var(--line, #e5e5e5);
}
.ed-pool-head h3 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin: 0 0 8px;
}
#ed-pool-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line, #ccc);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg, #fff);
  color: var(--fg);
  font-family: inherit;
}
.ed-pool-results {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px;
}
.ed-pool-empty, .ed-pool-loading {
  text-align: center;
  color: var(--fg-dim);
  padding: 30px 16px;
  font-size: 13px;
  line-height: 1.5;
}
.ed-pool-empty code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.ed-pool-section-head {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin: 6px 0;
  padding: 4px 8px;
}

.ed-pool-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  padding: 8px;
  align-items: center;
  border-radius: 8px;
  border: 1px solid transparent;
  margin-bottom: 4px;
  position: relative;
}
.ed-pool-card:hover {
  background: rgba(0,0,0,0.04);
  border-color: var(--line, #e5e5e5);
}
.ed-pool-card-img {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.04);
  border-radius: 6px;
  overflow: hidden;
  color: var(--fg-dim);
  font-size: 18px;
}
.ed-pool-card-img img { width: 100%; height: 100%; object-fit: contain; }

.ed-pool-card-body { min-width: 0; }
.ed-pool-card-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.25;
}
.ed-pool-card-meta {
  font-size: 10px;
  color: var(--fg-dim);
  margin-top: 2px;
  display: flex;
  gap: 8px;
}
.ed-pool-card-num {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--kr-red, #c92027);
}
.ed-pool-card-id { font-family: var(--font-display); opacity: 0.6; }
.ed-pool-card-vbadge {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(255, 170, 0, 0.18);
  color: #b87400;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.ed-pool-card-xtag {
  position: absolute;
  top: 2px;
  right: 56px;
  font-size: 9px;
  background: var(--kr-success, #3a82ff);
  color: #fff;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ed-pool-card-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ed-pool-add, .ed-pool-xsell {
  background: var(--kr-red, #c92027);
  color: #fff;
  border: none;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-display);
  transition: opacity 0.15s ease;
}
.ed-pool-add:hover, .ed-pool-xsell:hover { opacity: 0.85; }
.ed-pool-xsell { background: var(--kr-success, #3a82ff); }

/* ── Komposition (Mitte) ───────────────────────────────────────── */
.ed-col-comp { flex: 1 1 auto; min-height: 0; }
#ed-composition {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
}
.ed-comp-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.ed-comp-head h3 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin: 0;
}
.ed-comp-add-target {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-left: auto;
}
.ed-comp-add-target select {
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid var(--line, #ccc);
  background: var(--bg, #fff);
  color: var(--fg);
  font-size: 12px;
}

.ed-page-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(0,0,0,0.03);
  border-radius: 8px;
}
.ed-page-meta label {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  gap: 4px;
}
.ed-page-meta input, .ed-page-meta select {
  padding: 6px 10px;
  border: 1px solid var(--line, #ccc);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg, #fff);
  color: var(--fg);
  font-family: inherit;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.ed-comp-group {
  background: rgba(0,0,0,0.02);
  border: 1px solid var(--line, #e5e5e5);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}
.ed-comp-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.04);
  border-bottom: 1px solid var(--line, #e5e5e5);
}
.ed-comp-group-label {
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex: 1 1 auto;
}
.ed-comp-group-label:hover { color: var(--kr-red, #c92027); }
.ed-comp-group-id {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dim);
  opacity: 0.55;
  font-weight: 500;
  padding: 1px 5px;
  background: rgba(0,0,0,0.05);
  border-radius: 3px;
  cursor: help;
}
.ed-comp-group-count {
  font-size: 11px;
  background: var(--kr-red, #c92027);
  color: #fff;
  border-radius: 12px;
  padding: 1px 8px;
  font-family: var(--font-display);
  font-weight: 700;
}
.ed-comp-group-actions { display: flex; gap: 2px; }
.ed-comp-group-actions button,
.ed-comp-item-actions button {
  background: transparent;
  border: 1px solid transparent;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--fg);
  font-size: 12px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ed-comp-group-actions button:hover,
.ed-comp-item-actions button:hover {
  background: rgba(0,0,0,0.1);
  border-color: var(--line, #ccc);
}
.ed-comp-group-actions button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.ed-comp-items { padding: 4px; }
.ed-comp-empty {
  padding: 16px;
  text-align: center;
  color: var(--fg-dim);
  font-size: 12px;
  font-style: italic;
}

.ed-comp-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 8px;
  padding: 6px 8px;
  align-items: center;
  border-radius: 6px;
}
.ed-comp-item:hover { background: rgba(0,0,0,0.04); }
.ed-comp-item-img {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.04);
  border-radius: 5px;
  overflow: hidden;
  color: var(--fg-dim);
}
.ed-comp-item-img img { width: 100%; height: 100%; object-fit: contain; }
.ed-comp-item-body { min-width: 0; }
.ed-comp-item-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ed-comp-item-title.ed-has-override { color: var(--kr-red, #c92027); }
.ed-comp-item-meta {
  font-size: 10px;
  color: var(--fg-dim);
  display: flex;
  gap: 8px;
  margin-top: 1px;
}
.ed-comp-item-num {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--kr-red, #c92027);
}
.ed-comp-tag-override {
  background: var(--kr-red, #c92027);
  color: #fff;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 9px;
  letter-spacing: 0.04em;
}

/* ── A4-Vorschau (rechts) ───────────────────────────────────────── */
.ed-preview { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.ed-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--line, #e5e5e5);
}
.ed-preview-head h3 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin: 0;
}
.ed-preview-head select {
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid var(--line, #ccc);
  background: var(--bg, #fff);
  color: var(--fg);
  font-size: 12px;
}
.ed-preview-stage {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  overflow: auto;
  background: rgba(0,0,0,0.04);
}
#ed-preview-inner {
  background: var(--bg, #fff);
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1 / 1.414;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  overflow: hidden;
}
#ed-preview-inner .cp-page {
  width: 100% !important;
  height: 100% !important;
}

/* ── Editor-Index ──────────────────────────────────────────────── */
.ed-index { padding-top: 24px; }
.ed-index-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 24px;
}
.ed-index-head h1 {
  font-family: var(--font-display);
  font-size: 28px;
  margin: 0;
}
.ed-index-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg, #fff);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.ed-index-table th, .ed-index-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--line, #e5e5e5);
  font-size: 13px;
}
.ed-index-table th {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  background: rgba(0,0,0,0.03);
}
.ed-index-table tr:last-child td { border-bottom: none; }
.ed-index-table code {
  background: rgba(0,0,0,0.05);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.ed-btn-sm {
  padding: 5px 11px;
  border-radius: 5px;
  font-size: 12px;
  border: 1px solid var(--line, #ccc);
  background: var(--bg, #fff);
  color: var(--fg);
  text-decoration: none;
  display: inline-block;
  margin-right: 4px;
  cursor: pointer;
  font-family: inherit;
}
.ed-btn-sm:hover { background: rgba(0,0,0,0.06); }
.ed-btn-primary {
  background: var(--kr-red, #c92027);
  color: #fff;
  border-color: var(--kr-red, #c92027);
  font-weight: 600;
}
.ed-btn-primary:hover { opacity: 0.88; background: var(--kr-red, #c92027); }
.ed-btn-danger {
  background: transparent;
  color: var(--kr-red, #c92027);
  border-color: var(--kr-red, #c92027);
}
.ed-btn-danger:hover { background: var(--kr-red, #c92027); color: #fff; }

/* ── Toasts ────────────────────────────────────────────────────── */
#ed-toast-stack {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.ed-toast {
  background: var(--bg-elev, #fff);
  color: var(--fg);
  padding: 10px 16px;
  border-radius: 8px;
  border-left: 4px solid var(--fg-dim);
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  min-width: 200px;
  max-width: 360px;
  pointer-events: auto;
  animation: ed-toast-in 0.2s ease;
}
.ed-toast-success { border-left-color: #3a82ff; }
.ed-toast-warn { border-left-color: #ffa500; }
.ed-toast-error { border-left-color: var(--kr-red, #c92027); }
.ed-toast-out { opacity: 0; transform: translateX(20px); transition: all 0.25s ease; }
@keyframes ed-toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── „Edit"-Button auf Page-View ───────────────────────────────── */
.cp-edit-link {
  display: inline-block;
  font-size: 11px;
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: rgba(58,130,255,0.1);
  color: var(--kr-success, #3a82ff);
  padding: 3px 10px;
  border-radius: 4px;
  text-decoration: none;
  margin-left: auto;
  font-weight: 600;
}
.cp-edit-link:hover { background: var(--kr-success, #3a82ff); color: #fff; }

/* ── Print-Modus: Editor komplett verbergen ────────────────────── */
@media print {
  .ed-shell, #ed-toast-stack { display: none !important; }
}

/* ============ Move-Item-Modal ============ */
.ed-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 14, 16, 0.55);
  backdrop-filter: blur(2px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ed-modal-fade 0.15s ease-out;
}
@keyframes ed-modal-fade { from { opacity: 0; } to { opacity: 1; } }
.ed-modal {
  background: var(--kr-paper, #fafaf7);
  color: var(--kr-ink, #1a1a1a);
  border-radius: 8px;
  padding: 24px;
  min-width: 360px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.ed-modal-title {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--kr-red, #c92027);
}
.ed-modal-body { font-size: 14px; line-height: 1.5; }
.ed-modal-body code {
  background: #f0f0eb;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 13px;
}
.ed-modal-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ed-modal-choice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #d8d8d2;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: all 0.12s ease;
}
.ed-modal-choice:hover {
  background: var(--kr-red, #c92027);
  color: #fff;
  border-color: var(--kr-red, #c92027);
  transform: translateX(2px);
}
.ed-modal-choice .choice-label { font-weight: 600; }
.ed-modal-choice .choice-count {
  font-size: 12px;
  opacity: 0.7;
}
.ed-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.ed-modal-cancel {
  padding: 8px 18px;
  background: transparent;
  border: 1px solid #999;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.ed-modal-cancel:hover { background: #eee; }

/* ============ Sync-Check-Button + Modal ============ */
.ed-sync-btn {
  background: rgba(58, 130, 255, 0.12);
  border: 1px solid rgba(58, 130, 255, 0.3);
  color: #1e5fc4;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ed-sync-btn:hover:not(:disabled) {
  background: rgba(58, 130, 255, 0.22);
}
.ed-sync-btn:disabled { opacity: 0.6; cursor: wait; }
.ed-modal-wide { min-width: min(720px, 95vw); max-width: 95vw; }
.ed-sync-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.ed-sync-stat {
  flex: 1 1 0;
  min-width: 110px;
  padding: 10px 14px;
  border-radius: 6px;
  background: #f0f0eb;
  text-align: center;
  font-size: 12px;
  color: #555;
}
.ed-sync-stat strong { font-size: 22px; display: block; color: #1a1a1a; line-height: 1; margin-bottom: 4px; }
.ed-sync-stat-ok { background: rgba(58, 130, 255, 0.14); color: #1e5fc4; }
.ed-sync-stat-ok strong { color: #1e5fc4; }
.ed-sync-stat-orphan { background: rgba(255, 100, 100, 0.14); color: #b81a1f; }
.ed-sync-stat-orphan strong { color: #b81a1f; }
.ed-sync-stat-fixable { background: rgba(255, 170, 0, 0.18); color: #b87400; }
.ed-sync-stat-fixable strong { color: #b87400; }
.ed-sync-section h3 {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin: 0 0 6px 0;
}
.ed-sync-section-warn h3 { color: #b81a1f; }
.ed-sync-hint {
  font-size: 12px;
  color: #666;
  margin: 0 0 8px 0;
  line-height: 1.4;
}
.ed-sync-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.ed-sync-table th, .ed-sync-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e0e0db;
  text-align: left;
  vertical-align: middle;
}
.ed-sync-table th {
  background: #f0f0eb;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
}
.ed-sync-table code {
  background: #f0f0eb;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.ed-sync-unfix-reason { color: #b81a1f; font-style: italic; }
.ed-modal-confirm {
  padding: 8px 18px;
  background: var(--kr-red, #c92027);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.ed-modal-confirm:hover:not(:disabled) { opacity: 0.88; }
.ed-modal-confirm:disabled { opacity: 0.5; cursor: wait; }
