/* ═══════════════════════════════════════════════════════════════════════════
   AKQUIX PREMIUM EMAIL COMPOSER — Shared Component CSS
   Datei: frontend/static/components/email_composer.css
   Ergänzt die bestehenden .ec-* Klassen in crm-contact-v3.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Premium Toolbar Überschreibung ───────────────────────────────────────── */
.ec-toolbar {
  flex-wrap: wrap;
  gap: 1px;
  padding: 5px 12px;
  background: var(--surface3, #f8fafc);
  border-bottom: 1px solid var(--border2, #e5e7eb);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* Toolbar Dropdown (Überschriften) */
.ec-tbtn-dd {
  position: relative;
  display: inline-flex;
}
.ec-tbtn-dd-menu {
  display: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  z-index: 500;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  min-width: 170px;
  padding: 4px;
}
.ec-tbtn-dd-menu.open { display: block; }
.ec-tbtn-dd-item {
  display: block;
  width: 100%;
  padding: 6px 11px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-size: 12.5px;
  color: var(--text, #0f172a);
  border-radius: 5px;
  transition: background .1s;
  font-family: inherit;
}
.ec-tbtn-dd-item:hover { background: var(--surface3, #f1f5f9); }

/* Toolbar Button aktiv */
.ec-tbtn.is-active {
  background: #ede9fe;
  color: #7c3aed;
}

/* Variable Pills im Editor */
.ec-var-pill {
  display: inline;
  background: #ede9fe;
  color: #7c3aed;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: monospace;
  cursor: default;
  user-select: none;
}

/* ── Signatur-Feld (neue Field-Zeile) ───────────────────────────────────── */
.ec-field--sig .ec-from-sel {
  flex: 1;
}
.ec-sig-manage-btn {
  height: 22px;
  padding: 0 9px;
  border-radius: 6px;
  border: 1px solid var(--border, #e5e7eb);
  background: transparent;
  color: var(--t3, #94a3b8);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  font-family: inherit;
  flex-shrink: 0;
  white-space: nowrap;
}
.ec-sig-manage-btn:hover {
  background: var(--brand-dim, #eff6ff);
  border-color: var(--brand, #6366f1);
  color: var(--brand, #6366f1);
}

/* ── Tracking-Optionen ─────────────────────────────────────────────────── */
.ec-tracking {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 7px 14px;
  border-top: 1px solid var(--border2, #f1f5f9);
  flex-shrink: 0;
  background: var(--surface, #fff);
}
.ec-tracking-opt {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 11.5px;
  color: var(--t2, #475569);
  user-select: none;
}
.ec-tracking-opt input[type=checkbox] {
  accent-color: var(--brand, #6366f1);
  cursor: pointer;
}
.ec-tracking-bcc-inp {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11.5px;
  outline: none;
  display: none;
  color: var(--text, #0f172a);
  font-family: inherit;
  width: 160px;
  transition: border-color .15s;
}
.ec-tracking-bcc-inp:focus { border-color: var(--brand, #6366f1); }

/* ── Link-Dialog ───────────────────────────────────────────────────────── */
.ec-dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(15,23,42,.4);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
}
.ec-dialog-overlay.open { display: flex; }
.ec-dialog-box {
  background: var(--surface, #fff);
  border-radius: 12px;
  padding: 22px;
  width: 400px;
  max-width: 94vw;
  box-shadow: 0 16px 48px rgba(0,0,0,.18);
}
.ec-dialog-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text, #0f172a);
  margin-bottom: 14px;
}
.ec-dialog-inp {
  width: 100%;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  margin-bottom: 8px;
  box-sizing: border-box;
  color: var(--text, #0f172a);
  font-family: inherit;
  transition: border-color .15s;
}
.ec-dialog-inp:focus { border-color: var(--brand, #6366f1); }
.ec-dialog-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}
.ec-dialog-btn {
  border: none;
  border-radius: 7px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}
.ec-dialog-btn--ghost {
  background: var(--surface3, #f1f5f9);
  color: var(--t2, #334155);
}
.ec-dialog-btn--ghost:hover { background: var(--border2, #e5e7eb); }
.ec-dialog-btn--primary {
  background: var(--brand, #6366f1);
  color: #fff;
}
.ec-dialog-btn--primary:hover { background: #4f46e5; }

/* ── Preview Modal ─────────────────────────────────────────────────────── */
.ec-preview-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 4900;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}
.ec-preview-overlay.open { display: flex; }
.ec-preview-box {
  background: var(--surface, #fff);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,.22);
  width: 830px;
  max-width: 97vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.ec-preview-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  flex-shrink: 0;
}
.ec-preview-title { font-size: 13.5px; font-weight: 700; color: var(--text, #0f172a); }
.ec-preview-toggle { display: flex; gap: 4px; }
.ec-preview-toggle-btn {
  padding: 4px 11px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border, #e5e7eb);
  background: none;
  color: var(--t3, #64748b);
  cursor: pointer;
  transition: all .12s;
  font-family: inherit;
}
.ec-preview-toggle-btn.active {
  background: var(--brand, #6366f1);
  color: #fff;
  border-color: var(--brand, #6366f1);
}
.ec-preview-body {
  flex: 1;
  overflow: auto;
  padding: 14px 18px;
  display: flex;
  justify-content: center;
  background: var(--surface2, #f8fafc);
}
.ec-preview-frame {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  background: #fff;
  transition: width .2s;
  overflow: hidden;
}
.ec-preview-frame.desktop { width: 100%; min-height: 420px; }
.ec-preview-frame.mobile  { width: 375px; min-height: 420px; }
.ec-preview-frame iframe  { width: 100%; height: 100%; min-height: 420px; border: none; display: block; }

/* ── Signatur Manager Panel ────────────────────────────────────────────── */
.ec-sig-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 4800;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
}
.ec-sig-panel-overlay.open { display: flex; }
.ec-sig-panel-box {
  background: var(--surface, #fff);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  width: 980px;
  max-width: 97vw;
  height: 730px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ec-sig-panel-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  flex-shrink: 0;
}
.ec-sig-panel-title { font-size: 14px; font-weight: 700; color: var(--text, #0f172a); }

/* Body: zwei Spalten (Liste | Editor), einziger fixer Bereich zwischen Header/Footer */
.ec-sig-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* Linke Spalte: Signaturliste */
.ec-sig-col-list {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--border, #e5e7eb);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface2, #f8fafc);
}
.ec-sig-new-btn {
  margin: 12px 12px 6px;
  text-align: center;
}
.ec-sig-list {
  overflow-y: auto;
  padding: 6px 10px 12px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.ec-sig-item {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 9px;
  padding: 9px 11px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  background: var(--surface, #fff);
  cursor: pointer;
  transition: border-color .12s;
}
.ec-sig-item:hover { border-color: var(--brand, #6366f1); }
.ec-sig-item.active { border-color: var(--brand, #6366f1); background: var(--brand-dim, #eef2ff); }
.ec-sig-item-meta { flex: 1; min-width: 0; }
.ec-sig-item-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text, #0f172a);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ec-sig-item-preview {
  font-size: 11px;
  color: var(--t3, #64748b);
  max-height: 32px;
  overflow: hidden;
}
.ec-sig-item-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.ec-sig-badge-default {
  font-size: 9.5px;
  font-weight: 700;
  color: #059669;
  background: #d1fae5;
  border-radius: 4px;
  padding: 1px 5px;
}

/* Rechte Spalte: Editor + Vorschau — NUR dieser Bereich scrollt */
.ec-sig-col-editor {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 20px 26px 14px;
  gap: 14px;
}
.ec-sig-editor-lbl {
  font-size: 15px;
  font-weight: 700;
  color: var(--text, #0f172a);
  flex-shrink: 0;
}
.ec-sig-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.ec-sig-field-lbl {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--t4, #94a3b8);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.ec-sig-name-inp {
  width: 100%;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 9px;
  padding: 10px 13px;
  font-size: 14px;
  color: var(--text, #0f172a);
  outline: none;
  box-sizing: border-box;
  font-family: inherit;
  background: var(--surface, #fff);
  transition: border-color .15s, box-shadow .15s;
}
.ec-sig-name-inp:focus { border-color: var(--brand, #6366f1); box-shadow: 0 0 0 3px var(--brand-dim, rgba(79,99,231,.12)); }

/* ── Formatierungs-Toolbar: Ribbon-Stil (Outlook/Word) ────────────────────
   Horizontale Gruppen mit Trennern. flex-wrap erlaubt Umbruch bei wenig
   Platz, aber JEDE Zeile bleibt horizontal — niemals flex-direction:column. */
.ec-sig-toolbar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  row-gap: 6px;
  padding: 8px 10px;
  background: var(--surface2, #f8fafc);
  border: 1px solid var(--border2, #e5e7eb);
  border-radius: 12px 12px 0 0;
  border-bottom: none;
  flex-shrink: 0;
}
.ec-sig-tb-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
}
.ec-tbtn-sep {
  width: 1px;
  height: 22px;
  background: var(--border2, #e2e8f0);
  margin: 0 2px;
  flex-shrink: 0;
}
.ec-sig-toolbar .ec-tbtn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  font-size: 13px;
}
.ec-sig-toolbar .ec-tbtn:hover { background: var(--surface, #fff); box-shadow: 0 1px 3px rgba(15,23,42,.08); }
.ec-sig-toolbar .ec-tbtn.is-active { background: var(--brand-dim, #eef2ff); color: var(--brand, #6366f1); }
.ec-tbtn--wide { width: auto !important; padding: 0 10px; gap: 4px; font-size: 12.5px; font-weight: 600; }
.ec-sig-font-sel {
  height: 30px;
  border: 1px solid transparent;
  background: var(--surface, #fff);
  border-radius: 7px;
  font-size: 12px;
  color: var(--t2, #334155);
  padding: 0 6px;
  font-family: inherit;
  cursor: pointer;
}
.ec-sig-font-sel:hover { border-color: var(--border2, #e5e7eb); }
.ec-sig-color-lbl {
  position: relative;
  width: 30px;
  height: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--t3, #64748b);
  border-radius: 7px;
  cursor: pointer;
}
.ec-sig-color-lbl:hover { background: var(--surface, #fff); box-shadow: 0 1px 3px rgba(15,23,42,.08); }
.ec-sig-color-lbl-ic { line-height: 1; }
.ec-sig-color-lbl input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ── Editor + Vorschau: EINZIGER scrollbarer Bereich, Editor nimmt den
   größten Platz ein. Editor = "Papier"-Karte, Vorschau optisch abgesetzt. */
.ec-sig-editor-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.ec-sig-editor-card {
  border: 1px solid var(--border, #e5e7eb);
  border-top: none;
  border-radius: 0 0 12px 12px;
  background: var(--surface, #fff);
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
  flex-shrink: 0;
}
.ec-sig-body-editor {
  width: 100%;
  min-height: 340px;
  font-size: 14px;
  color: var(--text, #0f172a);
  outline: none;
  font-family: inherit;
  line-height: 1.65;
  padding: 20px 22px;
  box-sizing: border-box;
}
.ec-sig-body-editor .ProseMirror { outline: none; min-height: 340px; }
.ec-sig-native-editor { outline: none; min-height: 340px; }
.ec-sig-body-editor.is-empty::before,
.ec-sig-body-editor .ProseMirror.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: var(--t4, #94a3b8);
  float: left;
  height: 0;
  pointer-events: none;
}
.ec-sig-body-editor img { max-width: 100%; height: auto; cursor: pointer; }
.ec-sig-body-editor table { border-collapse: collapse; margin: 6px 0; }
.ec-sig-body-editor table td, .ec-sig-body-editor table th {
  border: 1px solid var(--border, #e5e7eb);
  padding: 5px 8px;
  min-width: 40px;
}
.ec-sig-body-editor blockquote {
  border-left: 3px solid var(--brand, #6366f1);
  margin: 6px 0;
  padding: 2px 0 2px 12px;
  color: var(--t3, #64748b);
}

/* Live-Vorschau: bewusst optisch VOM Editor unterscheidbar (getönter
   Hintergrund, "eingesenkter" Schatten statt erhabener Editor-Karte). */
.ec-sig-preview-section {
  flex-shrink: 0;
  padding-top: 4px;
  border-top: 1px solid var(--border2, #eef0f4);
}
.ec-sig-preview-lbl {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--t3, #64748b);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 10px 0 9px;
}
.ec-sig-preview-lbl-sub {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--t4, #94a3b8);
  text-transform: none;
  letter-spacing: 0;
}
.ec-sig-preview-box {
  border: 1px solid var(--border2, #e5e7eb);
  border-radius: 12px;
  padding: 20px 22px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text, #0f172a);
  background: var(--surface3, #f4f6fa);
  box-shadow: inset 0 1px 4px rgba(15,23,42,.05);
  min-height: 100px;
}

/* Footer (fixiert) */
.ec-sig-panel-footer {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 14px 26px;
  border-top: 1px solid var(--border, #e5e7eb);
  flex-shrink: 0;
  background: var(--surface2, #fbfcfe);
  border-radius: 0 0 14px 14px;
}
.ec-sig-default-lbl {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--t2, #475569);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.ec-sig-default-lbl input { accent-color: var(--brand, #6366f1); width: 15px; height: 15px; cursor: pointer; }

@media (max-width: 760px) {
  .ec-sig-panel-box { width: 97vw; height: 92vh; }
  .ec-sig-panel-body { flex-direction: column; }
  .ec-sig-col-list { width: 100%; max-height: 160px; border-right: none; border-bottom: 1px solid var(--border, #e5e7eb); }
}

/* ── Kleine Utility-Buttons ─────────────────────────────────────────────── */
.ec-btn-sm {
  border: none;
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}
.ec-btn-ghost { background: var(--surface3, #f1f5f9); color: var(--t2, #334155); }
.ec-btn-ghost:hover { background: var(--border2, #e5e7eb); }
.ec-btn-primary { background: var(--brand, #6366f1); color: #fff; }
.ec-btn-primary:hover { background: #4f46e5; }
.ec-btn-danger { background: var(--surface3, #f1f5f9); color: var(--t2, #334155); }
.ec-btn-danger:hover { background: var(--c-red-bg, #fef2f2); color: var(--c-red-tx, #dc2626); border-color: var(--c-red-bd, #fca5a5); }
