:root {
  --bg: #0f1117;
  --bg2: #161b26;
  --bg3: #1e2535;
  --border: #2a3245;
  --accent: #25d366;
  --accent-dim: #1a9e4c;
  --accent2: #128c7e;
  --text: #e8eaf0;
  --text-dim: #8892a4;
  --danger: #e53e3e;
  --warning: #d97706;
  --info: #3b82f6;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --sidebar-w: 220px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

.app { display: flex; height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 24px; }
.brand-name { font-size: 18px; font-weight: 700; color: var(--accent); letter-spacing: -.3px; }

.sidebar-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s;
  position: relative;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(37,211,102,.12); color: var(--accent); }
.nav-icon { font-size: 16px; flex-shrink: 0; }
.badge {
  margin-left: auto;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
}

.sidebar-status { padding: 12px 16px; border-top: 1px solid var(--border); }
.ws-indicator { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.ws-indicator .dot { width: 8px; height: 8px; border-radius: 50%; background: #555; flex-shrink: 0; }
.ws-indicator.connected .dot { background: var(--accent); }
.ws-indicator.disconnected .dot { background: var(--danger); }

/* ── Main ── */
.main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

.page { display: none; padding: 28px; min-height: 100%; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 22px; font-weight: 600; }

/* ── Cards ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.mt { margin-top: 20px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover:not(:disabled) { background: #1fba58; }
.btn-success { background: var(--accent2); color: #fff; }
.btn-success:hover:not(:disabled) { background: #0e6b62; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #263050; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c53030; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.form-control {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-dim); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
input[type="file"].form-control { padding: 7px 12px; }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }

.input-group { display: flex; gap: 8px; }
.input-group .form-control { flex: 1; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }

/* ── Message types ── */
.msg-type-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.type-btn {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.type-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(37,211,102,.1); }
.type-btn:hover:not(.active) { border-color: var(--text-dim); color: var(--text); }

/* ── Sessions grid ── */
.sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.session-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s;
}
.session-card:hover { border-color: var(--accent2); }
.session-card-header { display: flex; align-items: center; justify-content: space-between; }
.session-name { font-size: 15px; font-weight: 600; }
.status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.status-connected { background: rgba(37,211,102,.15); color: var(--accent); }
.status-qr { background: rgba(59,130,246,.15); color: #60a5fa; }
.status-connecting, .status-reconnecting { background: rgba(217,119,6,.15); color: #fbbf24; }
.status-disconnected, .status-not_found { background: rgba(229,62,62,.15); color: #f87171; }

.session-phone { font-size: 13px; color: var(--text-dim); }
.session-actions { display: flex; gap: 8px; }

/* ── Groups grid ── */
.groups-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; }
.group-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.group-card h4 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.group-card .meta { font-size: 12px; color: var(--text-dim); }
.group-card .actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ── Contacts ── */
.contacts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 12px; margin-top: 16px; }
.contact-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.contact-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.contact-info .name { font-size: 13px; font-weight: 600; }
.contact-info .phone { font-size: 11px; color: var(--text-dim); }

/* ── Media grid (view-once) ── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 16px; margin-top: 16px; }
.media-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s;
}
.media-card:hover { border-color: var(--accent); }
.media-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-info { padding: 10px 12px; }
.media-info .type { font-size: 11px; color: var(--accent); text-transform: uppercase; font-weight: 600; }
.media-info .sender { font-size: 12px; color: var(--text-dim); }
.media-info .date { font-size: 11px; color: var(--text-dim); }
.media-actions { display: flex; gap: 6px; padding: 0 12px 10px; }

/* ── Games overview ── */
.games-overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 12px; }
.game-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  transition: border-color .15s;
}
.game-card:hover { border-color: var(--accent); }
.game-emoji { font-size: 32px; margin-bottom: 8px; }
.game-name { font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.game-card code { font-size: 11px; background: var(--bg3); padding: 2px 6px; border-radius: 4px; color: var(--accent); }

/* ── Stats grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.stat-value { font-size: 32px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ── Message list ── */
.message-list { display: flex; flex-direction: column; gap: 8px; max-height: 400px; overflow-y: auto; margin-top: 10px; }
.msg-bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
}
.msg-in { align-self: flex-start; background: var(--bg3); border-bottom-left-radius: 2px; }
.msg-out { align-self: flex-end; background: rgba(37,211,102,.15); border-bottom-right-radius: 2px; }
.msg-meta { font-size: 10px; color: var(--text-dim); margin-top: 3px; }

/* ── Tabs ── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.cron-shortcuts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 99px;
  cursor: pointer;
  transition: all .15s;
}
.badge-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-sm { max-width: 380px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; padding: 4px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ── QR ── */
.qr-container { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 10px 0; }
.qr-img { width: 220px; height: 220px; border-radius: 12px; border: 3px solid var(--border); }
.qr-hint { font-size: 12.5px; color: var(--text-dim); text-align: center; }
.qr-status { font-size: 13px; font-weight: 500; }

