/* =========================================================================
   Le Pacte de la Source — Panel web
   Theme « sauge » : fond #2c3938, accents crème #e9ecd5.
   Toutes les classes historiques sont conservées pour ne rien casser.
   ========================================================================= */
:root {
  --bg: #2c3938;
  --bg-deep: #232d2c;
  --bg-soft: #33403f;
  --card: rgba(53, 67, 65, 0.82);
  --card-solid: #354341;
  --border: #45544f;
  --border-soft: rgba(233, 236, 213, 0.16);
  --text: #e9ecd5;
  --muted: #b3b9a1;
  --emerald: #e9ecd5;
  --emerald-soft: #f4f6e8;
  --emerald-deep: #c6cbb0;
  --gold: #dfe3c6;
  --gold-soft: #eef1dd;
  --gold-deep: #b9bfa2;
  --accent: #e9ecd5;
  --accent-2: #dfe3c6;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 8px 22px rgba(0, 0, 0, 0.32);
  --ring: 0 0 0 3px rgba(233, 236, 213, 0.22);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Inter", sans-serif;
  background:
    radial-gradient(1100px 520px at 82% -12%, rgba(233, 236, 213, 0.10), transparent 60%),
    radial-gradient(900px 480px at 8% 112%, rgba(222, 227, 197, 0.06), transparent 62%),
    linear-gradient(180deg, var(--bg-deep), var(--bg) 60%, var(--bg-deep));
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Structure ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  background: linear-gradient(180deg, rgba(44, 57, 56, 0.96), rgba(35, 45, 44, 0.96));
  border-right: 1px solid var(--border);
  padding: 18px 12px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  backdrop-filter: blur(10px);
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: #45544f; border-radius: 8px; }
.sidebar h2 { font-size: 15px; margin: 0 0 2px; letter-spacing: 0.3px; }
.sidebar .tagline { font-size: 11px; color: var(--muted); margin: 0 0 14px; }
.side-logo { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; border: 1px solid var(--border-soft); box-shadow: var(--shadow-soft); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 11px;
  font-size: 14px;
  margin-bottom: 2px;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, transform 0.15s, border-color 0.15s;
}
.sidebar nav a:hover { background: rgba(233, 236, 213, 0.10); color: var(--text); transform: translateX(2px); border-color: var(--border-soft); }
.sidebar nav a.active {
  background: linear-gradient(90deg, rgba(233, 236, 213, 0.30), rgba(233, 236, 213, 0.06));
  color: #e9ecd5;
  border-color: rgba(233, 236, 213, 0.45);
  box-shadow: inset 3px 0 0 var(--emerald);
}
.sidebar .user { margin-top: 14px; font-size: 13px; color: var(--muted); padding: 0 8px; }
.sidebar .user a { color: var(--muted); }

.main { flex: 1; padding: 28px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ---------- Signature ---------- */
.official-signature {
  width: 100%;
  margin-top: 30px;
  padding: 16px 4px 6px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.3px;
  text-align: center;
  opacity: 0.85;
}

/* ---------- En-têtes ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
h1 { font-size: 22px; margin: 0 0 16px; }

/* ---------- Cartes ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}
.card.hero { background: linear-gradient(135deg, rgba(233, 236, 213, 0.24), rgba(222, 227, 197, 0.12)); border-color: rgba(233, 236, 213, 0.45); }
.card .v { font-size: 25px; font-weight: 800; letter-spacing: -0.4px; }
.card .l { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card b { color: #e9ecd5; }

/* ---------- Tableaux ---------- */
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; font-size: 13px; box-shadow: var(--shadow-soft); }
th, td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; background: rgba(28, 38, 37, 0.5); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(233, 236, 213, 0.07); }

