/* AntiFast — design system commun (site, panel client, admin). */

:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;

  --bg: #f7f7fa;
  --surface: #ffffff;
  --surface-2: #f2f1f7;
  --border: #e5e3ee;
  --border-strong: #d4d1e0;
  --text: #17161f;
  --text-2: #4a4858;
  --muted: #77748a;

  --brand: #7c5cff;
  --brand-strong: #6644f2;
  --brand-text: #5b3be6;
  --brand-soft: rgba(124, 92, 255, 0.1);
  --brand-ring: rgba(124, 92, 255, 0.35);
  --on-brand: #ffffff;

  --success: #239a6c;
  --success-soft: rgba(35, 154, 108, 0.12);
  --warning: #c98419;
  --warning-soft: rgba(201, 132, 25, 0.14);
  --danger: #dc3e45;
  --danger-soft: rgba(220, 62, 69, 0.12);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(23, 22, 31, 0.05);
  --shadow: 0 1px 3px rgba(23, 22, 31, 0.06), 0 8px 24px rgba(23, 22, 31, 0.06);
  --shadow-lg: 0 20px 60px rgba(23, 22, 31, 0.18);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0c0b11;
    --surface: #14131b;
    --surface-2: #1b1a24;
    --border: #25232f;
    --border-strong: #34313f;
    --text: #edecf4;
    --text-2: #c0bdd0;
    --muted: #8f8ca3;
    --brand: #8a6dff;
    --brand-strong: #9b83ff;
    --brand-text: #a993ff;
    --brand-soft: rgba(138, 109, 255, 0.14);
    --brand-ring: rgba(138, 109, 255, 0.45);
    --success: #3dbd8b;
    --success-soft: rgba(61, 189, 139, 0.14);
    --warning: #e3a547;
    --warning-soft: rgba(227, 165, 71, 0.14);
    --danger: #ef5a60;
    --danger-soft: rgba(239, 90, 96, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #0c0b11;
  --surface: #14131b;
  --surface-2: #1b1a24;
  --border: #25232f;
  --border-strong: #34313f;
  --text: #edecf4;
  --text-2: #c0bdd0;
  --muted: #8f8ca3;
  --brand: #8a6dff;
  --brand-strong: #9b83ff;
  --brand-text: #a993ff;
  --brand-soft: rgba(138, 109, 255, 0.14);
  --brand-ring: rgba(138, 109, 255, 0.45);
  --success: #3dbd8b;
  --success-soft: rgba(61, 189, 139, 0.14);
  --warning: #e3a547;
  --warning-soft: rgba(227, 165, 71, 0.14);
  --danger: #ef5a60;
  --danger-soft: rgba(239, 90, 96, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; font-weight: 650; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
::selection { background: var(--brand-soft); }
:focus-visible { outline: 2px solid var(--brand-ring); outline-offset: 2px; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ─── Logo ─── */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Boutons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { filter: brightness(1.05); background: var(--danger); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: var(--radius); }
.btn-icon { width: 32px; padding: 0; }

/* ─── Formulaires ─── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-weight: 550; font-size: 13px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px; transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { height: auto; min-height: 88px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2377748a' stroke-width='1.6'%3E%3Cpath d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-sm { height: 30px; font-size: 12.5px; }
input[type='color'].input { padding: 3px; width: 56px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }

/* Interrupteur */
.switch { position: relative; display: inline-flex; flex-shrink: 0; width: 36px; height: 20px; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background 0.15s; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform 0.15s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand-ring); outline-offset: 2px; }

/* ─── Cartes ─── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 14.5px; }
.card-header p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ─── Badges ─── */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge.plain::before { display: none; }
.badge > svg { width: 13px; height: 13px; flex-shrink: 0; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.brand { background: var(--brand-soft); color: var(--brand-text); }

/* ─── Tableaux ─── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 550; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .actions { text-align: right; white-space: nowrap; }

/* ─── Divers ─── */
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); flex-shrink: 0; object-fit: cover; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.on { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot.off { background: var(--danger); }
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.kbd { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--surface-2); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--brand); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; max-width: calc(100vw - 40px); }
.toast { display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 380px; padding: 12px 14px; border-radius: var(--radius); background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toast-in 0.2s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
.toast.success::before, .toast.info::before { content: ''; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.toast.info::before { background: var(--brand); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Fenêtres modales */
dialog.modal { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog.modal.wide { width: min(720px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(10, 9, 15, 0.5); backdrop-filter: blur(2px); }
.modal-header { padding: 18px 22px 0; }
.modal-header h3 { font-size: 16px; }
.modal-header p { margin-top: 6px; color: var(--text-2); }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
