/* ============================================================
   CRM — Christophe. Charte reprise de Calendly (2026-08-06) :
   bleu, sans-serif partout, cartes blanches, boutons en pilule.
   ============================================================ */
:root {
  --bg: #f8f9fb;
  --panel: #ffffff;
  --ink: #14181f;
  --muted: #62697b;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --accent: #0069ff;      /* bleu Calendly */
  --accent-ink: #0052cc;
  --accent-soft: #e8f1ff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --pill: 999px;
  --shadow: 0 1px 2px rgba(20, 24, 31, .05), 0 1px 10px rgba(20, 24, 31, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Barre supérieure ---- */
.topbar {
  display: flex; align-items: center; gap: 32px;
  padding: 0 24px; height: 60px;
  background: var(--panel);
  border-bottom: 1px solid var(--line-strong);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: var(--pill);
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: var(--font); font-weight: 700; font-size: 11px; letter-spacing: .3px;
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; }
.brand-txt strong { font-family: var(--font); font-size: 16px; font-weight: 700; }
.brand-txt small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }

#nav { display: flex; gap: 4px; flex-wrap: wrap; }
#nav a {
  color: var(--muted); padding: 8px 14px; border-radius: var(--pill);
  font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
#nav a:hover { background: #eef0f3; color: var(--ink); }
#nav a.active { background: var(--accent-soft); color: var(--accent-ink); }

.badge {
  background: var(--accent); color: #fff; border-radius: 999px;
  font-size: 11px; min-width: 18px; height: 18px; padding: 0 5px;
  display: inline-grid; place-items: center; font-weight: 700;
}
.badge[hidden] { display: none; }  /* sinon la règle display ci-dessus écrase l'attribut hidden */

/* ---- Layout ---- */
#app { max-width: 1180px; margin: 0 auto; padding: 24px; }
.loading { color: var(--muted); padding: 40px; text-align: center; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.view-head h1 { font-family: var(--font); font-size: 22px; margin: 0; font-weight: 600; }
.view-head .sub { color: var(--muted); font-size: 13px; }

/* ---- Cartes stats ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .n { font-size: 30px; font-weight: 700; font-family: var(--font); line-height: 1; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; margin-top: 8px; }
.stat.accent .n { color: var(--accent); }
.stat.warn .n { color: var(--warn); }

/* ---- Panneaux ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; }
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-head h2 { margin: 0; font-size: 15px; font-family: var(--font); font-weight: 600; }
.panel-body { padding: 16px 18px; }
.panel-body.flush { padding: 0; }

/* ---- Pipeline (barres statut) ---- */
.pipeline { display: flex; flex-direction: column; gap: 8px; }
.pipe-row { display: grid; grid-template-columns: 150px 1fr 46px; align-items: center; gap: 10px; }
.pipe-row .lbl { font-size: 13px; color: var(--ink); display: flex; align-items: center; gap: 7px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pipe-bar { height: 10px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.pipe-bar > span { display: block; height: 100%; border-radius: 999px; }
.pipe-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; background: #f7f8fa; position: sticky; top: 0; }
table.grid tbody tr:hover { background: #f5f7fa; }
table.grid tr.clickable { cursor: pointer; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid th.row-check, table.grid td.row-check { width: 34px; padding-right: 0; }
.video-select-cell { width: 38px; padding-left: 10px !important; padding-right: 0 !important; text-align: center !important; }
.video-select-cell input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); vertical-align: middle; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* ---- Sélection groupée ---- */
.bulk-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
}
.bulk-bar[hidden] { display: none; }
.bulk-count { font-weight: 700; color: var(--accent-ink); white-space: nowrap; }
.bulk-group { display: flex; gap: 6px; align-items: center; }
.bulk-group select, .bulk-group input { padding: 6px 8px; font-size: 12.5px; }

/* ---- Tags ---- */
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid; white-space: nowrap;
}
.tag-rm { border: none; background: transparent; cursor: pointer; font-size: 13px; line-height: 1; padding: 0 0 0 2px; color: inherit; opacity: .65; }
.tag-rm:hover { opacity: 1; }

/* ---- Badges statut ---- */
.status-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--line-strong); background: #fff;
}
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: #eef0f3; color: var(--muted); }
.chip.email { background: #eaf1fb; color: #1e50a2; }
.chip.telephone { background: #eaf6ee; color: #14683f; }
.chip.linkedin { background: #eaf1fb; color: #0a66c2; }
.chip.ok { background: #e6f4ea; color: var(--ok); }
.chip.bad { background: #fbeceb; color: var(--danger); }
.chip.muted { background: #eef0f3; color: var(--muted); }

/* ---- Boutons ---- */
button, .btn {
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  padding: 8px 16px; border-radius: var(--pill); transition: background .12s, border-color .12s;
}
button:hover, .btn:hover { background: #eef1f5; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-ink); }
button.ghost { border-color: transparent; background: transparent; color: var(--accent); padding: 6px 8px; }
button.ghost:hover { background: var(--accent-soft); }
button.sm { padding: 5px 12px; font-size: 12px; }
button.danger { color: var(--danger); border-color: #e8c8c6; }
button.danger:hover { background: #fbeceb; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---- Formulaires ---- */
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  font-family: inherit; font-size: 13px; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 9px 12px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 60px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* ---- Barre de filtres ---- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters label.field { min-width: 140px; }
.filters .grow { flex: 1; min-width: 200px; }

/* ---- Module Emails IONOS ---- */
.email-tabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px;
  border-bottom: 1px solid var(--line);
}
.email-tabs button {
  border: none; border-radius: 8px 8px 0 0; background: transparent;
  color: var(--muted); padding: 9px 12px;
}
.email-tabs button.active {
  color: var(--accent-ink); background: var(--accent-soft);
}
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; min-width: 130px; }
.inline-fields input { padding: 6px 8px; }
.email-alerts { display: grid; gap: 8px; margin-bottom: 14px; }
.email-alert {
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 10px 12px; background: #fff8e6; color: #8a4b00;
}
.email-alert.bad { background: #fbeceb; color: var(--danger); border-color: #e8c8c6; }
.email-alert.warn { background: #fff8e6; color: #8a4b00; border-color: #f0e0a8; }

/* ---- Tâches ---- */
.task-item { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.task-item:last-child { border-bottom: none; }
.task-item.overdue { background: #fdf6ee; }
.task-main { flex: 1; min-width: 0; }
.task-main .who { font-weight: 600; }
.task-main .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.task-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.due-tag { font-size: 11px; padding: 2px 7px; border-radius: 5px; background: #eef0f2; color: var(--muted); font-weight: 600; }
.due-tag.late { background: #f7e0d6; color: #a13b12; }

/* ---- Séquences ---- */
.seq-steps { display: flex; flex-direction: column; gap: 8px; }
.step-line { display: grid; grid-template-columns: 28px 120px 1fr 90px auto; gap: 10px; align-items: center; }
.step-badge { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 12px; }

/* ---- Modale ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(27,26,23,.42); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border-radius: 10px; width: min(720px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.modal-head h3 { margin: 0; font-family: var(--font); font-size: 18px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--panel); }
.close-x { border: none; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px; }
.public-slug-editor { display: flex; align-items: center; gap: 0; margin-top: 4px; }
.public-slug-editor > span { flex: none; padding: 9px 0 9px 12px; border: 1px solid var(--line-strong); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); background: #f7f8fa; color: var(--muted); font-size: 13px; }
.public-slug-editor input { flex: 1; min-width: 10rem; border-radius: 0; }
.public-slug-editor button { border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; padding: 9px 12px; white-space: nowrap; }

/* ---- Détail contact ---- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; margin-bottom: 8px; }
.detail-grid .k { color: var(--muted); font-size: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.timeline li .t { color: var(--muted); font-size: 11px; }

/* ---- Entrée d'historique (interaction) ---- */
.ti { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.ti-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.ti-date { font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink); }
.ti-result { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eef0f3; color: var(--muted); }
.ti-result.ok { background: #e6f4ea; color: var(--ok); }
.ti-result.bad { background: #fbeceb; color: var(--danger); }
.ti-notes { font-size: 13px; color: var(--ink); line-height: 1.4; }
.ti-expand { margin-top: 6px; }
.ti-expand summary { cursor: pointer; font-size: 12px; color: var(--accent); font-weight: 600; list-style: none; }
.ti-expand summary::-webkit-details-marker { display: none; }
.ti-expand summary::before { content: "▸ "; }
.ti-expand[open] summary::before { content: "▾ "; }
.ti-body { margin-top: 8px; padding: 10px 12px; background: #f7f8fa; border: 1px solid var(--line); border-radius: 6px; font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; max-height: 320px; overflow-y: auto; color: var(--muted); }
.section-title { font-family: var(--font); font-size: 14px; font-weight: 600; margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 8px;
  z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 13px; max-width: 90vw;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

.hint { color: var(--muted); font-size: 12.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
code.inline { background: #eef0f3; padding: 2px 6px; border-radius: 4px; font-size: 12.5px; }
pre.cmd { background: #201d1a; color: #f3ede2; padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; }

@media (max-width: 640px) {
  .topbar { height: auto; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 16px; }
  #app { padding: 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .step-line { grid-template-columns: 24px 1fr; }
}

/* ============================================================
   Module campagnes CRM : orchestration 01 → 09
   ============================================================ */
.campaign-workflows { margin-bottom: 22px; }
.workflow-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); }
.workflow-item { display: grid; grid-template-columns: 30px 1fr; column-gap: 8px; padding: 14px 16px; background: var(--panel); }
.workflow-item > span { grid-row: span 2; color: var(--accent-ink); font-weight: 800; }
.workflow-item strong { font-size: 12.5px; }
.workflow-item small { color: var(--muted); font-size: 11px; }
.campaign-step-grid { display: grid; grid-template-columns: 1.3fr .7fr; gap: 22px; }
.campaign-filters { align-items: end; margin: 0 0 14px; }
.campaign-filters .field { min-width: 130px; }
.campaign-actions { margin-top: 16px; flex-wrap: wrap; }
.campaign-messages td { vertical-align: top; }
.campaign-messages details { max-width: 300px; }
.campaign-messages summary { cursor: pointer; color: var(--accent-ink); font-size: 12px; }
.danger-text { color: var(--danger); }
.error-list { margin-top: 14px; padding: 10px 14px; border-left: 3px solid var(--danger); background: #fff1f0; color: var(--danger); font-size: 12px; }
.error-list p { margin: 4px 0; }
@media (max-width: 900px) {
  .workflow-grid, .campaign-step-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Module vidéo-messagerie
   ============================================================ */
.vid-sources { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.vid-source {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--panel); color: var(--ink); cursor: pointer; font: inherit;
}
.vid-source:hover { border-color: var(--accent); }
.vid-source.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.vid-source-ico { font-size: 15px; line-height: 1; }

.vid-stage { position: relative; margin: 12px 0; }
.vid-preview {
  width: 100%; max-height: 420px; background: #111; border-radius: var(--radius);
  border: 1px solid var(--line-strong); display: block; object-fit: contain;
}
.vid-badge {
  position: absolute; top: 10px; left: 10px;
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px; border-radius: 999px;
  background: rgba(27, 26, 23, .78); color: #fff;
  font-variant-numeric: tabular-nums; font-size: 13px;
}
/* L'attribut hidden perd contre toute règle display d'auteur (leçon 2026-07-07). */
.vid-badge[hidden] { display: none; }
.vid-dot { width: 9px; height: 9px; border-radius: 50%; background: #e5484d; animation: vid-pulse 1.4s infinite; }
@keyframes vid-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .vid-dot { animation: none; } }

.vid-transcript { margin-top: 14px; max-height: 320px; overflow-y: auto; }
.vid-transcript p { margin: 0 0 8px; line-height: 1.5; }
.vid-transcript .hint { font-variant-numeric: tabular-nums; margin-right: 6px; }

.vid-countdown {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(17, 17, 17, .45);
  color: #fff;
  font-size: 96px; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums;
  border-radius: var(--radius);
  animation: vid-countdown-pulse .5s ease-out;
}
.vid-countdown[hidden] { display: none; }
@keyframes vid-countdown-pulse { from { transform: scale(1.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .vid-countdown { animation: none; } }

/* ---- Publication d'un envoi (P4) ---- */
.pick-results { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; max-height: 180px; overflow-y: auto; }
.pick-results button {
  text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; font: inherit;
}
.pick-results button:hover { background: #f2f4f7; }
.envoi-resultat { margin-top: 18px; padding: 14px; border-radius: 10px; border: 1px solid var(--line); }
.envoi-resultat.ok { background: #eaf6ee; border-color: #cfe9d7; }
.envoi-resultat.attente { background: #fff8e6; border-color: #f0e0a8; }
.envoi-url { display: block; margin: 8px 0; word-break: break-all; }
.tpl-apercu-texte { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 13.5px; margin: 8px 0 0; }
.link-btn {
  border: none; background: none; padding: 0; font: inherit; color: var(--accent, #7a2230);
  text-decoration: underline; cursor: pointer;
}
.link-btn:hover { opacity: .75; }
.envois-table td, .envois-table th { padding: 6px 10px; }
.envois-table .hint { font-size: 12px; }
.delivery-context { display: flex; gap: 18px; flex-wrap: wrap; border: 0; padding: 0; margin: 0 0 14px; }
.delivery-context label { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink); font-weight: 600; }
.delivery-context input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ============================================================
   Messages vocaux LinkedIn
   ============================================================ */
.voice-recorder {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 16px; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: #f7f8fa;
}
.voice-main-btn {
  min-width: 150px;
  min-height: 44px;
  font-size: 15px;
}
.voice-meter {
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: #fff;
}
.voice-meter[hidden] { display: none; }
.voice-meter strong { font-variant-numeric: tabular-nums; }
.voice-audio {
  width: 100%;
  min-height: 42px;
  display: block;
}