/* ── Info box ── */
.info-box {
  background: rgba(59,130,246,.08);
  border: 1px solid rgba(59,130,246,.25);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #93c5fd;
  margin-bottom: 20px;
}
.info-box code { background: rgba(255,255,255,.1); padding: 1px 5px; border-radius: 4px; }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn .25s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--accent); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Misc ── */
.empty-state { text-align: center; color: var(--text-dim); padding: 40px; font-size: 14px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
code { background: var(--bg3); padding: 2px 6px; border-radius: 4px; font-size: 12px; color: #81e6d9; }
.loading { text-align: center; padding: 20px; color: var(--text-dim); }
.sidebar-divider { height: 1px; background: var(--border); margin: 6px 12px; }

/* ════════════════════════════════════════
   DOCUMENTATION
   ════════════════════════════════════════ */

/* Layout deux colonnes */
.docs-layout {
  display: flex;
  gap: 0;
  min-height: 100%;
  align-items: flex-start;
}

/* Mini-nav sticky à gauche */
.docs-nav {
  width: 210px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 28px 0 28px 28px;
  scrollbar-width: thin;
}
.docs-nav-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-dim);
  padding: 4px 0 8px;
}
.docs-nav-link {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 6px;
  margin-bottom: 1px;
  border-left: 2px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.docs-nav-link:hover { color: var(--text); background: var(--bg3); }
.docs-nav-link.active { color: var(--accent); border-left-color: var(--accent); background: rgba(37,211,102,.07); }

/* Content */
.docs-content {
  flex: 1;
  padding: 28px 28px 60px 32px;
  max-width: 860px;
  min-width: 0;
}

/* Hero */
.docs-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, rgba(37,211,102,.08), rgba(18,140,126,.08));
  border: 1px solid rgba(37,211,102,.2);
  border-radius: 14px;
  padding: 28px 32px;
  margin-bottom: 40px;
}
.docs-hero-icon { font-size: 48px; line-height: 1; }
.docs-hero-title { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.docs-hero-sub { font-size: 13.5px; color: var(--text-dim); }

/* Sections */
.docs-section {
  margin-bottom: 52px;
  padding-top: 8px;
}
.docs-section h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.docs-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 20px 0 8px;
}
.docs-section p {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 10px;
}
.docs-section ol, .docs-section ul {
  padding-left: 20px;
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 2;
}

/* Code blocks */
.docs-section pre {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 10px 0 14px;
}
.docs-section pre code {
  background: none;
  padding: 0;
  font-size: 12.5px;
  color: #93e1d8;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  line-height: 1.6;
}

/* Tables docs */
.docs-table-wrap { overflow-x: auto; margin: 10px 0 14px; }
.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.docs-table thead tr { background: var(--bg3); }
.docs-table th {
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.docs-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  line-height: 1.5;
}
.docs-table tr:last-child td { border-bottom: none; }
.docs-table tr:hover td { background: rgba(255,255,255,.02); }

/* Info boxes */
.docs-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(59,130,246,.08);
  border: 1px solid rgba(59,130,246,.2);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: #93c5fd;
  margin: 12px 0;
  line-height: 1.6;
}
.docs-info.docs-warn {
  background: rgba(217,119,6,.08);
  border-color: rgba(217,119,6,.25);
  color: #fbbf24;
}
.docs-info-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

/* Pills de statut dans les docs */
.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.pill-green  { background: rgba(37,211,102,.15); color: #4ade80; }
.pill-blue   { background: rgba(59,130,246,.15);  color: #60a5fa; }
.pill-yellow { background: rgba(251,191,36,.12);  color: #fbbf24; }
.pill-red    { background: rgba(239,68,68,.15);   color: #f87171; }

/* API reference header */
.docs-api-header {
  background: linear-gradient(135deg, rgba(18,140,126,.1), rgba(37,211,102,.06));
  border: 1px solid rgba(37,211,102,.15);
  border-radius: 12px;
  padding: 24px 28px;
  margin: 52px 0 32px;
}
.docs-api-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; border: none; padding: 0; }
.docs-api-header p  { font-size: 13.5px; color: var(--text-dim); margin-bottom: 12px; }
.docs-response-format pre { margin: 0; }
.docs-response-format strong { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 6px; }

/* Endpoint cards */
.endpoint {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color .15s;
}
.endpoint:hover { border-color: rgba(37,211,102,.3); }

.endpoint-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg2);
  cursor: pointer;
  flex-wrap: wrap;
}
.endpoint-body {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.endpoint-body p { font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.endpoint-body pre { margin: 6px 0 0; }

.endpoint-path {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  background: none;
  padding: 0;
  font-family: 'Fira Code', monospace;
}
.endpoint-desc {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-left: auto;
}

/* Method badges */
.method {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 5px;
  letter-spacing: .5px;
  flex-shrink: 0;
  min-width: 56px;
  justify-content: center;
}
.method.get    { background: rgba(37,211,102,.15); color: #4ade80; }
.method.post   { background: rgba(59,130,246,.15);  color: #60a5fa; }
.method.put    { background: rgba(251,191,36,.12);  color: #fbbf24; }
.method.delete { background: rgba(239,68,68,.15);   color: #f87171; }

@media (max-width: 640px) {
  .sidebar { width: 60px; }
  .sidebar-brand .brand-name, .nav-item span:last-child, .sidebar-status .label { display: none; }
  .brand-icon { margin: 0 auto; }
  .nav-item { justify-content: center; padding: 12px 8px; }
  .nav-icon { margin: 0; }
}
