/* Panel du bot — thème sombre inspiré de Discord */
:root {
  --bg: #1e1f22;
  --bg-side: #17181b;
  --surface: #2b2d31;
  --surface-2: #232428;
  --input: #1e1f22;
  --border: #3a3c42;
  --text: #dbdee1;
  --text-strong: #f2f3f5;
  --muted: #949ba4;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #23a55a;
  --warning: #f0b232;
  --danger: #da373c;
  --mention-bg: rgba(88, 101, 242, 0.3);
  --radius: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "gg sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: #00a8fc; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--text-strong); margin: 0; }
h1 { font-size: 22px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.boot, .loading-page { padding: 48px; color: var(--muted); text-align: center; }

/* ── Mise en page ─────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex-shrink: 0; background: var(--bg-side); padding: 16px 12px 24px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid #111214;
}
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 24px 32px 120px; max-width: 1180px; width: 100%; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text-strong); font-size: 16px; padding: 4px 8px 16px; }
.brand img { width: 32px; height: 32px; border-radius: 50%; }
.guild-switch-wrap { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: var(--radius); padding: 8px; margin-bottom: 16px; }
.guild-switch { flex: 1; min-width: 0; background: transparent; border: none; font-weight: 600; padding: 4px; }
.nav-group { margin-bottom: 14px; }
.nav-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 10px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: #b5bac1; font-weight: 500; }
.nav-item:hover { background: #2e3035; color: var(--text-strong); text-decoration: none; }
.nav-item.active { background: #35373c; color: #fff; }
.nav-icon { width: 20px; text-align: center; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 32px; border-bottom: 1px solid #111214; background: var(--bg); position: sticky; top: 0; z-index: 5; }
.topbar .avatar { width: 28px; height: 28px; border-radius: 50%; }
.topbar .username { font-weight: 600; }
.topbar .menu-toggle { display: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head p { margin: 6px 0 0; max-width: 760px; }
.head-toggle { display: flex; align-items: center; gap: 10px; font-weight: 600; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); }

/* ── Cartes ───────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 20px; }
.card-head p { margin: 4px 0 0; }
.card-body { padding: 4px 20px 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.grid-2 .card { margin-bottom: 16px; }

.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: #b5bac1; margin-bottom: 6px; }
.field-hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.row > .field, .row > .input { flex: 1; min-width: 160px; }

/* ── Contrôles ────────────────────────────────────────────── */
.input {
  width: 100%; background: var(--input); color: var(--text); border: 1px solid #111214; border-radius: 6px;
  padding: 9px 11px; font: inherit; outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }
.input-number { max-width: 160px; }
select.input { cursor: pointer; }
textarea.input { resize: vertical; min-height: 44px; }
.textarea-wrap { position: relative; }
.counter { position: absolute; right: 10px; bottom: 8px; font-size: 11px; color: var(--muted); pointer-events: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 6px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; color: #fff; text-decoration: none; white-space: nowrap;
  transition: background .15s, opacity .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); }
.btn-success:hover { background: #1a8b4b; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a12828; }
.btn-ghost { background: #3a3c42; color: var(--text); }
.btn-ghost:hover { background: #45474e; }
.btn-discord { background: var(--accent); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.loading::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider { position: absolute; inset: 0; background: #80848e; border-radius: 24px; transition: background .2s; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid #00a8fc; outline-offset: 2px; }
.inline-check { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; cursor: pointer; }

.tabs { display: inline-flex; background: var(--input); border-radius: 8px; padding: 4px; margin: 4px 0 16px; gap: 4px; flex-wrap: wrap; }
.tab { background: transparent; border: none; color: var(--muted); padding: 8px 16px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.active { background: #404249; color: #fff; }

.palette { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--input); padding: 8px 10px; border-radius: 6px; width: fit-content; }
.swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.active { outline: 2px solid #fff; outline-offset: 2px; }
.color-input { width: 26px; height: 26px; border: none; padding: 0; background: none; cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #3a3c42; color: var(--text); border: none; border-radius: 14px; padding: 4px 10px; font: inherit; font-size: 13px; }
button.chip { cursor: pointer; }
button.chip:hover { background: #45474e; }
.chip-var { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--mention-bg); color: #c9cdfb; }
.chip-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0; }
.chip-x:hover { color: #fff; }
.var-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 14px; }

.list-editor { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.list-item { display: flex; gap: 8px; width: 100%; align-items: flex-start; background: var(--surface-2); padding: 10px; border-radius: 6px; }
.list-item .grow > * + * { margin-top: 8px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.badge-neutral { background: #3a3c42; color: #b5bac1; }
.badge-success { background: rgba(35, 165, 90, .2); color: #57d48a; }
.badge-warning { background: rgba(240, 178, 50, .18); color: #f5c85b; }
.badge-danger { background: rgba(218, 55, 60, .2); color: #f27c7f; }

.notice { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; border-left: 4px solid; }
.notice-info { background: rgba(88, 101, 242, .12); border-color: var(--accent); }
.notice-warning { background: rgba(240, 178, 50, .1); border-color: var(--warning); }
.notice-error { background: rgba(218, 55, 60, .12); border-color: var(--danger); }
.empty { color: var(--muted); padding: 18px; text-align: center; background: var(--surface-2); border-radius: 6px; }

.table { display: flex; flex-direction: column; gap: 6px; }
.table-row { display: flex; align-items: center; gap: 12px; background: var(--surface-2); padding: 10px 12px; border-radius: 6px; flex-wrap: wrap; }
.counter-row .input { margin: 4px 0; }
.counter-preview { background: var(--input); padding: 9px 11px; border-radius: 6px; font-weight: 600; }
.counter-preview::before { content: "🔒 "; }

/* ── Vue d'ensemble ───────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--text-strong); }
.stat-label { color: var(--muted); font-size: 12.5px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; color: var(--text); }
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile-icon { font-size: 22px; width: 36px; text-align: center; }
.tile-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ── Éditeur + aperçu ─────────────────────────────────────── */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.embed-editor { border-left: 4px solid var(--accent); padding-left: 16px; }
.preview-col { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.preview-label { font-weight: 700; font-size: 13px; color: var(--muted); }
.preview { background: #313338; border-radius: var(--radius); padding: 14px 14px 16px; width: 100%; }

.dmsg { display: flex; gap: 14px; }
.dmsg-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.dmsg-body { flex: 1; min-width: 0; }
.dmsg-head { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.dmsg-name { font-weight: 600; color: var(--text-strong); }
.dmsg-app { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 3px; }
.dmsg-time { color: var(--muted); font-size: 11.5px; }
.dmsg-content { color: var(--text); word-wrap: break-word; }
.mention { background: var(--mention-bg); color: #c9cdfb; border-radius: 3px; padding: 0 2px; font-weight: 500; }
.spoiler { background: #1e1f22; color: transparent; border-radius: 3px; }
.dmsg code { background: #2b2d31; padding: 1px 4px; border-radius: 4px; font-size: 85%; }
.dmsg pre { background: #2b2d31; padding: 8px; border-radius: 4px; white-space: pre-wrap; margin: 4px 0; }

.dembed { display: flex; gap: 16px; background: #2b2d31; border-left: 4px solid var(--accent); border-radius: 4px; padding: 10px 14px 14px 12px; margin-top: 6px; max-width: 520px; }
.dembed-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.dembed-author { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; color: var(--text-strong); }
.dembed-author img, .dembed-footer img { width: 22px; height: 22px; border-radius: 50%; }
.dembed-title { font-weight: 700; color: var(--text-strong); }
.dembed-desc { font-size: 13.5px; word-wrap: break-word; }
.dembed-fields { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.dembed-field { flex-basis: 100%; min-width: 0; font-size: 13.5px; }
.dembed-field.inline { flex: 1 1 140px; }
.dembed-fname { font-weight: 700; color: var(--text-strong); margin-bottom: 2px; }
.dembed-image { max-width: 100%; border-radius: 4px; margin-top: 6px; }
.dembed-thumb { width: 72px; height: 72px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.dembed-footer { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #b5bac1; margin-top: 4px; }
.dembed-footer img { width: 20px; height: 20px; }
.dcomponents { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.dbutton { padding: 6px 14px; border-radius: 4px; font-weight: 600; font-size: 13.5px; color: #fff; }
.dbutton-secondary { background: #4e5058; }
.dbutton-success { background: #248046; }
.dbutton-primary { background: var(--accent); }
.dbutton-link { background: #4e5058; }
.msg-button-row { display: grid; grid-template-columns: 70px 1fr 1.6fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
@media (max-width: 640px) { .msg-button-row { grid-template-columns: 60px 1fr auto; } .msg-button-row > :nth-child(3) { grid-column: 1 / -1; grid-row: 2; } }
.dselect { display: flex; justify-content: space-between; width: 100%; max-width: 400px; background: #1e1f22; border: 1px solid #111214; padding: 9px 12px; border-radius: 4px; color: var(--muted); }

/* ── Barre d'enregistrement, toasts, dialogues ────────────── */
.savebar {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 140%); width: min(760px, calc(100% - 32px));
  background: #111214; color: #fff; border-radius: var(--radius); padding: 12px 16px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); transition: transform .25s; z-index: 20; flex-wrap: wrap;
}
.savebar.visible { transform: translate(-50%, 0); }
.savebar-actions { display: flex; gap: 8px; }

#toasts { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: calc(100% - 32px); }
.toast { background: #111214; border-left: 4px solid var(--success); padding: 10px 14px; border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .4); transition: opacity .3s, transform .3s; max-width: 420px; }
.toast-error { border-color: var(--danger); }
.toast.hide { opacity: 0; transform: translateX(20px); }

.dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; max-width: 420px; width: calc(100% - 32px); }
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog p { margin: 0 0 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Connexion & choix du serveur ─────────────────────────── */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); border-radius: 12px; padding: 36px; max-width: 440px; width: 100%; text-align: center; border: 1px solid var(--border); }
.login-card h1 { margin: 12px 0 8px; }
.login-card p { margin: 0 0 24px; }
.login-avatar { width: 80px; height: 80px; border-radius: 50%; }
.picker { max-width: 1000px; margin: 0 auto; padding: 0 16px 48px; }
.picker .topbar { margin: 0 -16px 24px; }
.picker h1 { margin-bottom: 16px; }
.guild-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.guild-card { display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 14px; color: var(--text); text-align: center; }
a.guild-card:hover { border-color: var(--accent); text-decoration: none; }
.guild-card.disabled .guild-icon { opacity: .5; }
.guild-icon { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.guild-icon.lg { width: 64px; height: 64px; }
.guild-icon.placeholder { display: grid; place-items: center; background: #404249; color: #fff; font-weight: 700; font-size: 12px; }
.guild-icon.placeholder.lg { font-size: 18px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1000px) {
  .editor-grid, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .preview-col { position: static; }
}
@media (max-width: 800px) {
  .topbar .menu-toggle { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0, 0, 0, .6); }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 16px 16px 120px; }
  .topbar { padding: 10px 16px; }
  .topbar .username { display: none; }
  .page-head { flex-direction: column; }
  .ellipsis { max-width: 100%; }
}

/* Voyant de statut du bot */
.status-pill { display: flex; gap: 12px; justify-content: center; margin: 0 8px 14px; padding: 6px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none; }
.status-pill:hover { filter: brightness(1.15); }
.status-pill.status-bad { outline: 1px solid #ed4245; }

/* Casier judiciaire / anniversaires */
.mini-avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--surface); }
.table-row.clickable { cursor: pointer; }
.table-row.clickable:hover { outline: 1px solid var(--border); }
.counts { display: flex; gap: 10px; font-variant-numeric: tabular-nums; }
