/*
 * Inline-Bearbeitung auf der öffentlichen Live-Seite (nur für eingeloggte Admins).
 * Standardmäßig unsichtbar: Stifte/Marker erscheinen erst, wenn der Edit-Modus
 * aktiv ist (body.ff-editing). Für nicht-Admins wird gar nichts gerendert.
 */

/* Schwebender Umschalter unten rechts */
.ff-edit-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.ff-edit-toggle:hover { filter: brightness(1.07); }
body.ff-editing .ff-edit-toggle { background: #2d3a4a; }

/* Markierung editierbarer Felder – nur im Edit-Modus sichtbar */
.ff-ie-target { position: relative; }
body.ff-editing .ff-ie-target {
  outline: 2px dashed var(--primary-ring);
  outline-offset: 3px;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.12s ease;
}
body.ff-editing .ff-ie-target:hover {
  background: var(--primary-wash);
}
body.ff-editing .ff-ie-target::after {
  content: "✏️";
  position: absolute;
  top: -10px;
  right: -10px;
  font-size: 0.8rem;
  line-height: 1;
  padding: 3px 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* Stift-Button am Artikel (Inhaltsseiten) */
.ff-article-pen {
  display: none;
  align-items: center;
  gap: 6px;
  margin: 12px 0;
  padding: 8px 14px;
  border: 1px solid var(--primary-ring);
  border-radius: var(--radius);
  background: var(--primary-wash);
  color: var(--primary-soft);
  font-weight: 600;
  cursor: pointer;
}
body.ff-editing .ff-article-pen { display: inline-flex; }
.inline-page-editor { margin-top: 16px; }

/* Modal-Editor für Einstellungen */
.ff-ie-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  padding: 16px;
}
/* Der Dialog steht auf der dunklen Public-Oberflaeche. Feste Hellwerte hier
   machten .btn-ghost (color: var(--text-strong) = #fff) unsichtbar. */
.ff-ie-box {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-lg);
}
.ff-ie-head { font-weight: 700; margin-bottom: 12px; font-size: 1.05rem; color: var(--text-strong); }
.ff-ie-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-3);
  font: inherit;
  color: var(--text-strong);
}
.ff-ie-input:focus-visible {
  outline: 2px solid var(--admin-focus, var(--primary));
  outline-offset: 1px;
  border-color: transparent;
}
textarea.ff-ie-input { resize: vertical; min-height: 96px; }
.ff-ie-msg { min-height: 18px; margin: 8px 0 0; font-size: 0.85rem; color: var(--primary-soft); }
.ff-ie-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

/* Aktions-Spalte der Medienliste (Details + Löschen nebeneinander) */
.media-actions-cell { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.media-actions-cell .inline-form { margin: 0; }

/*
 * Block-Editor & Medien-Picker werden auf der öffentlichen (dunklen) Seite
 * eingeblendet. Der Editor wurde mit hartkodierten weißen Flächen für die helle
 * Admin-Oberfläche gebaut. Auf public-surface stellen wir diese auf die dunklen
 * Theme-Oberflächen (--surface*/--line/--text*) um, damit der Editor integriert
 * statt aufgesetzt wirkt. Der Admin-Editor (admin-surface) bleibt unberührt.
 */
body.public-surface .inline-page-editor {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 10px);
  padding: 16px;
  box-shadow: var(--shadow-lg, 0 12px 40px rgba(0, 0, 0, 0.45));
}
body.public-surface .pe-block {
  background: var(--surface-2);
  border-color: var(--line);
  box-shadow: none;
}
body.public-surface .pe-block-head {
  background: var(--surface-3);
  border-bottom-color: var(--line);
}
body.public-surface .pe-block-type { color: var(--text-strong); }

/* Eingabefelder als dunkle, eingelassene Flächen */
body.public-surface .page-editor input[type="text"],
body.public-surface .page-editor textarea,
body.public-surface .page-editor select,
body.public-surface .pe-rich,
body.public-surface .pe-table-grid input {
  background: var(--bg);
  color: var(--text-strong);
  border-color: var(--line);
}
body.public-surface .pe-rich:empty::before { color: var(--muted); }
body.public-surface .pe-add { border-top-color: var(--line); }

