/* =========================================================================
   Interface d'administration — Plateforme chatbot
   Vanilla CSS, sans build. Palette calée sur le widget (--fcm-*).
   ========================================================================= */
:root {
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --rust: #c2410c;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --ok: #166534;
  --ok-bg: #f0fdf4;
  --err: #b91c1c;
  --err-bg: #fef2f2;
  --warn-bg: #fffbeb;
  --warn: #92400e;
  --code-bg: #0f172a;
  --code-ink: #dbe3f0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 1rem; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
a { color: var(--primary); }
code { font-family: var(--mono); font-size: .85em; background: rgba(30, 64, 175, .08); padding: .1rem .35rem; border-radius: 6px; }
.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;
}
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.2rem; background: var(--card);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
}
.topbar .brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; }
.topbar .brand .dot { width: .95rem; height: .95rem; border-radius: 4px; background: var(--primary); display: inline-block; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: .85rem; color: var(--muted); display: flex; align-items: center; gap: .5rem; }
.topbar .user .role { background: rgba(30, 64, 175, .1); color: var(--primary); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: .15rem .45rem; border-radius: 999px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 1.4rem 1.2rem 3rem; }
.wrap.narrow { max-width: 460px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .4rem; border-bottom: 2px solid var(--line); margin-bottom: 1.4rem; }
.tabs a {
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: .95rem;
  padding: .55rem .9rem; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs a:hover { color: var(--ink); }
.tabs a.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.topbar .tabs { border-bottom: 0; margin-bottom: 0; flex: 1; min-width: 0; overflow-x: auto; }

/* ---------- Cards / list ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem 1.3rem; margin-bottom: 1.1rem; }
.card h2 { margin-bottom: .9rem; }
.toolbar { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 1rem; padding: .9rem .4rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 180px; }
.list .name { font-weight: 650; font-size: 1.02rem; }
.list .sub { font-size: .82rem; color: var(--muted); margin-top: .15rem; }
.list .sub code { font-size: .8em; }
.meta { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .18rem .5rem; border-radius: 999px; border: 1px solid var(--line-strong); background: #f8fafc; color: var(--muted); }
.badge.provider { color: var(--primary); border-color: rgba(30, 64, 175, .3); background: rgba(30, 64, 175, .07); }
.badge.on { color: var(--ok); border-color: rgba(22, 101, 52, .3); background: var(--ok-bg); }
.badge.off { color: var(--muted); background: #f1f5f9; }
.badge.key { color: var(--warn); border-color: rgba(146, 64, 14, .3); background: var(--warn-bg); }
.badge.nokey { color: var(--err); border-color: rgba(185, 28, 28, .3); background: var(--err-bg); }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--sans); font-size: .92rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 9px; padding: .55rem 1rem;
  background: #fff; color: var(--ink); transition: border-color .15s ease, background .15s ease, transform .05s ease;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-rust { background: var(--rust); border-color: var(--rust); color: #fff; }
.btn-rust:hover { background: #9a3412; border-color: #9a3412; }
.btn-ghost { background: transparent; }
.btn-sm { font-size: .82rem; padding: .35rem .7rem; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; }
.field > label, .field > .lab { display: block; font-size: .85rem; font-weight: 650; margin-bottom: .3rem; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: .25rem; }
.field .hint code { font-size: .8em; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], select, textarea {
  width: 100%; font-family: var(--sans); font-size: .95rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: 9px; padding: .55rem .7rem;
}
input[type="color"] { width: 3rem; height: 2.3rem; padding: .15rem; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; cursor: pointer; }
textarea { resize: vertical; min-height: 3.4rem; font-family: var(--mono); font-size: .85rem; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(30, 64, 175, .25); border-color: var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem .9rem; }
.theme-grid .sw { display: flex; align-items: center; gap: .5rem; }
.theme-grid .sw span { font-size: .8rem; color: var(--muted); }

/* checkbox / switch */
.check { display: flex; align-items: center; gap: .55rem; font-size: .92rem; cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; }

/* ---------- Origines ---------- */
.origins { display: flex; flex-direction: column; gap: .45rem; }
.origins .row { display: flex; gap: .5rem; align-items: center; }
.origins .row input { flex: 1; }
.origins .chip {
  display: inline-flex; align-items: center; gap: .45rem; font-size: .82rem;
  background: rgba(30, 64, 175, .07); border: 1px solid rgba(30, 64, 175, .25);
  color: var(--primary); padding: .3rem .5rem .3rem .7rem; border-radius: 999px;
}
.origins .chip button { border: 0; background: rgba(30, 64, 175, .15); color: var(--primary); width: 1.25rem; height: 1.25rem; border-radius: 50%; cursor: pointer; font-size: .8rem; line-height: 1; display: grid; place-items: center; }
.origins .chip button:hover { background: rgba(30, 64, 175, .3); }

/* ---------- Code généré ---------- */
.codeblock { margin: 0; background: var(--code-bg); color: var(--code-ink); border-radius: 10px; padding: 1rem 1.1rem; overflow: auto; font-family: var(--mono); font-size: .8rem; line-height: 1.6; white-space: pre; max-height: 420px; }
.codeblock .c { color: #7dd3fc; }

/* ---------- Aperçu ---------- */
.preview-frame { width: 100%; height: 480px; border: 1px solid var(--line-strong); border-radius: 10px; background: #f8fafc; }

/* ---------- Alerte ---------- */
.alert { padding: .7rem .9rem; border-radius: 10px; font-size: .9rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert.err { background: var(--err-bg); color: var(--err); border-color: rgba(185, 28, 28, .25); }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: rgba(22, 101, 52, .25); }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(146, 64, 14, .25); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 1.8rem 1.7rem; }
.auth-card .brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; margin-bottom: 1.2rem; }
.auth-card .brand .dot { width: 1.05rem; height: 1.05rem; border-radius: 4px; background: var(--primary); }
.auth-toggle { display: flex; gap: .4rem; margin-bottom: 1.1rem; border: 1px solid var(--line); border-radius: 10px; padding: .2rem; }
.auth-toggle button { flex: 1; border: 0; background: transparent; padding: .5rem; border-radius: 8px; font-weight: 600; font-size: .9rem; color: var(--muted); cursor: pointer; }
.auth-toggle button.is-active { background: rgba(30, 64, 175, .1); color: var(--primary); }

/* ---------- Divers ---------- */
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.empty .big { font-size: 2rem; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 1.1rem 0; }
.kv { display: flex; justify-content: space-between; gap: 1rem; font-size: .88rem; padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; text-align: right; word-break: break-all; }
.spin { display: inline-block; width: 1rem; height: 1rem; border: 2px solid var(--line-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
