/* VCM Bot : interface de configuration. Thème sombre inspiré de Discord. */

:root {
  --bg: #1e1f22;
  --panel: #2b2d31;
  --panel-2: #313338;
  --panel-3: #383a40;
  --border: #3f4147;
  --text: #f2f3f5;
  --muted: #b5bac1;
  --faint: #949ba4;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #23a55a;
  --warning: #f0b232;
  --danger: #da373c;
  --link: #00a8fc;
  --youtube: #ff0033;
  --tiktok: #fe2c55;
  --radius: 10px;
  --font: "gg sans", "Noto Sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; }
[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }

/* ─── Barre du haut ─────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(30, 31, 34, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand-avatar { width: 32px; height: 32px; border-radius: 50%; }

.user-zone { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-zone img { width: 30px; height: 30px; border-radius: 50%; }
.user-zone .user-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }

.page { max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }
.loading { color: var(--faint); padding: 60px 0; text-align: center; }

h1 { font-size: 26px; line-height: 1.2; margin: 0; }
h2 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 13px; }

/* ─── Boutons ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 16px;
  border: 0;
  border-radius: 6px;
  background: var(--panel-3);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
}
.btn:hover { background: #4e5058; text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: transparent; color: #fa777c; box-shadow: inset 0 0 0 1px rgba(218, 55, 60, 0.5); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-small { min-height: 32px; padding: 5px 12px; font-size: 14px; }
.btn-discord { background: var(--accent); color: #fff; font-size: 16px; padding: 12px 22px; min-height: 48px; }
.btn-discord:hover { background: var(--accent-hover); }
.btn-discord svg { width: 24px; height: 24px; }

/* ─── Accueil ───────────────────────────────────────────────────────────── */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 470px);
  gap: 48px;
  align-items: center;
  padding: 40px 0;
}
.hero h1 { font-size: 38px; letter-spacing: -0.02em; }
.hero p.lead { font-size: 17px; color: var(--muted); margin: 16px 0 28px; max-width: 520px; }
.hero .features { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; }
.hero .features li { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.hero .features img { width: 20px; height: 20px; border-radius: 4px; }
.hero .note { margin-top: 14px; }
.hero-preview { background: var(--panel-2); border: 1px solid var(--border); border-radius: 14px; padding: 18px 8px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35); }

/* ─── Serveurs ──────────────────────────────────────────────────────────── */

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }

.guild-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.guild-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text);
  transition: transform 0.15s, border-color 0.15s;
}
a.guild-card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.guild-card .name { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-card.absent { opacity: 0.8; }

.guild-icon {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  background: var(--panel-3);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 20px;
  color: var(--muted);
  overflow: hidden;
  flex: none;
}
.guild-icon img { width: 100%; height: 100%; object-fit: cover; }
.guild-icon.small { width: 48px; height: 48px; border-radius: 16px; font-size: 16px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: rgba(35, 165, 90, 0.15); color: #57d38c; }
.badge-off { background: var(--panel-3); color: var(--faint); }

/* ─── Page d'un serveur ─────────────────────────────────────────────────── */

.back { display: inline-flex; gap: 6px; color: var(--muted); margin-bottom: 18px; }
.guild-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 26px; }
.guild-head .grow { flex: 1; min-width: 200px; }

.alerts { display: grid; gap: 12px; }
.alert-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.alert-card.paused { opacity: 0.7; }
.alert-main { display: flex; gap: 14px; align-items: flex-start; }
.alert-avatar { position: relative; flex: none; }
.alert-avatar > img:first-child { width: 52px; height: 52px; border-radius: 50%; background: var(--panel-3); object-fit: cover; }
.alert-avatar .platform { position: absolute; right: -4px; bottom: -4px; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--panel); background: var(--panel); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-weight: 700; font-size: 16px; }
.alert-title a { color: var(--text); }
.alert-number { color: var(--faint); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.alert-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin-top: 4px; }
.alert-status { font-size: 13px; margin-top: 8px; color: var(--faint); }
.alert-status.error { color: #fa777c; }
.alert-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.alert-preview { margin-top: 14px; background: var(--panel-2); border-radius: 8px; padding: 14px 6px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 4px; background: var(--panel-3); color: var(--text); font-size: 13px; font-weight: 500; }

.warning-box { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: rgba(240, 178, 50, 0.1); border: 1px solid rgba(240, 178, 50, 0.35); color: #f5cf7d; font-size: 13px; }
.warning-box ul { margin: 0; padding-left: 18px; }

.empty { text-align: center; padding: 50px 20px; background: var(--panel); border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* Interrupteur actif / en pause */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--muted); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 40px; height: 24px; border-radius: 12px; background: #80848e; position: relative; transition: background 0.15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--link); outline-offset: 2px; }

/* ─── Éditeur d'alerte ──────────────────────────────────────────────────── */

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 470px);
  gap: 24px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 28px;
}
.editor h2 { margin-bottom: 18px; }
.editor .preview-col { position: sticky; top: 76px; align-self: start; }
.preview-box { background: var(--panel-2); border-radius: 10px; padding: 14px 4px; min-height: 160px; }
.preview-placeholder { color: var(--faint); text-align: center; padding: 40px 20px; font-size: 14px; }

