/* Interface d'administration du hub A2MPL. Couleurs de l'agence, thème clair et sombre. */
:root {
  color-scheme: light dark;
  --bg: #f0f0eb;
  --fg: #141312;
  --muted: #5b5853;
  --accent: #b8360f;
  --accent-fg: #ffffff;
  --card: #ffffff;
  --sunk: #e7e6e0;
  --line: #d9d6cf;
  --ok: #2f7a4b;
  --ok-bg: #e3f1e7;
  --warn: #8a5a00;
  --warn-bg: #f7ecd2;
  --err: #a8321a;
  --err-bg: #f8e1da;
  --info: #3b5b8c;
  --info-bg: #e2e9f4;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312;
    --fg: #f0f0eb;
    --muted: #a9a59d;
    --accent: #e0531f;
    --card: #1f1d1b;
    --sunk: #191816;
    --line: #34312d;
    --ok: #7fcf9b;
    --ok-bg: #1d3325;
    --warn: #e6c071;
    --warn-bg: #3a2f17;
    --err: #f08f78;
    --err-bg: #3d211a;
    --info: #9db8e3;
    --info-bg: #1e2a3d;
  }
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px / 1.55 var(--font);
}
a {
  color: var(--accent);
}
h1 {
  font-size: 1.5rem;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 1.1rem;
  margin: 28px 0 12px;
}
h3 {
  font-size: 1rem;
  margin: 0;
}
p {
  margin: 0 0 10px;
}
code,
pre {
  font-family: var(--mono);
  font-size: 0.86em;
}
code {
  background: var(--sunk);
  padding: 1px 5px;
  border-radius: 4px;
  overflow-wrap: anywhere;
}
pre {
  background: var(--sunk);
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
}
pre code {
  background: none;
  padding: 0;
}
td code {
  white-space: nowrap;
  overflow-wrap: normal;
}
.muted {
  color: var(--muted);
}
.note {
  margin-top: 16px;
}
small,
.small {
  font-size: 0.85rem;
}

