/* WoW Guild Manager — interface d'administration */
:root {
  color-scheme: dark;
  --bg: #0e0c0d;
  --panel: #161315;
  --panel-2: #1c181a;
  --line: #2a2427;
  --line-2: #352e32;
  --text: #ece6e3;
  --muted: #988e8a;
  --faint: #5f5653;
  --gold: #e2b04a;
  --red: #d64b3c;
  --red-deep: #8f2a20;
  --green: #4cc38a;
  --amber: #e8a33d;
  --blue: #7fb2e5;
  --discord: #5865f2;
  --term: #0a0909;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  background-image: radial-gradient(1200px 500px at 15% -10%, rgba(143, 42, 32, .18), transparent 60%);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; }
h1 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
code { font-family: var(--mono); font-size: .92em; color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }

/* ---- Boutons et champs ---- */
.btn {
  appearance: none; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  font: 600 13px var(--sans); padding: 8px 12px; border-radius: 8px; cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s; text-decoration: none;
}
.btn:hover:not(:disabled) { background: #251f22; border-color: #43393e; }
.btn:focus-visible, input:focus-visible, select:focus-visible, .tab:focus-visible, summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn-primary { background: var(--red-deep); border-color: #a83a2e; }
.btn-primary:hover:not(:disabled) { background: #a3322a; border-color: #c24636; }
.btn-danger { color: #ff9a8e; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: #211c1f; border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-wide { width: 100%; padding: 11px; }
.btn.armed { background: var(--red); border-color: var(--red); color: #fff; }
.btn-discord { display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: var(--discord); border-color: var(--discord); color: #fff; }
.btn-discord:hover:not(:disabled) { background: #4752c4; border-color: #4752c4; }
select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 7px;
  padding: 6px 8px; font: 13px var(--sans); max-width: 100%; min-width: 0;
}
.field { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.error { background: rgba(214, 75, 60, .1); border: 1px solid rgba(214, 75, 60, .38); color: #ff9a8e; border-radius: 8px; padding: 9px 12px; margin: 0 0 14px; font-size: 13px; }
.notice { background: rgba(226, 176, 74, .08); border: 1px solid rgba(226, 176, 74, .3); color: #edd29a; border-radius: 8px; padding: 9px 12px; margin: 0 0 14px; font-size: 13px; }

/* ---- Barre du haut ---- */
.topbar {
  height: 60px; display: flex; align-items: center; gap: 24px;
  padding: 0 20px; border-bottom: 1px solid var(--line); background: rgba(14, 12, 13, .9);
}
.brand { display: flex; gap: 11px; align-items: center; min-width: 0; }
.brand strong { display: block; font-size: 15px; white-space: nowrap; }
.brand > div > span { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .version {
  display: inline-block; font: 600 10.5px var(--mono); color: var(--gold); vertical-align: 2px;
  background: rgba(226, 176, 74, .1); border: 1px solid rgba(226, 176, 74, .28); border-radius: 5px; padding: 1px 6px; margin-left: 6px;
}
.brand .version.outdated { color: #ff9a8e; background: rgba(214, 75, 60, .12); border-color: rgba(214, 75, 60, .45); }
.brand .version.outdated::after { content: " · redémarrage requis"; }
.tabs { display: flex; gap: 4px; height: 100%; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  font: 600 13.5px var(--sans); padding: 0 12px; cursor: pointer; height: 100%;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--red); }
.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.topbar-right form { margin: 0; }
.conn { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.conn.off i { background: var(--amber); animation: pulse 1.4s infinite; }
.me { display: flex; align-items: center; gap: 9px; padding: 3px 12px 3px 3px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); }
.me img { border-radius: 50%; background: var(--panel-2); object-fit: cover; }
.me-text { display: flex; flex-direction: column; line-height: 1.15; }
.me-text span:first-child { font-size: 13px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.level { font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.level.l3 { color: var(--gold); }
.level.l2 { color: var(--blue); }

/* ---- Mise en page ---- */
.layout {
  height: calc(100% - 60px); display: grid; grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px; padding: 16px 20px 20px;
}
.side { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; }
.view { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
#view-access { overflow-y: auto; gap: 14px; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.view-head p { margin: 6px 0 0; max-width: 720px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-grow { flex: 1; min-height: 140px; display: flex; flex-direction: column; gap: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }

/* ---- État du bot ---- */
.state-row { display: flex; align-items: center; gap: 12px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 5px rgba(76, 195, 138, .13); }
.dot.wait { background: var(--amber); box-shadow: 0 0 0 5px rgba(232, 163, 61, .13); animation: pulse 1.4s infinite; }
.dot.off { background: var(--red); box-shadow: 0 0 0 5px rgba(214, 75, 60, .13); }
@keyframes pulse { 50% { opacity: .45; } }
.state-label { font-size: 17px; font-weight: 700; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0; }
.metrics div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
.metrics dt { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.metrics dd { margin: 2px 0 0; font: 600 16px var(--mono); font-variant-numeric: tabular-nums; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.switch { display: flex; align-items: center; gap: 10px; margin-top: 14px; cursor: pointer; font-size: 13px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch input:disabled ~ span { opacity: .5; cursor: not-allowed; }
.track { width: 34px; height: 20px; border-radius: 20px; background: #3a3236; position: relative; flex: none; transition: background .15s; }
.thumb { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track .thumb { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--gold); outline-offset: 2px; }
#restarts, #backup { margin: 8px 0 0; }
#backup { margin: 0; }
.guilds { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.guilds li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.guilds li:first-child { border-top: 0; }
.guilds .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guilds .count { color: var(--muted); font: 12px var(--mono); white-space: nowrap; }

/* ---- Console ---- */
.console {
  position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0;
  background: var(--term); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.console-head { display: flex; align-items: center; gap: 12px; padding: 9px 10px 9px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.console-title { font-weight: 700; font-size: 13.5px; }
#console-hint { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.console-tools { display: flex; gap: 4px; }
.term {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 16px;
  font: 12.5px/1.6 var(--mono); color: #d8d1cd; outline: none; overscroll-behavior: contain;
}
.ln { display: grid; grid-template-columns: 74px minmax(0, 1fr); white-space: pre-wrap; word-break: break-word; }
.ln .ts { color: var(--faint); user-select: none; }
.k-panel .tx { color: var(--blue); }
.k-out .tx { color: #e8e0dc; }
.k-err .tx, .lvl-err .tx { color: #ff8b7d; }
.lvl-warn .tx { color: var(--amber); }
.k-cmd { margin-top: 6px; }
.k-cmd .tx { color: var(--gold); font-weight: 600; }
.k-cmd .tx::before { content: "› "; color: var(--red); }
.k-cmd .who { color: var(--muted); font-weight: 400; margin-left: 10px; font-size: 11.5px; }
.k-cmd .who::before { content: "par "; }
.jump {
  position: absolute; right: 18px; bottom: 64px; border: 1px solid var(--line-2); background: var(--panel-2);
  color: var(--text); font: 600 12px var(--sans); padding: 7px 12px; border-radius: 20px; cursor: pointer;
}
.prompt { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); background: #100e0f; }
.ps1 { font: 700 15px var(--mono); color: var(--red); }
.prompt input { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text); font: 13px var(--mono); padding: 6px 0; caret-color: var(--gold); }
.prompt input:focus-visible { outline: none; }
.prompt input::placeholder { color: var(--faint); }

/* ---- Tableaux (accès) ---- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 0 8px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table .w-level { width: 150px; }
.table td.empty { color: var(--muted); font-size: 12.5px; padding: 14px 0; }
.table.perms td:not(:first-child), .table.perms th:not(:first-child) { text-align: center; width: 92px; }
.table.perms td:not(:first-child) { color: var(--green); }
.cell-user { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cell-user img { width: 24px; height: 24px; border-radius: 50%; flex: none; object-fit: cover; background: var(--panel-2); }
.cell-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: #99aab5; }
.pill { display: inline-block; font: 600 11px var(--sans); padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line-2); color: var(--muted); }
.pill.l3 { color: var(--gold); border-color: rgba(226, 176, 74, .35); }
.pill.l2 { color: var(--blue); border-color: rgba(127, 178, 229, .35); }
.add-role { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.mono { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ---- Connexion ---- */
.login-page { display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; text-align: center; }
.login-logo { display: block; margin: 0 auto 14px; }
.login-card h1 { font-size: 21px; }
.login-card > .muted { margin: 4px 0 24px; }
.login-card form { text-align: left; display: grid; gap: 8px; }
.login-card label { font-size: 12.5px; color: var(--muted); }
.login-card input { width: 100%; background: var(--term); border: 1px solid var(--line-2); color: var(--text); border-radius: 8px; padding: 11px 12px; font: 14px var(--sans); margin-bottom: 8px; }
.hint { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); }
.owner-login { margin-top: 20px; text-align: left; border-top: 1px solid var(--line); padding-top: 14px; }
.owner-login summary { cursor: pointer; color: var(--muted); font-size: 12.5px; text-align: center; list-style: none; }
.owner-login summary::-webkit-details-marker { display: none; }
.owner-login summary::after { content: " ▾"; }
.owner-login[open] summary { margin-bottom: 12px; }
.login-foot { margin: 18px 0 0; font-size: 11.5px; color: var(--faint); }

/* ---- Écrans étroits ---- */
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  html, body { height: auto; }
  .topbar { padding: 0 16px; gap: 12px; flex-wrap: wrap; height: auto; min-height: 56px; }
  .brand > div > span, .conn span, .me-text { display: none; }
  .tabs { order: 3; width: 100%; height: 42px; border-top: 1px solid var(--line); }
  .me { padding: 2px; }
  .layout { height: auto; grid-template-columns: 1fr; padding: 12px 16px 16px; }
  .side { overflow: visible; }
  .console { height: 72vh; flex: none; }
  .card-grow { min-height: 0; }
  .ln { grid-template-columns: 1fr; }
  .ln .ts { display: none; }
  #console-hint { display: none; }
  .hide-sm { display: none; }
  .add-role { grid-template-columns: 1fr 1fr; }
  .add-role select:first-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