.field { margin-bottom: 18px; }
.field > label, .field > .label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); margin-bottom: 8px; }
.field .hint { font-size: 13px; color: var(--faint); margin-top: 6px; }
.field .hint code { background: var(--panel-3); padding: 1px 5px; border-radius: 4px; font-size: 12px; color: var(--text); }

.input, select.input, textarea.input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.input:focus { border-color: var(--accent); }
.input[readonly] { color: var(--muted); }
textarea.input { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 8px; }
.row .input { flex: 1; min-width: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice {
  position: relative;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { border-color: var(--accent); background: rgba(88, 101, 242, 0.1); }
.choice:has(input:focus-visible) { outline: 2px solid var(--link); }
.choice:has(input:disabled) { cursor: default; }
.choice img { width: 24px; height: 24px; border-radius: 5px; flex: none; }
.choice .emoji { font-size: 20px; line-height: 24px; flex: none; }
.choice strong { display: block; }
.choice small { display: block; color: var(--faint); font-size: 13px; }

.checks { display: flex; gap: 8px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 6px; background: var(--bg); cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.source-chip { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 12px; border-radius: 8px; background: rgba(35, 165, 90, 0.12); color: #9ae6b8; font-size: 14px; }
.source-chip img { width: 28px; height: 28px; border-radius: 50%; }
.source-chip.error { background: rgba(218, 55, 60, 0.12); color: #fa777c; }

.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ─── Aperçu Discord ────────────────────────────────────────────────────── */

.dc-message { display: flex; gap: 14px; padding: 4px 14px; font-size: 15px; line-height: 1.375; color: #dbdee1; }
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--panel-3); }
.dc-body { min-width: 0; flex: 1; }
.dc-header { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dc-name { font-weight: 600; color: #f2f3f5; }
.dc-tag { background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; line-height: 15px; }
.dc-time { color: var(--faint); font-size: 12px; margin-left: 2px; }
.dc-content { white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-content .dc-sub { display: block; font-size: 12px; color: var(--faint); }
.dc-content blockquote { margin: 2px 0; padding: 0 0 0 12px; border-left: 4px solid #4e5058; }
.dc-mention { background: rgba(88, 101, 242, 0.3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; font-weight: 500; }

.dc-embed {
  display: grid;
  gap: 8px;
  max-width: 432px;
  margin-top: 6px;
  padding: 10px 16px 16px 12px;
  border-left: 4px solid #1e1f22;
  border-radius: 4px;
  background: #2b2d31;
}
.dc-embed.large { max-width: 520px; }
.dc-embed-author { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: #f2f3f5; }
.dc-embed-author img { width: 24px; height: 24px; border-radius: 50%; }
.dc-embed-author a { color: #f2f3f5; }
.dc-embed-provider { font-size: 12px; color: var(--faint); }
.dc-embed-title { font-weight: 600; font-size: 16px; }
.dc-embed-title a { color: var(--link); }
.dc-embed-desc { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-fields { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.dc-field { font-size: 14px; }
.dc-field-name { font-weight: 600; color: #f2f3f5; }
.dc-embed-image img, .dc-player img, .dc-video img { width: 100%; height: auto; border-radius: 4px; background: #1e1f22; }
.dc-embed-image.portrait img, .dc-video img { width: auto; max-width: 100%; max-height: 380px; }
.dc-embed-footer { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #dbdee1; }
.dc-embed-footer img { width: 20px; height: 20px; border-radius: 50%; }
.dc-player, .dc-video { position: relative; display: inline-block; max-width: 100%; margin-top: 6px; }
.dc-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
}
.dc-play::after { content: ""; margin-left: 5px; border-style: solid; border-width: 12px 0 12px 20px; border-color: transparent transparent transparent #fff; }
.dc-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.dc-button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; min-height: 32px; border-radius: 8px; background: #4e5058; color: #fff; font-size: 14px; font-weight: 500; }
.dc-button:hover { background: #6d6f78; text-decoration: none; }
.dc-button svg { width: 14px; height: 14px; opacity: 0.8; }

/* ─── Notifications ─────────────────────────────────────────────────────── */

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 8px; background: var(--panel-3); border-left: 4px solid var(--success); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); animation: toast-in 0.2s ease-out; }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ─── Petits écrans ─────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .hero, .editor { grid-template-columns: minmax(0, 1fr); }
  .hero { gap: 28px; padding: 10px 0; }
  .hero h1 { font-size: 30px; }
  .editor .preview-col { position: static; }
}

@media (max-width: 560px) {
  .page { padding: 20px 16px 60px; }
  .topbar { padding: 10px 16px; }
  .user-zone .user-name { display: none; }
  .grid-2, .segmented { grid-template-columns: 1fr; }
  .editor { padding: 16px; }
  .dc-message { padding: 4px 6px; gap: 10px; }
  .dc-avatar { width: 34px; height: 34px; }
  .alert-actions .btn { flex: 1 1 auto; }
}
