/* ═══════════════════════════════════════════════════════════════
   dashboard.css — Polymarket Paper Bot
   Palette : un token CSS = un seul rôle sémantique
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  /* Fonds */
  --bg:  #060b18;
  --bg2: #0d1428;
  --bg3: #111d35;
  --border: #1c2d50;

  /* Textes */
  --white: #dce8ff;
  --muted: #4a5c80;

  /* ── Couleurs SÉMANTIQUES (état/message) ── */
  --c-gain:      #00e67a;   /* gain, succès, live */
  --c-loss:      #ff4d4d;   /* perte, erreur, alerte */
  --c-info:      #5b8dee;   /* information neutre, accent UI */
  --c-warn:      #ffc947;   /* avertissement, vigilance */
  --c-teach:     #38bdf8;   /* leçons à Léo (distinct du cyan info) */
  --c-postmortem:#a855f7;   /* post-mortems, analyse profonde */
  --c-banter:    #facc15;   /* bavardage, humour */
  --c-strategy:  #6366f1;   /* mises à jour stratégiques */
  --c-wallet:    #f59e0b;   /* wallet tracker, alertes financières */
  --c-pre-shock: #10b981;   /* signal pré-choc détecté */
  --c-momentum:  #fb923c;   /* momentum trade */

  /* ── Couleurs SCOUTS (identité, jamais réutilisées pour état) ── */
  --scout-gemini:     #5b8dee;
  --scout-groq:       #00e67a;
  --scout-mistral:    #e8a000;   /* or distinct de --c-warn */
  --scout-openrouter: #ff6b6b;
  --scout-deepseek:   #a78bfa;
  --scout-cerebras:   #fb923c;

  /* ── Espacements / typo ── */
  --radius:  12px;
  --radius-s: 8px;
  --radius-xs: 4px;
  --gap:     13px;
  --gap-s:   8px;
  --fs-sm:   .78rem;
  --fs-xs:   .7rem;
  --fs-xxs:  .65rem;
}

body {
  background: var(--bg);
  color: var(--white);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  padding: 0;
}

/* ── Header ─────────────────────────────────────────────────── */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 99;
}
header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--c-info);
  display: flex;
  align-items: center;
  gap: 8px;
}
.hright { display: flex; align-items: center; gap: 18px; font-size: .8rem; color: var(--muted); }
.live {
  background: #0a2a15;
  border: 1px solid #00aa55;
  color: var(--c-gain);
  padding: 3px 11px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dot {
  width: 7px; height: 7px;
  background: var(--c-gain);
  border-radius: 50%;
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .2; } }

/* ── Layout principal ───────────────────────────────────────── */
.main-layout { display: flex; width: 100%; min-height: calc(100vh - 52px); }

.main-content {
  flex: 0 0 64%; width: 64%;
  padding: 22px 20px;
  min-width: 0;
  overflow-x: auto;
}
.chat-sidebar {
  flex: 0 0 36%; width: 36%; min-width: 340px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  transition: flex-basis .25s ease, width .25s ease;
}
.chat-sidebar.collapsed {
  flex: 0 0 42px !important;
  width: 42px !important;
  min-width: 42px !important;
  overflow: hidden;
}
.chat-sidebar.collapsed .chat-messages,
.chat-sidebar.collapsed .chat-input-area,
.chat-sidebar.collapsed .chat-header-title { display: none; }

@media (max-width: 1300px) {
  .main-content  { flex: 0 0 60%; width: 60%; }
  .chat-sidebar  { flex: 0 0 40%; width: 40%; min-width: 320px; }
}
@media (max-width: 900px) {
  .chat-sidebar { display: none; }
  .main-content { flex: 0 0 100%; width: 100%; }
  /* Le chat est accessible via le bouton drawer */
  .chat-drawer-btn { display: flex !important; }
}