/* --- Cadre ------------------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}
.side {
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  padding: 0 8px 18px;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--fg);
  text-decoration: none;
  font-weight: 500;
}
.nav a:hover {
  background: var(--sunk);
}
.nav a[aria-current="page"] {
  background: var(--sunk);
  color: var(--accent);
}
.nav svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.who {
  margin-top: auto;
  padding: 12px 10px 0;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}
.who strong {
  display: block;
}
.who form {
  margin-top: 8px;
}
.main {
  padding: 28px clamp(16px, 4vw, 44px) 60px;
  max-width: 1120px;
  width: 100%;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head p {
  margin: 0;
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .side {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand {
    padding: 0 8px 0 0;
  }
  .nav {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    max-width: 100%;
  }
  .nav a {
    padding: 6px 9px;
    white-space: nowrap;
  }
  .nav a span.label {
    display: none;
  }
  .who {
    margin: 0 0 0 auto;
    border: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .who strong,
  .who .role {
    display: none;
  }
  .who form {
    margin: 0;
  }
  .main {
    padding-top: 20px;
  }
}

/* --- Composants ---------------------------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
}
.card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
}
.grid .card {
  margin: 0;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--sunk);
  color: var(--muted);
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge.ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.badge.err {
  background: var(--err-bg);
  color: var(--err);
}
.badge.info {
  background: var(--info-bg);
  color: var(--info);
}
.badge.plain::before {
  display: none;
}
.notice {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 14px;
  border: 1px solid transparent;
}
.notice.ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.notice.warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.notice.err {
  background: var(--err-bg);
  color: var(--err);
}
.notice.info {
  background: var(--info-bg);
  color: var(--info);
}
.notice p:last-child {
  margin: 0;
}
.notice code {
  background: rgba(127, 127, 127, 0.15);
}
.secret-once {
  border: 2px solid var(--accent);
  background: var(--card);
  color: var(--fg);
}
.secret-once code {
  font-size: 0.95rem;
  display: inline-block;
  padding: 6px 8px;
  margin: 6px 0;
}

details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 6px 0;
}
details[open] > summary {
  margin-bottom: 8px;
}
ol.steps {
  margin: 0 0 8px;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}
.steps li {
  margin: 3px 0;
}

/* --- Formulaires ----------------------------------------------------------------------------------- */
label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 12px 0 4px;
}
.field-help {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}
textarea {
  resize: vertical;
  min-height: 70px;
  font-family: var(--mono);
  font-size: 0.85rem;
}
input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.65;
}
.inline {
  display: flex;
  gap: 8px;
  align-items: center;
}
.inline input {
  flex: 1;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  margin: 6px 14px 0 0;
  font-size: 0.88rem;
}
.row {
  display: grid;
  gap: 0 14px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
}
.actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
}
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button.ghost,
.button.ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--line);
}
button.ghost:hover {
  background: var(--sunk);
}
button.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font-weight: 500;
}
button.danger {
  background: transparent;
  color: var(--err);
  border-color: var(--line);
}
button.small {
  padding: 4px 10px;
  font-size: 0.85rem;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.source {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}

/* --- Tableaux -------------------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
th,
td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--sunk);
}
tr:last-child td {
  border-bottom: 0;
}
.table-wrap form {
  margin: 0;
}
.empty-row {
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

/* --- Résultats de test ----------------------------------------------------------------------------- */
.probe {
  margin-top: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  font-size: 0.88rem;
}
.probe ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.probe li {
  padding: 2px 0 2px 20px;
  position: relative;
  overflow-wrap: anywhere;
}
.probe li::before {
  position: absolute;
  left: 0;
  font-weight: 700;
}
.probe li.ok::before {
  content: "✓";
  color: var(--ok);
}
.probe li.error::before {
  content: "✕";
  color: var(--err);
}
.probe li.info::before {
  content: "i";
  color: var(--info);
}
.probe .found {
  margin-top: 8px;
}
.probe .found code {
  display: inline-block;
  margin: 2px 4px 2px 0;
}

/* --- Assistant ------------------------------------------------------------------------------------- */
.chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 88px);
  min-height: 480px;
}
.chat-head {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.chat-head h1 {
  margin: 0 auto 0 0;
}
.chat-head label {
  margin: 0;
  font-weight: 500;
}
.chat-head select {
  width: auto;
  min-width: 220px;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg {
  max-width: min(760px, 92%);
  border-radius: 12px;
  padding: 10px 14px;
  overflow-wrap: anywhere;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-fg);
  white-space: pre-wrap;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--sunk);
}
.msg.error {
  align-self: flex-start;
  background: var(--err-bg);
  color: var(--err);
}
.msg p {
  margin: 0 0 8px;
}
.msg p:last-child,
.msg ul:last-child,
.msg ol:last-child,
.msg pre:last-child,
.msg .md-table:last-child {
  margin-bottom: 0;
}
.msg ul,
.msg ol {
  margin: 0 0 8px;
  padding-left: 20px;
}
.msg h3,
.msg h4 {
  margin: 10px 0 6px;
  font-size: 0.98rem;
}
.msg blockquote {
  margin: 0 0 8px;
  padding-left: 10px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.msg .md-table {
  overflow-x: auto;
  margin: 0 0 8px;
}
.msg table {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.msg th {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.82rem;
}
.msg .meta {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}
.msg.pending {
  color: var(--muted);
}
.dots::after {
  content: "…";
  animation: blink 1.2s infinite;
}
@keyframes blink {
  50% {
    opacity: 0.2;
  }
}
@media (prefers-reduced-motion: reduce) {
  .dots::after {
    animation: none;
  }
}
.chat-empty {
  margin: auto;
  text-align: center;
  max-width: 520px;
  color: var(--muted);
}
.chat-empty h2 {
  color: var(--fg);
  margin-top: 0;
}
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}
.suggestions button {
  font-weight: 500;
}
.chat-form {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  align-items: flex-end;
}
.chat-form textarea {
  font-family: var(--font);
  font-size: 0.95rem;
  min-height: 46px;
  max-height: 220px;
}
.chat-foot {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* --- Connexion ------------------------------------------------------------------------------------- */
.solo {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.solo .card {
  width: 100%;
  max-width: 440px;
  padding: 28px;
}
.solo .brand {
  padding: 0 0 18px;
}
fieldset.choices {
  border: 0;
  padding: 0;
  margin: 12px 0 0;
}
fieldset.choices legend {
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0;
  margin-bottom: 4px;
}
