:root {
  --bg: #111214;
  --bg-2: #1a1b1e;
  --surface: #202226;
  --surface-2: #2a2c31;
  --border: #33363c;
  --text: #e6e7ea;
  --muted: #9a9ea6;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #3ba55d;
  --danger: #ed4245;
  --warning: #f0b232;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: #8ea1ff; text-decoration: none; }
a:hover { text-decoration: underline; }
[x-cloak] { display: none !important; }
code { background: var(--bg-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; font-size: 13px; }

/* ── Barre du haut ── */
.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--bg-2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .5px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #9b59f6); color: #fff; font-size: 14px;
}
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); object-fit: cover; }

/* ── Mise en page ── */
.layout { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 60px); }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--border); padding: 18px 12px; }
.guild-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.guild-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; overflow: hidden; flex-shrink: 0; }
.guild-icon img { width: 100%; height: 100%; object-fit: cover; }
.guild-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--muted); font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--surface-2); color: var(--text); }
.nav .ico { width: 22px; text-align: center; }
.nav-sep { height: 1px; background: var(--border); margin: 12px 4px; }
.main { padding: 28px 32px 120px; max-width: 1100px; width: 100%; }

.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; }
.page-head p { margin: 0; color: var(--muted); }

/* ── Cartes & formulaires ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 17px; margin: 0; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.sub-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 12px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); }
input[type=text], input[type=number], input[type=url], select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; font: inherit; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
input[type=color] { width: 48px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); cursor: pointer; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }

/* Interrupteur */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; cursor: pointer; }
.switch + .switch { border-top: 1px solid var(--border); }
.switch-text strong { display: block; font-weight: 600; }
.switch-text span { font-size: 13px; color: var(--muted); }
.switch input { display: none; }
.slider { width: 42px; height: 24px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); position: relative; flex-shrink: 0; transition: background .15s; }
.slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .slider { background: var(--success); border-color: var(--success); }
.switch input:checked + .slider::after { transform: translateX(18px); }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600;
  transition: background .15s, opacity .15s; white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.secondary:hover { background: #363940; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid rgba(237, 66, 69, .4); }
.btn.danger:hover { background: rgba(237, 66, 69, .12); }
.btn.success { background: var(--success); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--muted); padding: 4px 8px; }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }

/* Puces (rôles / salons sélectionnés) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 3px 6px 3px 10px; font-size: 13px; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.chip button:hover { color: var(--danger); }
.chips select { width: auto; min-width: 180px; padding: 5px 8px; font-size: 13px; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; font-weight: 700; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.badge.on { background: rgba(59, 165, 93, .15); color: #5fd38a; }
.badge.off { background: rgba(237, 66, 69, .12); color: #ff7b7e; }
.badge.warn { background: rgba(240, 178, 50, .15); color: var(--warning); }

/* Accueil / liste des serveurs */
.hero { max-width: 720px; margin: 12vh auto 0; text-align: center; padding: 0 16px; }
.hero h1 { font-size: 44px; margin: 18px 0 8px; }
.hero p { color: var(--muted); font-size: 17px; margin: 0 0 28px; }
.hero .brand-logo { width: 72px; height: 72px; font-size: 26px; border-radius: 20px; margin: 0 auto; }
.features { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 30px; }
.servers { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.server { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.server .guild-icon { width: 72px; height: 72px; border-radius: 22px; font-size: 22px; }
.server-name { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.container { max-width: 1100px; margin: 0 auto; padding: 32px 20px 80px; }

/* Statistiques */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-value { font-size: 28px; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 13px; }
.module-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.module-link { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; color: var(--text); }
.module-link:hover { border-color: var(--accent); text-decoration: none; }

/* Barre d'enregistrement */
.savebar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30;
  background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: 12px; padding: 10px 12px 10px 18px; display: flex; align-items: center; gap: 16px;
  width: min(640px, calc(100% - 32px));
}
.savebar span { flex: 1; font-weight: 600; }

/* Notifications */
.toasts { position: fixed; top: 74px; right: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100% - 32px)); }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--success); border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow); white-space: pre-line; animation: slide .2s ease; }
.toast.error { border-left-color: var(--danger); }
@keyframes slide { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Aperçu de message Discord */
.preview { background: #313338; border-radius: 8px; padding: 16px; font-size: 14.5px; }
.preview .msg-content { margin-bottom: 6px; white-space: pre-wrap; word-break: break-word; }
.embed-preview { border-left: 4px solid var(--accent); background: #2b2d31; border-radius: 4px; padding: 10px 14px; max-width: 520px; display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.embed-preview .e-author { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.embed-preview .e-title { font-weight: 700; color: #fff; }
.embed-preview .e-desc { white-space: pre-wrap; word-break: break-word; color: #dbdee1; }
.embed-preview .e-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.embed-preview .e-field { grid-column: span 3; }
.embed-preview .e-field.inline { grid-column: span 1; }
.embed-preview .e-field b { display: block; font-size: 13px; }
.embed-preview .e-image { max-width: 100%; border-radius: 4px; margin-top: 8px; grid-column: 1 / -1; }
.embed-preview .e-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 4px; }
.embed-preview .e-footer { font-size: 12px; color: var(--muted); grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; }
.embed-preview img.mini { width: 20px; height: 20px; border-radius: 50%; }
.preview-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.preview-buttons span { background: #4e5058; color: #fff; padding: 6px 14px; border-radius: 4px; font-size: 14px; }

/* Éditeur deux colonnes */
.split { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
.list { display: flex; flex-direction: column; gap: 4px; }
.list button { text-align: left; background: transparent; border: 1px solid transparent; color: var(--muted); padding: 9px 10px; border-radius: 8px; cursor: pointer; font: inherit; display: flex; align-items: center; gap: 8px; }
.list button:hover { background: var(--surface-2); color: var(--text); }
.list button.active { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.perm-row:last-child { border-bottom: 0; }
.perm-cat { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--accent); margin: 16px 0 4px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: 10px 16px; }
  .guild-head { border-bottom: 0; margin-bottom: 4px; padding-bottom: 6px; }
  .nav { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .nav a { white-space: nowrap; margin: 0; }
  .nav-sep { display: none; }
  .main { padding: 20px 16px 120px; }
  .split { grid-template-columns: 1fr; }
  .user .name { display: none; }
  .hero h1 { font-size: 32px; }
}
