/* Tableau de bord Better Bot : thème sombre, proche de Discord ; accent : rouge de la marque (logo) */
:root {
  --bg: #1e1f22;
  --surface: #2b2d31;
  --surface-2: #313338;
  --surface-3: #383a40;
  --border: #3f4147;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --faint: #80848e;
  --accent: #f23f43;
  --accent-ink: #ffffff;
  --primary: #5865f2;
  --primary-hover: #4752c4;
  --success: #23a55a;
  --danger: #da373c;
  --radius: 10px;
  --gap: 16px;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: .9rem; }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: var(--gap);
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
#me { display: flex; align-items: center; gap: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); object-fit: cover; flex: none; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }

/* Éléments de formulaire */
select, input[type="text"], input[type="number"], textarea {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
select:focus, input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer; font-weight: 600;
  background: var(--surface-3); color: var(--text);
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); filter: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: 6px 10px; font-size: .9rem; }

/* Interrupteur on/off */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 24px; border-radius: 12px; background: var(--faint); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Cases à cocher en grille */
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--primary); }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.wide { gap: 24px; }
.grow { flex: 1; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* Connexion */
.login { max-width: 440px; margin: 10vh auto 0; text-align: center; }
.login img { margin-bottom: 14px; }
.login p { color: var(--muted); margin: 10px 0 22px; }

/* Liste des serveurs */
.guilds { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--gap); margin-top: 18px; }
.guild-card { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: border-color .15s, transform .15s; }
.guild-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.guild-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--surface-3); display: grid; place-items: center; font-weight: 700; flex: none; object-fit: cover; }

/* Page d'un serveur */
.guild-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; color: var(--muted); cursor: pointer; font-weight: 600; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* Modules : liste à gauche, réglages à droite */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; cursor: pointer; color: var(--muted); }
.chip-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.modules { display: grid; grid-template-columns: 300px 1fr; gap: var(--gap); align-items: start; }
.module-list { display: flex; flex-direction: column; gap: 4px; }
.module-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; border: 1px solid transparent; background: var(--surface); cursor: pointer; }
.module-item:hover { background: var(--surface-2); }
.module-item[aria-current="true"] { border-color: var(--accent); background: var(--surface-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--success); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-title { font-weight: 600; font-size: .92rem; color: var(--muted); text-transform: none; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--gap); }
.section-title { font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); font-weight: 700; margin-top: 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* Éléments d'une liste (membres, salons, rôles) */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--surface-3); font-size: .9rem; max-width: 100%; }
.tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag button { border: 0; background: none; cursor: pointer; color: var(--faint); font-size: 1rem; line-height: 1; padding: 0 4px; }
.tag button:hover { color: var(--danger); }
.role-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Tableau des droits */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--faint); font-size: .85rem; font-weight: 600; }
td.center, th.center { text-align: center; }

.lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--gap); }

/* Statistiques : couleurs des séries validées pour la surface sombre (bleu, orange) */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap); }
.tile { display: flex; flex-direction: column; gap: 4px; }
.tile-label { color: var(--muted); font-size: .9rem; }
.tile-value { font-size: 1.9rem; line-height: 1.1; }
.tile-value.text { font-size: 1.2rem; line-height: 1.3; }
.chart { --series-1: #3987e5; --series-2: #d95926; --grid: #3f4147; display: flex; flex-direction: column; gap: 10px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.legend span, .chart-tooltip span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch.s1 { background: #3987e5; }
.swatch.s2 { background: #d95926; }
.plot { position: relative; height: 200px; margin-left: 44px; }
.tick { position: absolute; left: 0; right: 0; border-top: 1px solid var(--grid); }
.tick span { position: absolute; right: calc(100% + 8px); transform: translateY(-50%); color: var(--faint); font-size: .8rem; font-variant-numeric: tabular-nums; }
.columns { position: absolute; inset: 0; display: flex; align-items: stretch; gap: 2px; }
.column { flex: 1; display: flex; flex-direction: column-reverse; align-items: center; gap: 2px; cursor: default; border-radius: 4px; }
.column:hover, .column:focus-visible { background: rgba(255,255,255,.04); outline: none; }
.segment { width: 100%; max-width: 24px; flex: none; }
.segment.s1 { background: var(--series-1); }
.segment.s2 { background: var(--series-2); }
.column > .segment:last-child { border-radius: 4px 4px 0 0; }
.chart-tooltip { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; gap: 4px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: .85rem; white-space: nowrap; pointer-events: none; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.chart-tooltip[hidden] { display: none; }
.x-axis { display: flex; justify-content: space-between; margin-left: 44px; color: var(--faint); font-size: .8rem; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; align-items: center; gap: 12px; }
.hbar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 12px; }
.hbar-fill { height: 100%; min-width: 4px; background: #3987e5; border-radius: 0 4px 4px 0; }
.hbar-value { color: var(--muted); font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table summary { cursor: pointer; color: var(--muted); }
.data-table table { margin-top: 10px; }
@media (max-width: 760px) { .hbar { grid-template-columns: minmax(0, 1fr) auto; } .hbar-track { grid-column: 1 / -1; grid-row: 2; } }

/* Notifications */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 20; max-width: calc(100vw - 32px); }
.toast { background: var(--surface-3); border-left: 4px solid var(--success); padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.toast.error { border-left-color: var(--danger); }

.empty { color: var(--muted); padding: 24px; text-align: center; }
.loading { color: var(--muted); padding: 40px; text-align: center; }

@media (max-width: 760px) {
  .modules { grid-template-columns: 1fr; }
  main { padding: 16px 16px 48px; }
  .topbar .brand span { display: none; }
  #me .name { display: none; }
}
