/* UI du generateur. Le rendu de la signature elle-meme est autonome (styles
   inline dans signature.js) : rien ici ne le touche. Theme par marque via
   [data-brand] sur <body>. Montserrat pour l'interface (charte commune). */

:root {
  --bg: #f6f6f7;
  --panel: #ffffff;
  --ink: #1e1e24;
  --muted: #6b6b76;
  --line: #e6e6ea;
  --radius: 14px;
  --accent: #f9886c;
  --accent-ink: #ffffff;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 8px 24px rgba(20, 20, 30, 0.06);
  font-family: "Montserrat", -apple-system, "Segoe UI", Roboto, sans-serif;
}

body[data-brand="zouaf"] { --accent: #f9886c; --accent-ink: #ffffff; }
body[data-brand="glaads"] { --accent: #7a00ff; --accent-ink: #ffffff; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

/* --- Top bar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar__title { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15px; }
.topbar__hint { color: var(--muted); font-size: 12px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }

/* --- Layout --- */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(360px, 1fr) minmax(360px, 1fr);
  gap: 18px;
  padding: 18px 22px;
  align-items: start;
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 220px 1fr; }
  .preview { grid-column: 1 / -1; }
}

/* --- Sidebar --- */
.sidebar { position: sticky; top: 18px; display: flex; flex-direction: column; gap: 12px; }
.filters { display: flex; gap: 6px; }
.filters button {
  flex: 1;
  padding: 7px 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
}
.filters button.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }

.siglist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.siglist li {
  padding: 11px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.siglist li.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.siglist .name { font-weight: 700; }
.siglist .meta { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.siglist .badge { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.badge--zouaf { background: #fdeae3; color: #b5411f; }
.badge--glaads { background: #efe2ff; color: #5a00bd; }
.siglist .empty-hint { color: var(--muted); padding: 10px 4px; font-size: 13px; }

/* --- Buttons --- */
.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 9px 16px;
  font-weight: 600;
}
.btn--sm { padding: 6px 12px; font-size: 12px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--new { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn--ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* --- Editor --- */
.editor, .preview {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.editor__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.editor__actions { display: flex; align-items: center; gap: 8px; }
.dirty { font-size: 12px; color: var(--accent); font-weight: 700; }

.brandpick, .segmented { display: flex; gap: 8px; }
.segmented { margin: 8px 0 4px; }
.brandpick label, .segmented label {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-size: 13px;
}
.brandpick input, .segmented input { accent-color: var(--accent); }
.brandpick label:has(:checked), .segmented label:has(:checked) {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); font-weight: 700;
}

.iconbase { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fcfcfd; }
.iconbase label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.hint.warn { color: #b23c17; font-weight: 600; }

fieldset { border: none; border-top: 1px solid var(--line); margin: 0; padding: 14px 0 4px; }
fieldset:first-of-type { border-top: none; }
legend { font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 0; }
form label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 10px; }
form input, form select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fcfcfd;
}
form input:focus, form select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.sub { font-size: 11px; font-weight: 700; color: var(--ink); text-transform: uppercase; letter-spacing: 0.5px; margin: 14px 0 0; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 10px; }
label.check input { width: auto; margin: 0; accent-color: var(--accent); }
form textarea { min-height: 64px; line-height: 1.5; }

.social-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.social-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 8px; align-items: center; }
.social-row select, .social-row input { margin-top: 0; }
.social-row button { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }

/* --- Preview --- */
.preview { position: sticky; top: 18px; }
.preview__bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.preview__tools { display: flex; gap: 6px; flex-wrap: wrap; }
.preview__frame { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #f4f4f5; }
#previewFrame { display: block; width: 700px; height: 420px; border: 0; background: #f4f4f5; }
.code { margin-top: 12px; }
.code summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--muted); }
#codeOut { height: 180px; margin-top: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.5; resize: vertical; }

/* --- Empty state --- */
.empty { grid-column: 2 / -1; padding: 60px 20px; text-align: center; color: var(--muted); }
@media (max-width: 1100px) { .empty { grid-column: 2 / -1; } }

/* --- Toast --- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow); z-index: 20;
}