/* ── Drawer mobile (chat) ────────────────────────────────────── */
.chat-drawer-btn {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  background: var(--c-info);
  color: var(--bg);
  border: none;
  border-radius: 50%;
  width: 48px; height: 48px;
  font-size: 1.3rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(91,141,238,.4);
}
.chat-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(4,8,20,.85);
}
.chat-drawer-overlay.open { display: flex; flex-direction: column; }
.chat-drawer-inner {
  margin-top: auto;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  height: 70vh;
  display: flex;
  flex-direction: column;
}

/* ── Grille de stats ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--gap);
  margin-bottom: 22px;
}
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .stats-grid { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px 15px;
}
/* Carte "Héros" — pour l'Apprenti Léo (T5.2) */
.card-hero {
  background: linear-gradient(135deg, #0a1a3a 0%, #0d1f45 100%);
  border: 2px solid var(--c-info);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: 0 0 20px rgba(91,141,238,.15);
  margin-bottom: 22px;
}
.card-hero .lbl { color: var(--c-info); }

.lbl {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.val { font-size: 1.5rem; font-weight: 700; color: var(--white); }

/* ── Sections ────────────────────────────────────────────────── */
.section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 22px;
  overflow: hidden;
}
/* Section secondaire repliable (T5.3) */
.section-secondary > summary {
  background: rgba(0,0,0,.1);
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  font-weight: 700;
  font-size: .9rem;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-secondary > summary::before { content: '▶'; font-size: .7rem; }
.section-secondary[open] > summary::before { content: '▼'; }
.section-secondary[open] > summary { color: var(--white); }

.sh {
  background: rgba(0,0,0,.15);
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  font-weight: 700;
  font-size: .9rem;
  color: var(--white);
}
.sb { overflow-x: auto; }

/* ── Tableaux ────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .85rem; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); text-transform: uppercase; font-size: .68rem; font-weight: 700; letter-spacing: .5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.015); }
@media (max-width: 600px) { th, td { padding: 8px 8px; font-size: .78rem; } }

/* ── Classes utilitaires ─────────────────────────────────────── */
.empty  { text-align: center; padding: 32px; color: var(--muted); font-style: italic; }
.mono   { font-family: 'Courier New', Courier, monospace; font-weight: 600; }
.muted  { color: var(--muted); }
.hidden { display: none !important; }

/* Chip — pastille de stat / indicateur */
.chip {
  padding: 8px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  display: inline-flex;
  flex-direction: column;
}
.chip-sm { padding: 4px 10px; font-size: var(--fs-xs); }

/* Pill — étiquette courte */
.pill {
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: var(--fs-xs);
  font-weight: 700;
  display: inline-block;
}

.row-flex { display: flex; gap: var(--gap-s); flex-wrap: wrap; align-items: center; }
.gap      { gap: var(--gap); }
.gap-s    { gap: var(--gap-s); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge     { padding: 2px 8px; border-radius: var(--radius-xs); font-size: var(--fs-xs); font-weight: 700; display: inline-block; }
.badge-yes { background: #0a2a18; border: 1px solid #00aa55; color: var(--c-gain); }
.badge-no  { background: #2b0c10; border: 1px solid #aa1122; color: var(--c-loss); }
.sc-badge  { padding: 1px 6px; border-radius: var(--radius-xs); font-size: .72rem; font-weight: 700; display: inline-block; }

/* ── Barre de progression ────────────────────────────────────── */
.pb  { background: var(--bg3); border-radius: 10px; height: 6px; width: 100%; overflow: hidden; }
.pbf { height: 100%; border-radius: 10px; }

/* ── Filtres (boutons toggle) ────────────────────────────────── */
.sf-row  { display: flex; gap: 8px; flex-wrap: wrap; }
.sf-btn  {
  background: none; border: 1px solid; border-radius: 6px;
  padding: 4px 12px; font-size: var(--fs-sm); font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.sf-btn:hover   { background: rgba(255,255,255,.05); }
.sf-active      { background: rgba(255,255,255,.08) !important; font-weight: 700; }

/* ── Bouton collapse ─────────────────────────────────────────── */
.collapse-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); padding: 3px 9px; font-size: var(--fs-xs); font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.collapse-btn:hover { border-color: var(--c-info); color: var(--c-info); }

/* ── focus-visible (accessibilité) ──────────────────────────── */
:focus-visible { outline: 2px solid var(--c-info); outline-offset: 2px; }

/* ── Onglets ─────────────────────────────────────────────────── */
.tab-nav  { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 0 18px; margin-bottom: 4px; }
.tab-btn  {
  padding: 9px 18px; background: var(--bg3);
  border: 1px solid var(--border); border-radius: 10px;
  color: var(--muted); cursor: pointer; font-size: .84rem;
  font-weight: 600; transition: all .15s; white-space: nowrap;
}
.tab-btn:hover     { border-color: var(--c-info); color: var(--white); }
.tab-btn.tab-active {
  background: var(--c-info); border-color: var(--c-info);
  color: #060b18; box-shadow: 0 2px 10px rgba(91,141,238,.35);
}
.tab-pane           { display: none; }
.tab-pane.tab-active { display: block; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(4, 8, 20, 0.85); backdrop-filter: blur(8px);
  z-index: 10000; align-items: center; justify-content: center; padding: 20px;
}
.modal-content {
  background: #0d1428; border: 1px solid #1c2d50; border-radius: 16px;
  width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,.5); animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(15px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  padding: 16px 24px; border-bottom: 1px solid #1c2d50;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 1.15rem; color: var(--c-info); font-weight: 700; }
.close-btn { background: none; border: none; color: #4a5c80; font-size: 1.8rem; cursor: pointer; line-height: 1; }
.close-btn:hover { color: var(--c-loss); }
.modal-body { padding: 24px; color: var(--white); }

/* ── Chat sidebar ────────────────────────────────────────────── */
.chat-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: .9rem; color: var(--c-info);
  display: flex; align-items: center; justify-content: space-between;
}
/* Bouton replier/élargir le chat */
.chat-toggle-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); padding: 3px 8px; font-size: .75rem;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.chat-toggle-btn:hover { border-color: var(--c-info); color: var(--c-info); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-msg {
  padding: 8px 12px; border-radius: 10px; font-size: .82rem;
  line-height: 1.45; max-width: 95%; word-break: break-word;
}
.chat-msg.scout {
  background: var(--bg3); border: 1px solid var(--border);
  align-self: flex-start;
}
.chat-msg.user {
  background: #2a0808; border: 2px solid #cc2222;
  align-self: flex-end;
  box-shadow: 0 0 8px rgba(204,34,34,.35);
  border-radius: 10px 10px 2px 10px;
}
.chat-msg.user::before {
  content: "Vous"; display: block;
  font-size: .65rem; font-weight: 700; color: #ff6666;
  text-transform: uppercase; margin-bottom: 4px; letter-spacing: .05em;
}
.chat-msg.system {
  background: rgba(255,77,77,.08); border: 1px solid rgba(255,77,77,.25);
  align-self: center; text-align: center; color: #fb923c; font-weight: 600;
}
.chat-msg.smart-money {
  background: rgba(251,146,60,.1); border: 1px solid rgba(251,146,60,.4);
  align-self: center; text-align: center; color: var(--c-warn); font-weight: 600;
}
.chat-msg.source-intel {
  background: rgba(56,189,248,.07); border: 1px solid rgba(56,189,248,.3);
  align-self: center; font-size: .78rem; color: var(--c-teach);
  white-space: pre-wrap; font-family: monospace;
}
.chat-msg.postmortem {
  background: rgba(168,85,247,.07); border: 1px solid rgba(168,85,247,.25);
  align-self: flex-start; border-left: 3px solid var(--c-postmortem);
}
.chat-msg.teaching {
  background: rgba(56,189,248,.10); border: 1px solid rgba(56,189,248,.4);
  align-self: flex-start; border-left: 3px solid var(--c-teach);
}
.chat-msg.teaching::after {
  content: "Lecon a Leo"; display: block;
  font-size: .62rem; color: var(--c-teach); margin-top: 4px; font-style: italic;
}
.chat-msg.trade-closed {
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1);
  align-self: center; font-size: .78rem; color: var(--muted); font-style: italic;
}
.chat-msg.batch-report {
  background: rgba(34,197,94,.07); border: 1px solid rgba(34,197,94,.3);
  align-self: center; font-size: .80rem; color: #4ade80; white-space: pre-wrap;
}
.chat-msg.momentum-trade {
  background: rgba(251,146,60,.12); border: 2px solid rgba(251,146,60,.6);
  align-self: center; font-size: .82rem; color: var(--c-momentum);
  white-space: pre-wrap; font-weight: 600; border-radius: 8px; text-align: center;
  box-shadow: 0 0 10px rgba(251,146,60,.2);
}
.chat-msg.pre-shock {
  background: rgba(16,185,129,.12); border: 2px solid rgba(16,185,129,.7);
  align-self: center; font-size: .82rem; color: var(--c-pre-shock);
  white-space: pre-wrap; font-weight: 700; border-radius: 8px; text-align: center;
  box-shadow: 0 0 14px rgba(16,185,129,.3); letter-spacing: .01em;
}
.chat-msg.banter {
  background: rgba(250,204,21,.07); border: 1px solid rgba(250,204,21,.35);
  align-self: flex-start; border-left: 3px solid var(--c-banter);
  font-style: italic; color: #fde68a;
}
.chat-msg.strategy-update {
  background: rgba(99,102,241,.1); border: 2px solid rgba(99,102,241,.5);
  align-self: stretch; font-size: .81rem; color: #a5b4fc;
  white-space: pre-wrap; border-left: 4px solid var(--c-strategy); font-weight: 500;
}
.chat-msg.wallet-tracker {
  background: rgba(251,191,36,.10); border: 1px solid rgba(251,191,36,.45);
  align-self: center; font-size: .80rem; color: #fde68a;
  white-space: pre-wrap; border-left: 4px solid var(--c-wallet);
  font-weight: 600; text-align: left; max-width: 95%;
}
.chat-author {
  font-weight: 700; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .5px; margin-bottom: 3px;
}
.chat-time { font-size: .65rem; color: var(--muted); margin-top: 4px; text-align: right; }

.chat-input-area {
  padding: 10px; border-top: 1px solid var(--border); display: flex; gap: 8px;
}
.chat-input-area textarea {
  flex: 1; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; color: var(--white);
  font-size: .85rem; outline: none; resize: none;
  line-height: 1.45; min-height: 36px; max-height: 150px;
  overflow-y: auto; font-family: 'Segoe UI', system-ui, sans-serif;
  scrollbar-width: thin;
}
.chat-input-area textarea:focus       { border-color: var(--c-info); }
.chat-input-area textarea::placeholder { color: var(--muted); }
.chat-input-area button {
  background: var(--c-info); border: none; border-radius: 8px;
  color: #060b18; padding: 8px 14px; font-weight: 700; font-size: .8rem; cursor: pointer;
}
.chat-input-area button:hover { opacity: .85; }
.mic-btn {
  background: var(--bg3) !important; border: 1px solid var(--border) !important;
  color: var(--muted) !important; padding: 8px 10px !important;
}
.mic-btn:hover { border-color: var(--c-info) !important; color: var(--white) !important; }
.mic-btn.recording {
  background: #3d0a0a !important; border-color: var(--c-loss) !important;
  color: var(--c-loss) !important;
  box-shadow: 0 0 0 3px rgba(255,77,77,.25);
  animation: pulse-mic 1s ease-in-out infinite;
}
@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255,77,77,.25); }
  50%       { box-shadow: 0 0 0 6px rgba(255,77,77,.10); }
}