body.public-surface .pe-preview {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}
body.public-surface .pe-thumb { background: var(--surface-3); border-color: var(--line); }
body.public-surface .pe-table-grid td { border-color: var(--line); }

/* Medien-Picker (Modal wird an <body> angehängt, daher separat) */
body.public-surface .pe-modal-box { background: var(--surface); color: var(--text); }
body.public-surface .pe-modal-head { border-bottom-color: var(--line); }
body.public-surface .pe-picker-cell { background: var(--surface-2); border-color: var(--line); }
body.public-surface .pe-picker-cell span { color: var(--text-soft); }

/* =========================================================================
   „Startseite anpassen"-Modus (home-editor.js) — Widget-Editor
   ========================================================================= */
.ffh-customize-toggle { bottom: 76px; }

/* Deck macht rechts Platz für den Drawer */
body.ffh-customizing .ffh-deck { margin-right: 330px; }
body.ffh-customizing .footer { display: none; }

/* Editierbare Kacheln */
.ffh-w-editable {
  outline: 1.5px dashed var(--primary-ring, rgba(232, 50, 63, .45));
  outline-offset: 4px;
  cursor: grab;
  overflow: visible;
}
.ffh-w-editable:active { cursor: grabbing; }
.ffh-w-dragging { opacity: .45; }

.ffh-w-name {
  position: absolute;
  top: -13px;
  left: 16px;
  z-index: 6;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 4px 13px;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-soft);
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
.ffh-w-controls {
  position: absolute;
  top: -14px;
  right: 14px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 3px 5px;
  box-shadow: var(--shadow-md);
}
.ffh-w-sizes { display: flex; gap: 2px; background: var(--surface); border-radius: var(--radius-pill); padding: 2px; }
.ffh-w-sizes button {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 3px 9px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}
.ffh-w-sizes button.on { background: var(--primary-wash); color: var(--primary-soft); }
.ffh-w-hide {
  width: 24px; height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.ffh-w-hide:hover { background: var(--primary-wash); color: var(--primary-soft); }

/* Ghost-Kachel (frisch eingeblendet, Inhalt kommt nach dem Speichern) */
.ffh-tile--ghost {
  border-style: dashed;
  border-color: var(--primary-ring);
  background: var(--primary-wash);
  min-height: 160px;
}
.ffh-ghost-inner {
  margin: auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ffh-ghost-inner b { color: var(--primary-soft); font-size: 14.5px; }
.ffh-ghost-inner span { color: var(--muted); font-size: 12px; }

/* Drawer rechts */
.ffh-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 316px;
  z-index: 120;
  background: color-mix(in srgb, var(--bg) 92%, #000);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 50px rgba(0, 0, 0, .45);
  display: flex;
  flex-direction: column;
  padding: 20px;
}
.ffh-drawer-head h2 { font-size: 16px; font-weight: 750; color: var(--text-strong); margin: 0 0 6px; }
.ffh-drawer-head p { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin: 0 0 16px; }
.ffh-drawer-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.ffh-drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid var(--line-soft);
  background: var(--surface);
}
.ffh-drawer-item.is-off { opacity: .55; }
.ffh-drawer-txt { min-width: 0; }
.ffh-drawer-txt b { display: block; font-size: 13.5px; font-weight: 650; color: var(--text-strong); }
.ffh-drawer-txt span { font-size: 11px; color: var(--muted); }
.ffh-switch {
  margin-left: auto;
  width: 36px; height: 21px;
  flex: 0 0 auto;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
}
.ffh-switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--muted);
  transition: left .15s, background .15s;
}
.ffh-switch.on { background: color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary-ring); }
.ffh-switch.on::after { left: 17px; background: var(--primary-soft); }
.ffh-drawer-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
  margin-top: 14px;
}
/* „Fertig“ prominent in voller Breite, Sekundäraktionen darunter */
.ffh-drawer-foot .btn-primary { flex: 1 1 100%; order: -1; justify-content: center; }
.ffh-drawer-foot .btn-ghost { flex: 1 1 auto; justify-content: center; font-size: 12.5px; padding: 8px 12px; }
.ffh-drawer-spacer { display: none; }
