/* Mailxender — interface client. Thème clair/sombre par variables. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #1c2230;
  --text-muted: #5f6b7a;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #e8efff;
  --success: #15803d;
  --success-soft: #e7f6ec;
  --warning: #b45309;
  --warning-soft: #fdf3e2;
  --danger: #c2261d;
  --danger-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f131a;
    --surface: #171c25;
    --surface-2: #1e2430;
    --border: #2a3140;
    --text: #e6e9ef;
    --text-muted: #9aa4b5;
    --primary: #5b8cff;
    --primary-hover: #7aa2ff;
    --primary-soft: #1c2742;
    --success: #4ade80;
    --success-soft: #15291d;
    --warning: #fbbf24;
    --warning-soft: #2e2512;
    --danger: #f87171;
    --danger-soft: #331a1a;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f131a;
  --surface: #171c25;
  --surface-2: #1e2430;
  --border: #2a3140;
  --text: #e6e9ef;
  --text-muted: #9aa4b5;
  --primary: #5b8cff;
  --primary-hover: #7aa2ff;
  --primary-soft: #1c2742;
  --success: #4ade80;
  --success-soft: #15291d;
  --warning: #fbbf24;
  --warning-soft: #2e2512;
  --danger: #f87171;
  --danger-soft: #331a1a;
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); font-size: .88em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.muted { color: var(--text-muted); }
.small { font-size: .87rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Structure */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; padding: 4px 10px 18px; color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: .95rem; }
.nav-section { margin: 14px 10px 4px; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 28px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.content { padding: 28px; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-muted); }
.menu-toggle { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-toggle { display: inline-flex; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Cartes et grilles */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 16px 20px 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
@media (min-width: 600px) and (max-width: 900px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { color: var(--text-muted); font-size: .85rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .82rem; color: var(--text-muted); }

.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }

/* ---------- Tableaux */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table a.row-link { color: var(--text); font-weight: 600; }

/* ---------- Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--text-muted); white-space: nowrap; }
.badge-verifie, .badge-approved, .badge-terminee, .badge-delivered, .badge-active, .badge-manual, .badge-verified, .badge-subscribed, .badge-en_cours { background: var(--success-soft); color: var(--success); }
.badge-partiel, .badge-pending, .badge-planifiee, .badge-en_revue, .badge-en_pause, .badge-queued, .badge-sending, .badge-past_due, .badge-sent { background: var(--warning-soft); color: var(--warning); }
.badge-a_configurer, .badge-rejected, .badge-failed, .badge-bounced, .badge-complained, .badge-undelivered, .badge-echec_partiel, .badge-suspended, .badge-annulee, .badge-canceled { background: var(--danger-soft); color: var(--danger); }
.badge-en_cours, .badge-sent { background: var(--primary-soft); color: var(--primary); }

/* ---------- Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .92rem;
  cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: .84rem; }
.btn-lg { padding: 12px 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* ---------- Formulaires */
.field { margin-bottom: 16px; }
.field label, .label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
.field .hint { font-size: .83rem; color: var(--text-muted); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
.input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea.input { min-height: 110px; resize: vertical; }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin-bottom: 10px; cursor: pointer; }
.check input { margin-top: 3px; }
.radio-cards { display: grid; gap: 10px; }
.radio-card { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; background: var(--surface); }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio-card input { margin-top: 4px; }
.form-narrow { max-width: 560px; }
input[type="color"].input { padding: 2px; height: 40px; width: 70px; }

/* ---------- Messages */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-info { background: var(--primary-soft); color: var(--primary); }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty h3 { color: var(--text); }

/* ---------- Assistant */
.steps { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; counter-reset: step; }
.steps a, .steps span {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); font-weight: 600; font-size: .9rem;
}
.steps .num { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: .78rem; }
.steps .current { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.steps .current .num { background: var(--primary); color: #fff; }
.steps .done .num { background: var(--success); color: #fff; }
.wizard-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

.summary { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; margin: 0; }
.summary dt { color: var(--text-muted); }
.summary dd { margin: 0; font-weight: 500; }
@media (max-width: 600px) { .summary { grid-template-columns: 1fr; } .summary dd { margin-bottom: 8px; } }

/* ---------- DNS */
.dns-record { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: var(--surface); }
.dns-record .dns-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.dns-grid { display: grid; grid-template-columns: 90px 1fr auto; gap: 6px 10px; align-items: center; font-size: .9rem; }
.dns-grid code { background: var(--surface-2); padding: 5px 8px; border-radius: 6px; word-break: break-all; }
@media (max-width: 600px) { .dns-grid { grid-template-columns: 1fr; } }

/* ---------- Téléphone (aperçu SMS) */
.phone { width: 280px; max-width: 100%; margin: 0 auto; border: 10px solid #111827; border-radius: 34px; background: #f3f4f6; padding: 16px 12px 28px; min-height: 420px; }
.phone-head { text-align: center; font-weight: 700; color: #111827; font-size: .92rem; padding-bottom: 10px; border-bottom: 1px solid #d1d5db; margin-bottom: 14px; }
.bubble { background: #e5e7eb; color: #111827; border-radius: 16px 16px 16px 4px; padding: 10px 12px; font-size: .9rem; white-space: pre-wrap; word-wrap: break-word; max-width: 92%; }
.counter { display: flex; gap: 14px; flex-wrap: wrap; font-size: .87rem; color: var(--text-muted); margin-top: 6px; }
.counter strong { color: var(--text); }
.counter .warn { color: var(--warning); font-weight: 600; }

/* ---------- Studio */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .studio { grid-template-columns: 1fr; } }
.block-item { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin-bottom: 10px; }
.block-item-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--surface-2); border-radius: 10px 10px 0 0; font-weight: 600; font-size: .9rem; }
.block-item-body { padding: 12px; }
.block-item-body .field { margin-bottom: 10px; }
.block-palette { display: flex; flex-wrap: wrap; gap: 6px; }
.preview-frame { width: 100%; height: 720px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.preview-frame.mobile { width: 390px; max-width: 100%; display: block; margin: 0 auto; }
.preview-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; flex-wrap: wrap; }
.logo-preview { overflow: auto; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0/16px 16px; padding: 12px; border-radius: 8px; border: 1px solid var(--border); min-height: 60px; }
.logo-preview table { border-collapse: collapse; margin: 0 auto; }

/* ---------- Pages publiques */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card .brand { justify-content: center; padding-bottom: 20px; }
.auth-foot { text-align: center; margin-top: 16px; color: var(--text-muted); font-size: .92rem; }
.bare { max-width: 520px; margin: 0 auto; padding: 60px 16px; }

/* ---------- Divers */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a, .tabs button { padding: 9px 14px; border: 0; background: none; color: var(--text-muted); font: inherit; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs .active { color: var(--primary); border-bottom-color: var(--primary); }
.pagination { display: flex; gap: 6px; justify-content: center; margin: 16px 0; flex-wrap: wrap; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); flex: none; display: grid; place-items: center; font-size: .7rem; color: #fff; }
.checklist .done .dot { background: var(--success); border-color: var(--success); }
.checklist .done a { color: var(--text-muted); text-decoration: line-through; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: 0; }
.org-switch select { max-width: 220px; }
.theme-toggle svg { width: 18px; height: 18px; }
details.more summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.copy { cursor: pointer; }
