/* Panel des logs Kayz. Mise en page calquée sur le panel de référence (barre latérale, chiffres clés, filtres, tableau,
   détail en fenêtre). --accent = couleur du serveur réglée en jeu (F10 > Réglages > Couleur des menus). */
:root {
  --bg: #12151a;
  --panel: #191d23;
  --panel-2: #1f242b;
  --line: #262b33;
  --line-2: #323843;
  --text: #e6e8eb;
  --muted: #8a919c;
  --faint: #5f6672;
  --danger: #e5484d;
  --accent: #5db6e5;
  --accent-ink: #0d1a22;
  --radius: 10px;
  --font: 'Archivo', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(700px 320px at 50% -80px, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px 24px 22px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; font-weight: 800; font-stretch: 85%; letter-spacing: -0.01em; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.login-card kbd { font: 600 13px var(--font); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px; color: var(--text); }
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; text-transform: uppercase; }
.login-card .btn { width: 100%; margin-top: 12px; padding: 11px; }
.login-error { color: var(--danger); margin-top: 10px; font-size: 13px; min-height: 18px; }

/* ---------------------------------------------------------------- structure */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--bg); border-right: 1px solid var(--line); padding: 14px 12px 24px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 4px 16px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  font-weight: 800; font-size: 17px; font-stretch: 85%; }
.brand b { display: block; font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 12.5px; }
.side h2 { margin: 14px 6px 6px; font-size: 12px; font-weight: 600; color: var(--faint); }
.nav a, .cat { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav a:hover, .cat:hover { background: var(--panel); }
.nav a.on, .cat.on { background: color-mix(in srgb, var(--accent) 13%, var(--panel)); }
.nav svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.nav .count, .cat .count { margin-left: auto; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 18%, var(--panel)); color: color-mix(in srgb, var(--accent) 70%, white); font-variant-numeric: tabular-nums; }
.cat-filter { position: relative; margin: 2px 0 6px; }
.cat-filter input { width: 100%; padding: 7px 10px 7px 30px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.cat-filter svg { position: absolute; left: 10px; top: 50%; translate: 0 -50%; width: 13px; height: 13px; color: var(--faint); }
.cat { width: 100%; border: 0; background: none; text-align: left; font-size: 13.5px; }
.cat .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.cat .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat.empty { color: var(--faint); }
.side-foot { margin-top: 18px; padding: 10px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.side-foot button { background: none; border: 0; color: var(--muted); padding: 0; text-decoration: underline; text-underline-offset: 3px; }

.main { min-width: 0; padding: 18px 24px 40px; }
.crumbs { color: var(--muted); font-size: 12.5px; }
.crumbs a { color: inherit; text-decoration: none; }
.head { display: flex; align-items: flex-end; gap: 16px; margin: 10px 0 16px; }
.head h1 { margin: 0; font-size: 24px; font-weight: 800; font-stretch: 85%; letter-spacing: -0.01em; }
.head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.head .actions { margin-left: auto; display: flex; gap: 8px; }

/* direct : point qui respire tant que le panel suit les nouveaux logs */
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; background: var(--panel); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live.on i { background: #3dd68c; box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.6); animation: breathe 2.4s ease-out infinite; }
.live.on { color: var(--text); }
@keyframes breathe { 70% { box-shadow: 0 0 0 7px rgba(61, 214, 140, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 214, 140, 0); } }

/* ---------------------------------------------------------------- chiffres clés */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; min-width: 0; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat b { display: block; font-size: 19px; font-weight: 700; margin: 2px 0 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- filtres */
.filters { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 15px; height: 15px; color: var(--faint); }
.filters .search input { width: 100%; padding: 10px 12px 10px 36px; }
.field-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.filters input, .field input { width: 100%; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; }
.filters input:focus { border-color: var(--accent); outline: none; }
.filter-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.filter-actions .total { margin-left: auto; color: var(--muted); font-size: 12.5px; }

.btn { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 13px; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #ffb4b6; border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: color-mix(in srgb, var(--danger) 10%, var(--panel)); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------------------------------------------------------------- tableau */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13.5px; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.fresh td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
td.date { white-space: nowrap; color: var(--text); font-variant-numeric: tabular-nums; }
td.date small { display: block; color: var(--muted); }
td.mono { font-variant-numeric: tabular-nums; color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.msg { min-width: 260px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; white-space: nowrap;
  color: color-mix(in srgb, var(--c) 75%, white); background: color-mix(in srgb, var(--c) 17%, transparent); }
.empty-state { padding: 46px 16px; text-align: center; color: var(--muted); }
.more { display: flex; justify-content: center; padding: 14px; }

/* ---------------------------------------------------------------- détail */
dialog { border: 1px solid var(--line-2); border-radius: 14px; background: var(--panel); color: var(--text); padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: rgba(5, 7, 10, 0.72); }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.dlg-head .meta { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.dlg-close { margin-left: auto; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); display: grid; place-items: center; }
.dlg-body { padding: 16px 18px 18px; overflow-y: auto; }
.dlg-body h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 16px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.kv div span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.kv div b { font-weight: 600; word-break: break-all; font-variant-numeric: tabular-nums; }
.kv .wide { grid-column: 1 / -1; }
.kv-title { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 4px 0 6px; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 0 18px 16px; }

/* ---------------------------------------------------------------- administration */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.tabs button.on { color: var(--text); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.card-head b { font-size: 15px; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .dot { width: 8px; height: 8px; border-radius: 50%; }
.row small { display: block; color: var(--muted); font-size: 12.5px; }
.row .right { margin-left: auto; display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; }
.perm-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0 16px; }
.perm-group { padding: 12px 16px 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.perm { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: var(--bg); }
.perm:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.perm input { accent-color: var(--accent); margin-top: 3px; }
.perm b { display: block; font-size: 13.5px; font-weight: 600; }
.perm small { color: var(--muted); font-size: 12px; }
.editor-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 16px; }
.note { color: var(--muted); font-size: 12.5px; padding: 12px 16px; }
.toast { position: fixed; bottom: 18px; left: 50%; translate: -50% 0; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 14px; font-size: 13px; z-index: 20; }

/* ---------------------------------------------------------------- petits écrans */
.menu-btn { display: none; }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .field-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } .perm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 10; inset: 0 auto 0 0; width: 260px; translate: -100% 0; transition: translate 0.2s ease; }
  .shell.open .side { translate: 0 0; }
  .menu-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel); }
  .main { padding: 14px 16px 32px; }
  .stats, .field-row, .perm-grid { grid-template-columns: 1fr; }
  .head { flex-wrap: wrap; align-items: center; }
}
@media (prefers-reduced-motion: reduce) { .live.on i { animation: none; } .side { transition: none; } }

/* ---------------------------------------------------------------- connexion Discord, membres, rangs */
.btn.discord { display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; padding: 11px; width: 100%; }
.btn.discord[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.login-foot { margin: 14px 0 0 !important; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; text-align: center; }
.side-foot { display: flex; gap: 10px; align-items: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; object-fit: cover; }
.avatar.ph { display: grid; place-items: center; background: var(--panel-2); color: var(--muted); font-weight: 700; }
.add-member, .rank-fields { display: flex; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.add-member .grow, .rank-fields .grow { flex: 1 1 260px; }
.field select, .row select { background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; }
.field input, .field select { width: 100%; }
.field input[type=color] { width: 54px; height: 37px; padding: 3px; }
.row .seen { min-width: 110px; text-align: right; }
.row select { padding: 6px 8px; }
.perm input:disabled + span { opacity: 0.45; }

.brand-logo { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; flex: none; }
.login-logo { display: block; width: 88px; height: 88px; margin: 0 auto 14px; border-radius: 18px; object-fit: cover; }

/* Kayz Cloud : choix du serveur (une clé de licence = un serveur client) */
.tenant-pick { display: flex; flex-direction: column; gap: 5px; margin: 0 4px 16px; font-size: 12px; opacity: .9; }
.tenant-pick select { width: 100%; padding: 7px 9px; border-radius: 8px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06); color: inherit; font: inherit; font-size: 13px; }
