/* ════════════════════════════════════════════════════════════════
   PSYCHIATRIE DE PRÉCISION — Styles
   Reprend la charte de l'app Streamlit : teal #007481 / bleu #00578a,
   rainbow divider, cartes colorées, badges de niveau.
   ════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&family=DM+Mono:wght@400;500&family=DM+Serif+Display&display=swap');

:root {
  --teal: #007481;
  --blue: #00578a;
  --navy: #0d1b35;
  --sky: #4a9eff;
  --red: #cc0000;
  --ink: #1e293b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: 'Outfit', system-ui, sans-serif;
  color: var(--ink);
  /* Fond bleu dégradé (remplace l'ancienne image brain.jpg) */
  background: linear-gradient(160deg, #00415f 0%, #00578a 45%, #0a7c8c 100%) fixed;
  min-height: 100vh;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 18px 20px 60px; }

/* ── Rainbow divider ── */
.rainbow-divider {
  height: 3px;
  background: linear-gradient(to right, #cc0000, #ff7700, #ffcc00, #007481, #00578a, #6a0dad);
  border-radius: 2px;
  margin: 14px 0;
}

/* ── Hero ── */
.hero-title {
  text-align: center; background: var(--teal); border-radius: 15px; padding: 8px 16px;
}
.hero-title h1 { color: #fff; font-size: 22px; margin: 0; letter-spacing: .5px; }
.hero-img {
  height: 220px; overflow: hidden; border-radius: 14px; width: 100%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #0a7c8c 0%, #00578a 55%, #003d63 100%);
  position: relative;
}
.hero-img .brain {
  font-size: 120px; line-height: 1;
  filter: drop-shadow(0 0 22px rgba(120,200,255,.55));
  animation: brainFloat 4s ease-in-out infinite, brainPulse 2.6s ease-in-out infinite;
}
@keyframes brainFloat {
  0%, 100% { transform: translateY(-8px) rotate(-3deg); }
  50%      { transform: translateY(8px) rotate(3deg); }
}
@keyframes brainPulse {
  0%, 100% { filter: drop-shadow(0 0 14px rgba(120,200,255,.45)); }
  50%      { filter: drop-shadow(0 0 34px rgba(150,220,255,.85)); }
}
@media (prefers-reduced-motion: reduce) { .hero-img .brain { animation: none; } }
.hero-date { text-align: center; color: #fff; font-size: 18px; margin: 6px 0; }

/* ── Auth ── */
.auth-card {
  background: #fff; border-radius: 14px; padding: 26px 30px; max-width: 520px;
  margin: 10px auto; box-shadow: 0 2px 18px rgba(0,87,138,.12);
}
.auth-card h2 { color: var(--blue); margin: 0 0 4px; }
.auth-note { color: var(--red); font-size: 15px; margin-bottom: 14px; }
label.fld { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; color: #334155; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px;
  font-family: inherit; font-size: 15px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,116,129,.15); }

/* ── Boutons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(90deg, var(--teal), var(--blue)); color: #fff;
  border: none; border-radius: 8px; font-weight: 600; font-size: 16px;
  padding: 11px 22px; width: 100%; cursor: pointer; transition: opacity .2s;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--blue); border: 1px solid #cbd5e1; }
.btn-sm { width: auto; padding: 8px 16px; font-size: 14px; }

/* ── Tabs ── */
.tabbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.tabbar button {
  flex: 1 1 auto; background: #fff; border: 1px solid #cbd5e1; border-radius: 10px;
  padding: 10px 12px; font-weight: 600; font-size: 14px; color: #475569; cursor: pointer;
}
.tabbar button.active { background: linear-gradient(90deg, var(--teal), var(--blue)); color: #fff; border-color: transparent; }
.subtabbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.subtabbar button { background: #eef2f6; border: 1px solid #dbe3ea; border-radius: 8px;
  padding: 8px 12px; font-weight: 600; font-size: 13px; color: #475569; cursor: pointer; }
.subtabbar button.active { background: var(--blue); color: #fff; border-color: transparent; }

/* ── Sections ── */
.section { background: rgba(255,255,255,.92); border-radius: 14px; padding: 18px 20px;
  margin-bottom: 16px; box-shadow: 0 1px 10px rgba(0,87,138,.07); }
h2.sec-title { color: var(--blue); font-size: 19px; margin: 4px 0 2px; }
.sec-label { font-family: 'DM Mono', monospace; font-size: .72rem; letter-spacing: .08em;
  color: #64748b; text-transform: uppercase; margin: 10px 0 6px; }
.caption { color: #64748b; font-size: 13px; margin: 2px 0 10px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ── Cartes colorées ── */
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px 16px;
  margin-bottom: 10px; color: var(--ink); }
.card-teal   { border-left: 5px solid #14b8a6; background: #f0fdfa; }
.card-purple { border-left: 5px solid #a855f7; background: #faf5ff; }
.card-blue   { border-left: 5px solid #3b82f6; background: #eff6ff; }
.card-green  { border-left: 5px solid #22c55e; background: #f0fdf4; }
.card-orange { border-left: 5px solid #f97316; background: #fff7ed; }
.card-red    { border-left: 5px solid #ef4444; background: #fef2f2; }
.card-indigo { border-left: 5px solid #6366f1; background: #eef2ff; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .72rem;
  font-weight: 700; letter-spacing: .04em; }
.badge-none   { background: #dcfce7; color: #15803d; }
.badge-low    { background: #fef9c3; color: #a16207; }
.badge-medium { background: #ffedd5; color: #c2410c; }
.badge-high   { background: #fee2e2; color: #b91c1c; }

.tag-langue { display: inline-block; background: #e0f2fe; color: #0369a1; font-size: .72rem;
  border-radius: 6px; padding: 3px 9px; margin-right: 6px; font-weight: 600; }

/* ── Barre de risque ── */
.risk-bar { height: 8px; background: #e2e8f0; border-radius: 5px; overflow: hidden; margin: 8px 0; }
.risk-fill { height: 100%; border-radius: 5px; transition: width .4s; }

/* ── Bannière d'alerte ── */
.alert-banner { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b;
  border-radius: 12px; padding: 14px 18px; margin: 12px 0; font-size: 14px; line-height: 1.5; }

/* ── Progress ── */
.progress { height: 10px; background: #e2e8f0; border-radius: 6px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--teal), var(--sky)); width: 0; transition: width .3s; }
.progress-msg { color: var(--sky); font-family: 'DM Mono', monospace; font-size: .85rem; }

/* ── Échelle / questions ── */
.q-row { margin-bottom: 10px; }
.q-text { font-size: .9rem; margin-bottom: 6px; }
.opt-row { display: flex; flex-wrap: wrap; gap: 6px; }
.opt-row label { display: inline-flex; align-items: center; gap: 5px; background: #fff;
  border: 1px solid #cbd5e1; border-radius: 7px; padding: 5px 10px; font-size: 13px; cursor: pointer; }
.opt-row input { width: auto; }

/* ── Narratif ── */
.narrative { background: #fff; border-radius: 12px; padding: 18px 22px; line-height: 1.65;
  font-size: 15px; color: #1e293b; }
.narrative h3 { color: var(--blue); font-size: 16px; margin: 16px 0 6px; }

/* ── Stat / score card ── */
.stat { text-align: center; }
.stat .lbl { font-family: 'DM Mono', monospace; font-size: .7rem; color: #64748b; }
.stat .val { font-family: 'DM Serif Display', serif; font-size: 2rem; }

/* ── Notes ── */
.expander { background: rgba(255,255,255,.92); border-radius: 12px; margin-bottom: 12px; overflow: hidden;
  box-shadow: 0 1px 10px rgba(0,87,138,.07); }
.expander > summary { cursor: pointer; padding: 14px 18px; font-weight: 600; color: var(--blue); list-style: none; }
.expander > summary::-webkit-details-marker { display: none; }
.expander > summary::before { content: "▸ "; color: var(--teal); }
.expander[open] > summary::before { content: "▾ "; }
.expander .body { padding: 0 18px 16px; }

.hidden { display: none !important; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #cbd5e1;
  border-top-color: var(--teal); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TCC (onglet 4) / TEX (onglet 5) ── */
.metric-box { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px; text-align: center; }
.metric-num { font-family: 'DM Serif Display', serif; font-size: 1.5rem; color: var(--blue); }
.metric-label { font-size: .74rem; color: #64748b; margin-top: 2px; }
.card-title { font-weight: 700; color: #1e2533; font-size: 1rem; margin-bottom: 8px; }
.card-sm { background: #fff; border: 1px solid #eef1f6; border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.card-title-sm { font-weight: 600; color: #3a4d6b; font-size: .86rem; margin-bottom: 5px; }
.section-title { font-family: 'DM Serif Display', serif; font-size: 1.25rem; color: var(--blue); margin: 4px 0 8px; }
.divider { border: none; border-top: 1px solid #e2e8f0; margin: 14px 0; }
.prog-bg { height: 10px; background: #e2e8f0; border-radius: 6px; overflow: hidden; margin-top: 6px; }
.prog-fill { height: 100%; background: linear-gradient(90deg, #3d8b7a, #4a9eff); transition: width .4s; }
.timeline { display: flex; flex-wrap: wrap; gap: 4px; justify-content: space-between; margin: 10px 0; }
.tl-step { flex: 1 1 8%; text-align: center; min-width: 56px; }
.tl-dot { width: 30px; height: 30px; border-radius: 50%; margin: 0 auto; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; color: #fff; }
.tl-done { background: #3d8b7a; } .tl-current { background: #d4843a; } .tl-pending { background: #cbd5e1; color: #64748b; }
.tl-label { font-size: .62rem; color: #7a8699; margin-top: 3px; }
.ai-box { background: #f0f7fb; border-left: 4px solid var(--sky); border-radius: 8px; padding: 12px 14px; font-size: .9rem; line-height: 1.6; white-space: pre-wrap; }
.ai-box-amber { background: #fff8f0; border-left: 4px solid #d4843a; border-radius: 8px; padding: 12px 14px; font-size: .9rem; line-height: 1.6; white-space: pre-wrap; }
.chip { display: inline-block; background: #eef2f6; color: #3a4d6b; border-radius: 999px; padding: 3px 10px; font-size: .74rem; margin: 2px 4px 2px 0; }
.badge-done { background: #dcfce7; color: #15803d; } .badge-curr { background: #ffedd5; color: #c2410c; }
.badge-current { background: #ffedd5; color: #c2410c; } .badge-locked { background: #e2e8f0; color: #64748b; }
.alert { border-radius: 10px; padding: 11px 15px; font-size: .9rem; margin: 8px 0; }
.alert-warn { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.alert-jade { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.triangle-box { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px; height: 100%; }
.triangle-label { font-size: .72rem; color: #7a8699; font-weight: 600; }
.triangle-val { font-size: .85rem; color: #1e2533; margin-top: 3px; }

.footer-note { text-align: center; color: #94a3b8; font-size: 12px; margin-top: 24px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; transition: opacity .3s; z-index: 99; }
.toast.show { opacity: 1; }
