/* ==========================================================================
   Relais — feuille de style commune (Manager + Agent + Connexion)
   ========================================================================== */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #475467;
  --text-3: #98a2b3;
  --ink: #0b1220;
  --ink-2: #16213a;
  --ink-text: #cbd5e1;

  --brand: #0f9d76;
  --brand-strong: #0b7f5f;
  --brand-soft: #e6f6f0;

  --ready: #12b76a;   --ready-soft: #e7f8ef;
  --pause: #f79009;   --pause-soft: #fef4e6;
  --call: #2e90fa;    --call-soft: #e8f2ff;
  --wrap: #7a5af8;    --wrap-soft: #f1edff;
  --off: #98a2b3;     --off-soft: #f2f4f7;
  --danger: #f04438;  --danger-soft: #fef0ef;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .25);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17; --surface: #121826; --surface-2: #0f1520; --border: #1f2937; --border-strong: #2b3646;
    --text: #e6e9ef; --text-2: #a4adbd; --text-3: #6b7587;
    --brand-soft: #0f2a22; --ready-soft: #0f2a1d; --pause-soft: #2d2010; --call-soft: #0f2238;
    --wrap-soft: #1f1a3a; --off-soft: #1a2130; --danger-soft: #2e1515;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
.num, .tabular { font-variant-numeric: tabular-nums; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --------------------------------------------------------------- boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: 600 14px var(--font); cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); outline-offset: 1px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--off-soft); color: var(--text); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.lg { height: 52px; padding: 0 24px; font-size: 16px; border-radius: 12px; }
.btn.xl { height: 64px; padding: 0 32px; font-size: 18px; border-radius: 16px; }
.btn.block { width: 100%; }
.icon-btn { width: 36px; padding: 0; }

/* --------------------------------------------------------------- formulaires */
label.field { display: block; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
label.field small { display: block; color: var(--text-3); font-size: 12px; margin-top: 4px; }
input, select, textarea {
  width: 100%; height: 42px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 14px var(--font);
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; height: auto; }
input[type="range"] { height: 6px; padding: 0; accent-color: var(--brand); border: none; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* --------------------------------------------------------------- cartes & badges */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-h h3 { font-size: 15px; }
.card-h .sub { color: var(--text-3); font-size: 13px; font-weight: 500; }
.card-b { padding: 20px; }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--off-soft); color: var(--text-2); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.st-ready { background: var(--ready-soft); color: var(--ready); }
.st-pause { background: var(--pause-soft); color: var(--pause); }
.st-on_call, .st-connected { background: var(--call-soft); color: var(--call); }
.st-wrapup { background: var(--wrap-soft); color: var(--wrap); }
.st-offline { background: var(--off-soft); color: var(--off); }
.st-danger { background: var(--danger-soft); color: var(--danger); }
.st-brand { background: var(--brand-soft); color: var(--brand); }

.avatar { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; position: relative; }
.avatar .dot { position: absolute; right: -3px; bottom: -3px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--surface); }

.empty { text-align: center; color: var(--text-3); padding: 36px 16px; }
.empty svg.i { width: 32px; height: 32px; margin-bottom: 8px; color: var(--border-strong); }
.muted { color: var(--text-3); }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------- tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }

/* --------------------------------------------------------------- toasts & modales */
#toasts { position: fixed; z-index: 100; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; display: flex; gap: 10px; align-items: center; animation: toastIn .25s ease; max-width: 90vw; }
.toast.error { background: var(--danger); }
.toast.ok svg.i { color: var(--ready); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

.modal-bg { position: fixed; inset: 0; z-index: 90; background: rgba(11, 18, 32, .55); display: grid; place-items: center; padding: 16px; animation: fade .15s; backdrop-filter: blur(2px); }
.modal { width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .2s ease; }
.modal-h { padding: 20px 24px 0; display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.modal-h h3 { font-size: 18px; }
.modal-h p { margin: 4px 0 0; color: var(--text-2); }
.modal-b { padding: 20px 24px; display: grid; gap: 16px; }
.modal-f { padding: 0 24px 20px; display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(6px); } }

.drawer-bg { position: fixed; inset: 0; z-index: 80; background: rgba(11, 18, 32, .4); animation: fade .15s; }
.drawer { position: fixed; z-index: 81; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--surface); box-shadow: var(--shadow-lg); overflow: auto; animation: slideIn .22s ease; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }

.secret { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border-strong); font: 600 16px ui-monospace, SFMono-Regular, Menlo, monospace; }
.secret span { flex: 1; }
.callout { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); font-size: 13px; border: 1px solid var(--border); }
.callout.warn { background: var(--pause-soft); color: color-mix(in srgb, var(--pause) 70%, var(--text)); border-color: transparent; }
.callout.info { background: var(--call-soft); color: color-mix(in srgb, var(--call) 70%, var(--text)); border-color: transparent; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: 600 13px var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip .n { color: var(--text-3); font-weight: 500; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.on .n { color: #94a3b8; }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--border-strong); transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }

.spinner { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.conn-lost { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 95; background: var(--danger); color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 13px; display: flex; gap: 8px; align-items: center; box-shadow: var(--shadow-lg); }