/* ---------- Boutons ---------- */
button, .btn {
  background: linear-gradient(180deg, var(--emerald-soft), var(--emerald-deep));
  color: #242d2c;
  border: 0;
  border-radius: 11px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s, filter 0.12s;
  box-shadow: 0 6px 16px rgba(233, 236, 213, 0.28);
}
button:hover { transform: translateY(-1px); box-shadow: 0 9px 22px rgba(233, 236, 213, 0.38); }
button:active { transform: translateY(0); }
button.secondary { background: #3d4b47; color: var(--text); box-shadow: none; }
button.secondary:hover { background: #48564f; box-shadow: none; }
button.gold, .btn-gold { background: linear-gradient(180deg, var(--gold-soft), var(--gold-deep)); color: #2a1f00; box-shadow: 0 6px 16px rgba(222, 227, 197, 0.28); }
button.success { background: linear-gradient(180deg, #4ade80, #16a34a); color: #04180b; box-shadow: 0 6px 16px rgba(34, 197, 94, 0.3); }
button.danger { background: linear-gradient(180deg, #f87171, #dc2626); color: #e9ecd5; box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3); }
button:disabled { opacity: 0.5; cursor: default; transform: none; }

/* ---------- Formulaires ---------- */
input, select, textarea {
  background: #27312f;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 13px;
  width: 100%;
  margin: 4px 0 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--emerald); box-shadow: var(--ring); }
label { font-size: 13px; color: var(--muted); font-weight: 600; }
textarea { min-height: 120px; font-family: Consolas, "Cascadia Code", monospace; resize: vertical; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px; background: #3d4b47; font-weight: 700; }
.badge.green { background: rgba(34, 197, 94, 0.18); color: #4ade80; }
.badge.red { background: rgba(239, 68, 68, 0.18); color: #f87171; }
.badge.amber { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }
.badge.gold { background: rgba(222, 227, 197, 0.16); color: var(--gold-soft); }

/* ---------- Barres d'outils ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar-row { display: flex; gap: 6px; flex-wrap: wrap; }
.toolbar-row button { padding: 7px 11px; font-size: 13px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  max-width: min(420px, calc(100vw - 40px));
  background: rgba(44, 57, 56, 0.97);
  border: 1px solid var(--emerald);
  color: var(--text);
  padding: 13px 18px;
  border-radius: 13px;
  display: none;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease-out;
  z-index: 100;
  font-size: 13px;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Modales ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 27, 26, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 16px;
  backdrop-filter: blur(3px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
}
.modal h3 { margin: 0 0 12px; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ---------- Aperçu Discord ---------- */
.preview-box {
  background: #27312f;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 16px;
  min-height: 120px;
  word-wrap: break-word;
}
.preview-box h3 { margin: 0 0 8px; color: #e9ecd5; }
.preview-box blockquote { border-left: 3px solid var(--emerald); margin: 6px 0; padding-left: 10px; color: var(--muted); }
.preview-box code { background: #1f2928; padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.preview-box pre { background: #1f2928; padding: 10px; border-radius: 8px; overflow-x: auto; }
.preview-box pre code { background: none; padding: 0; }
.preview-box ul { margin: 6px 0; padding-left: 22px; }
.preview-box .mention { background: rgba(233, 236, 213, 0.22); padding: 0 5px; border-radius: 5px; }

/* ---------- Divers ---------- */
.empty { color: var(--muted); padding: 18px; text-align: center; }
.login-wrap { max-width: 430px; margin: 10vh auto; text-align: center; padding: 0 16px; }
.hint { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; margin-bottom: 16px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }

/* ---------- Sidebar réductible ---------- */
.side-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.icon-btn { background: #3d4b47; box-shadow: none; padding: 7px 11px; border-radius: 9px; width: auto; color: var(--text); }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); margin: 15px 0 6px 8px; }
.nav-burger { display: none; position: fixed; top: 12px; left: 12px; z-index: 120; }
body.menu-collapsed .nav-burger { display: block; }
.sidebar.collapsed { width: 66px; }
.sidebar.collapsed nav a span,
.sidebar.collapsed h2,
.sidebar.collapsed .tagline,
.sidebar.collapsed .user,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .side-collapse,
.sidebar.collapsed .side-logo,
.sidebar.collapsed .brand > div { display: none; }
.sidebar.collapsed .brand { justify-content: center; }
.sidebar.collapsed nav a { justify-content: center; }

/* ---------- Accueil ---------- */
.hero { display: flex; align-items: center; gap: 16px; background: linear-gradient(135deg, rgba(233, 236, 213, 0.26), rgba(222, 227, 197, 0.13)); border: 1px solid rgba(233, 236, 213, 0.42); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-soft); margin-bottom: 18px; }
.hero img { width: 58px; height: 58px; border-radius: 50%; border: 2px solid rgba(222, 227, 197, 0.6); }
.hero h1 { margin: 0; font-size: 22px; }
.hero p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.note { border-left: 3px solid var(--emerald); padding: 11px 13px; background: rgba(233, 236, 213, 0.07); border-radius: 0 11px 11px 0; margin-bottom: 10px; }
.note.pinned { border-left-color: var(--gold); background: rgba(222, 227, 197, 0.08); }
.note small { color: var(--muted); }
.note .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.note .row button { padding: 5px 10px; font-size: 12px; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 10px; }
.quick-grid a { display: block; text-align: center; padding: 13px; border-radius: 13px; background: var(--card); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 13px; font-weight: 700; transition: transform 0.12s, border-color 0.12s, background 0.12s; }
.quick-grid a:hover { transform: translateY(-2px); border-color: var(--emerald); background: rgba(233, 236, 213, 0.1); }
.duo-btns { display: flex; gap: 10px; }
.duo-btns a { flex: 1 1 0; text-decoration: none; display: flex; min-width: 0; }
.duo-btns button { flex: 1; padding: 12px 8px; font-size: 14px; font-weight: 700; border-radius: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.duo-btns button:hover { transform: translateY(-1px); }

/* ---------- Auto-modération ---------- */
.am-hero { background: linear-gradient(135deg, rgba(233, 236, 213, 0.20), rgba(222, 227, 197, 0.1)); border-color: rgba(233, 236, 213, 0.42); }
.am-hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.am-hero-top p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.am-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 12px; }
.am-grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 10px; }
.am-card { background: rgba(61, 75, 71, 0.65); border: 1px solid var(--border); border-radius: 13px; padding: 13px; cursor: pointer; transition: border-color 0.15s, transform 0.15s; }
.am-card:hover { transform: translateY(-2px); }
.am-card.on { border-color: rgba(233, 236, 213, 0.55); box-shadow: 0 0 0 1px rgba(233, 236, 213, 0.25); }
.am-card b { display: block; margin-top: 6px; }
.am-card small { color: var(--muted); font-size: 12px; }
.am-card-top { display: flex; align-items: center; justify-content: space-between; }
.am-icon { font-size: 22px; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #45544f; border-radius: 20px; transition: 0.2s; }
.switch span:before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #e9ecd5; border-radius: 50%; transition: 0.2s; }
.switch input:checked + span { background: linear-gradient(90deg, var(--emerald-soft), var(--emerald-deep)); }
.switch input:checked + span:before { transform: translateX(18px); }
.seg { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.seg button { flex: 1; background: #3d4b47; color: var(--text); box-shadow: none; white-space: nowrap; }
.seg button.on { background: linear-gradient(180deg, var(--emerald-soft), var(--emerald-deep)); color: #242d2c; box-shadow: 0 4px 14px rgba(233, 236, 213, 0.3); }
.am-words-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: rgba(233, 236, 213, 0.14); border: 1px solid rgba(233, 236, 213, 0.34); font-size: 12px; font-weight: 600; }
.chip a { color: var(--red); text-decoration: none; }
input[type="range"] { padding: 0; accent-color: var(--emerald); }

/* ---------- Onglets d'accès (Paramètres) ---------- */
.access-tabs { display: flex; gap: 8px; flex-wrap: wrap; background: rgba(61, 75, 71, 0.6); border: 1px solid var(--border); border-radius: 14px; padding: 6px; margin-bottom: 18px; }
.access-tabs button { background: transparent; color: var(--muted); box-shadow: none; border-radius: 10px; font-weight: 700; padding: 9px 15px; }
.access-tabs button:hover { background: rgba(233, 236, 213, 0.12); color: var(--text); transform: none; }
.access-tabs button.on { background: linear-gradient(180deg, var(--emerald-soft), var(--emerald-deep)); color: #242d2c; box-shadow: 0 5px 14px rgba(233, 236, 213, 0.3); }
.tab-panel { animation: fade-in 0.2s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.tab-panel[hidden] { display: none; }

/* ---------- Badge de niveau ---------- */
.level-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: 0.3px; background: rgba(233, 236, 213, 0.16); border: 1px solid rgba(233, 236, 213, 0.4); color: var(--emerald-soft); }
.level-badge.staff { background: rgba(222, 227, 197, 0.16); border-color: rgba(222, 227, 197, 0.45); color: var(--gold-soft); }
.level-badge.bras_droit { background: rgba(233, 236, 213, 0.16); border-color: rgba(233, 236, 213, 0.4); color: var(--emerald-soft); }
.level-badge.animateur { background: rgba(96, 165, 250, 0.16); border-color: rgba(96, 165, 250, 0.4); color: #93c5fd; }

/* ---------- Comptes du staff ---------- */
.acct-level { font-weight: 700; }
.acct-level.staff { color: var(--gold-soft); }
.acct-level.bras_droit { color: var(--emerald-soft); }
.acct-level.animateur { color: #93c5fd; }
.notice { padding: 11px 14px; border-radius: 12px; font-size: 13px; margin-bottom: 12px; border: 1px solid var(--border); background: rgba(61, 75, 71, 0.6); color: var(--muted); }
.notice.warn { border-color: rgba(245, 158, 11, 0.45); color: #fcd34d; background: rgba(245, 158, 11, 0.08); }
.notice.ok { border-color: rgba(34, 197, 94, 0.45); color: #6ee7b7; background: rgba(34, 197, 94, 0.08); }
.role-card { display: grid; grid-template-columns: 1fr; gap: 4px; }
.role-card .role-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.role-card .role-emoji { font-size: 24px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .am-grid-2 { grid-template-columns: 1fr; }
  .nav-burger { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 110; transform: translateX(-100%); transition: transform 0.2s; height: 100vh; width: 250px; }
  .sidebar.open { transform: none; }
  .sidebar.collapsed { width: 250px; }
  .sidebar.collapsed nav a span,
  .sidebar.collapsed h2,
  .sidebar.collapsed .tagline,
  .sidebar.collapsed .user,
  .sidebar.collapsed .nav-section,
  .sidebar.collapsed .side-collapse,
  .sidebar.collapsed .side-logo,
  .sidebar.collapsed .brand > div { display: block; }
  .sidebar.collapsed .brand { justify-content: flex-start; }
  .main { padding-top: 58px; }
}
@media (max-width: 760px) {
  .sidebar { width: 66px; padding: 14px 8px; }
  .sidebar nav a span, .sidebar h2, .sidebar .tagline, .sidebar .user { display: none; }
  .sidebar nav a { justify-content: center; }
  .main { padding: 14px; }
  table { font-size: 12px; }
  .access-tabs button { flex: 1 1 40%; }
}

/* ---------- Mode prévisualisation (Administrateur) ---------- */
.preview-banner {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(222, 227, 197, 0.20), rgba(233, 236, 213, 0.18));
  border-bottom: 1px solid var(--gold);
  color: var(--text);
  font-size: 14px;
}
.preview-banner .preview-title { font-weight: 700; color: var(--gold-soft); letter-spacing: 0.3px; }
.preview-banner .preview-hint { color: var(--muted); }
.preview-banner #preview-exit { margin-left: auto; }
.recovery-box {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--gold);
  border-radius: var(--radius-sm);
  background: rgba(222, 227, 197, 0.08);
}
.recovery-box code { color: var(--gold-soft); }
