/* Jarvis : feuille de style unique du site. Aucune ressource externe. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #17202a;
  --muted: #56606b;
  --border: #dde1e6;
  --primary: #1d4ed8;
  --primary-hover: #1e3fae;
  --primary-soft: #e6edfd;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #166534;
  --ok-soft: #e3f6e9;
  --warn: #7a4100;
  --warn-soft: #fff4dc;
  --focus: #1d4ed8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; margin-top: 1.5em; }
h3 { font-size: 1.05rem; margin-top: 1.2em; }
.card > h2:first-child, .card > h3:first-child, .tabpanel > h2:first-child { margin-top: 0; }
p { margin: 0 0 0.75em; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
code, kbd, pre { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 0.9em; }
code, kbd { background: #eef1f5; border: 1px solid #e1e5ea; border-radius: 5px; padding: 0 5px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.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;
}
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 8px;
}
.skip:focus { top: 8px; color: #fff; }

/* En-tête ------------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 22px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; flex: none; }
.brand-fallback { display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a {
  color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500;
}
.mainnav a:hover { background: var(--surface-2); color: var(--primary); }
.mainnav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.navcount {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 0.75rem; text-align: center; line-height: 20px;
}
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 0.95rem; }
.linklike {
  background: none; border: none; padding: 6px 4px; color: var(--primary); cursor: pointer;
  font: inherit; text-decoration: underline; text-underline-offset: 3px;
}

.container { max-width: 1120px; margin: 0 auto; padding: 24px 20px 64px; }
.narrow { max-width: 480px; margin: 24px auto; }
.pagehead { margin-bottom: 18px; }
.pagehead h1 { margin-bottom: 4px; }
.lead { font-size: 1.05rem; color: var(--muted); }
.crumbs { margin: 0 0 10px; }
.crumbs a { text-decoration: none; font-weight: 500; }

/* Boutons et formulaires ----------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 9px;
  background: var(--primary); color: #fff; border: 1px solid var(--primary);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: #c5cbd3; }
.btn.secondary:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #e9a59f; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { min-height: 36px; padding: 5px 12px; font-size: 0.92rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; margin-top: 10px; }
.inline input { flex: 1 1 220px; }

.field { margin-bottom: 12px; }
.field > label, label.block, .sendform > label, .tech > label, .advanced > label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
input[type="text"], input:not([type]), input[type="password"], input[type="number"], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px;
  border: 1px solid #b9c0c9; border-radius: 9px; background: #fff; color: var(--text); font: inherit;
}
textarea { min-height: 220px; font-family: ui-monospace, Consolas, monospace; font-size: 0.88rem; }
input[type="file"] { font: inherit; max-width: 100%; }
.check, .switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.check input, .switch input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.formgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 16px;
  align-items: end; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
}
.formgrid > h3 { grid-column: 1 / -1; margin: 0 0 6px; }
.formgrid > details { grid-column: 1 / -1; }
details > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }

.msg { border-radius: 9px; padding: 10px 14px; margin: 10px 0; border: 1px solid transparent; }
.msg.error { background: var(--danger-soft); color: #8a1c13; border-color: #f3c1bc; }
.msg.ok { background: var(--ok-soft); color: var(--ok); border-color: #b9e5c7; }
.msg.warn { background: var(--warn-soft); color: var(--warn); border-color: #f2d59b; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.empty { color: var(--muted); padding: 18px; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

.tablewrap { overflow-x: auto; margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; font-size: 0.95rem; }
caption { text-align: left; font-weight: 600; padding: 0 0 6px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #eceff2; vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; font-size: 0.9rem; }
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }

/* Badges d'état ---------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent;
}
.badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state-offline { background: #eef0f3; color: #47505b; border-color: #dde1e6; }
.state-connecting { background: #e0ecff; color: #1e429f; border-color: #c3d6fb; }
.state-playing { background: #dcf5e4; color: #14532d; border-color: #b4e3c3; }
.state-sheltered { background: #ece7fd; color: #4c1d95; border-color: #d6cbfa; }
.state-dead { background: #fde4e2; color: #8f1d14; border-color: #f6c3be; }
.state-blocked { background: #fff1d6; color: #7a3e00; border-color: #f4d391; }
.state-paused { background: #e6eef5; color: #284b63; border-color: #c9d8e5; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.pill.on { background: var(--ok-soft); color: var(--ok); border-color: #b9e5c7; }

/* Accueil : blocs serveur et cartes bot --------------------------------------- */
.server { margin-bottom: 30px; }
.server-head {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 20px;
  padding-bottom: 12px; margin-bottom: 14px; border-bottom: 2px solid var(--border);
}
.server-head h2 { margin: 0; font-size: 1.35rem; }
.server-kind { font-weight: 500; color: var(--muted); }
.server-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 6px; color: var(--muted); font-size: 0.95rem; }
.server-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.addbot { margin: 0 0 14px; }
.addbot .inline { margin-top: 0; }
.botgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.botgrid > div { display: flex; min-width: 0; }
.botgrid > div > .botcard { flex: 1; min-width: 0; }
.botcard {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.botcard-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.botcard h3 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.botcard .activity { font-weight: 600; margin: 0; }
.botcard .activity.none { font-weight: 400; color: var(--muted); }
.problem { margin: 8px 0 0; font-size: 0.92rem; color: #8a1c13; background: var(--danger-soft); border-radius: 8px; padding: 6px 10px; }
.problem.warn { color: var(--warn); background: var(--warn-soft); }
.botcard .problem { margin: 0; }
.botcard-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.botcard-actions .btn { flex: 1; }

.vitals { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; font-size: 0.92rem; }
.vitals .label { color: var(--muted); }
.meter { height: 8px; border-radius: 6px; background: #e6e9ed; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 6px; background: #2f855a; }
.meter.health > span { background: #c53030; }
.meter.food > span { background: #b7791f; }
.meter.build > span { background: var(--primary); }

.progress { font-size: 0.92rem; }
.progress-label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.progress-steps { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; list-style: none; padding: 0; margin: 0; }
.progress-steps li { height: 8px; border-radius: 4px; background: #e2e5ea; }
.progress-steps li.done { background: #6d5bd0; }
.progress-steps li.current { background: #4c1d95; }
.progress-names { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; list-style: none; padding: 0; margin: 4px 0 0; font-size: 0.75rem; color: var(--muted); text-align: center; }
.progress-names li.current { color: #4c1d95; font-weight: 700; }

/* Page d'un bot ------------------------------------------------------------- */
.botheader { margin-bottom: 14px; }
.botheader-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.botheader-title h1 { margin: 0; overflow-wrap: anywhere; }
.botheader .muted { margin: 4px 0 0; }
.activity-big { font-size: 1.15rem; font-weight: 600; margin: 8px 0 10px; }
.botheader-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.tabs {
  display: flex; flex-wrap: wrap; gap: 2px; margin: 8px 0 18px;
  box-shadow: inset 0 -2px 0 var(--border);
}
.tabs [role="tab"] {
  flex: none; background: none; border: none; border-bottom: 3px solid transparent;
  padding: 10px 16px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; min-height: 44px;
}
.tabs [role="tab"]:hover { color: var(--text); }
.tabs [role="tab"][aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tabpanel:focus-visible { outline-offset: 6px; }

.overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.overview .card { margin: 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.chips li { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 0.9rem; }
.chips li b { font-weight: 700; }

.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick .group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.quick select { width: auto; min-width: 140px; }
.hint { color: var(--muted); font-size: 0.92rem; margin-top: 8px; }
.chatlog {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  height: 340px; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px;
}
.chatline { max-width: 85%; padding: 6px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); overflow-wrap: anywhere; }
.chatline .from { display: block; font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.chatline.me { align-self: flex-end; background: var(--primary-soft); border-color: #c8d6f7; }
.chatline.bot { align-self: flex-start; }
.chatline.other { align-self: flex-start; background: #fff; }
.sendform { margin-top: 12px; }

.events { list-style: none; padding: 0; margin: 0 0 18px; }
.events li {
  display: grid; grid-template-columns: 74px 1fr; gap: 12px; padding: 9px 12px;
  border-left: 4px solid #c5cbd3; background: var(--surface); border-radius: 0 8px 8px 0; margin-bottom: 6px;
}
.events time { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.events .count { color: var(--muted); font-size: 0.85rem; margin-left: 6px; }
.events li.success { border-left-color: #2f855a; }
.events li.warn { border-left-color: #d69e2e; }
.events li.error { border-left-color: #c53030; }
.events li.error .text { color: #8a1c13; font-weight: 600; }

.console {
  background: #111827; color: #e5e7eb; border-radius: 10px; padding: 12px 14px; margin: 8px 0;
  height: 340px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.82rem; line-height: 1.45;
}
.tech { margin-top: 10px; }

.uploadform { margin-top: 16px; }
.advanced summary { font-size: 1.05rem; }

/* Administration --------------------------------------------------------------- */
.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.subnav a { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; font-weight: 500; }
.servercard { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; background: var(--surface-2); }
.servercard h3 { margin: 0 0 8px; }
.memberlist { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 6px 0; }
.memberlist li { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 12px; }
.memberlist .btn { min-height: 30px; padding: 2px 10px; font-size: 0.85rem; }
.accessbot { padding: 12px 0; border-bottom: 1px solid var(--border); }
.accessbot:last-child { border-bottom: none; }
.accessbot h3 { margin: 0; font-size: 1rem; }

/* Aide et connexion -------------------------------------------------------------- */
.hero { padding: 16px 0 8px; }
.hero h1 { font-size: 2rem; }
.hero .lead { max-width: 720px; }
.steps { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; counter-reset: step; }
.steps li { counter-increment: step; margin: 0; }
.steps li h3 { margin-top: 0; }
.steps li h3::before { content: counter(step) '. '; color: var(--primary); }
.segmented { display: flex; gap: 6px; margin-bottom: 14px; }
.segmented [role="tab"] {
  flex: 1; min-height: 44px; border: 1px solid #c5cbd3; background: var(--surface); border-radius: 9px;
  font: inherit; font-weight: 600; color: var(--text); cursor: pointer;
}
.segmented [role="tab"][aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Checklist de test (page existante) --------------------------------------------- */
.stats { display: flex; gap: 12px; margin: 14px 0; flex-wrap: wrap; }
.stats .stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 18px; color: var(--muted); }
.stats .stat b { display: block; font-size: 1.2rem; color: var(--text); }
.testcat h2 { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 1.1rem; }
.testcat h2 .muted { font-size: 0.85rem; font-weight: 400; }
.testitem { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.testitem .tlabel { font-weight: 600; }
.testitem .thint { font-size: 0.88rem; color: var(--muted); }
.testitem .trow { display: flex; gap: 6px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.statusbtn { border: 1px solid #c5cbd3; background: var(--surface); border-radius: 8px; padding: 6px 12px; cursor: pointer; font: inherit; min-height: 36px; }
.statusbtn.yes.active { background: #15803d; border-color: #15803d; color: #fff; }
.statusbtn.partial.active { background: #b45309; border-color: #b45309; color: #fff; }
.statusbtn.no.active { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.testitem input.tsugg { flex: 1; min-width: 180px; }

/* Message temporaire ------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90;
  max-width: calc(100% - 32px); background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.toast.show { opacity: 1; }
.toast.error { background: #8a1c13; }

/* Téléphone ----------------------------------------------------------------------- */
@media (max-width: 640px) {
  .topbar { padding: 8px 16px; gap: 6px 12px; }
  .mainnav { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -6px; }
  .mainnav a { padding: 8px 10px; white-space: nowrap; }
  .who-name { display: none; }
  .container { padding: 16px 16px 56px; }
  h1, .hero h1 { font-size: 1.5rem; }
  .server-actions { width: 100%; }
  .server-actions .btn { flex: 1 1 auto; }
  .botgrid { grid-template-columns: 1fr; }
  .tabs { box-shadow: none; gap: 6px; }
  .tabs [role="tab"] {
    flex: 1 1 auto; border: 1px solid #c5cbd3; border-radius: 9px; padding: 8px 12px; background: var(--surface); color: var(--text);
  }
  .tabs [role="tab"][aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
  .events li { grid-template-columns: 1fr; gap: 2px; }
  .chatline { max-width: 95%; }
  .chatlog, .console { height: 300px; }
  td.actions { white-space: normal; }
  td.actions .btn { margin: 2px 0; }
  td.actions .btn + .btn { margin-left: 0; }
  /* Tableaux avec boutons : une ligne devient un petit bloc lisible sans défilement. */
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--border); }
  table.stack tr:last-child { border-bottom: none; }
  table.stack td { display: block; border: none; padding: 3px 12px; }
  table.stack td[data-label]::before { content: attr(data-label) ' : '; color: var(--muted); }
  table.stack td.actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 6px; }
  table.stack td.actions .btn { margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
