/* =========================================================================
   1AI TRADER — Habillage des outils (AI Signals + Assistant IA) — additif
   Tout est limité à body.st21-tool (posé uniquement sur ces deux pages).
   Ne change aucune logique : cadre du graphique, légende, boutons, pastilles, panneaux.
   Clair / sombre / RTL. Mouvements coupés avec « réduire les animations ».
   ========================================================================= */

/* ---------------------------------------------------------------- cadre du graphique */
body.st21-tool .algo-chart-frame {
  position: relative; isolation: isolate;
  border-color: color-mix(in srgb, var(--algo-accent) 30%, var(--algo-border));
  border-radius: 18px;
  background:
    radial-gradient(80% 60% at 50% -10%, color-mix(in srgb, var(--algo-accent) 10%, transparent), transparent 70%),
    var(--algo-surface);
  box-shadow: var(--algo-shadow-md), 0 0 0 1px color-mix(in srgb, var(--algo-accent) 8%, transparent),
              0 24px 60px -28px color-mix(in srgb, var(--algo-accent) 45%, transparent);
}
body.st21-tool .asst-chart-wrap {
  border-radius: 14px; overflow: hidden;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--algo-accent) 18%, transparent);
}

/* ---------------------------------------------------------------- légende O / H / L / C */
.st21-legend {
  position: absolute; inset-block-start: 8px; left: 10px; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; max-width: calc(100% - 90px);
  padding: 5px 10px; border-radius: 10px; pointer-events: none; direction: ltr; unicode-bidi: isolate;
  font: 500 11.5px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums;
  color: var(--algo-ink);
  background: color-mix(in srgb, var(--algo-surface) 72%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid color-mix(in srgb, var(--algo-border) 80%, transparent);
}
.st21-legend[hidden] { display: none; }
.st21-legend em { font-style: normal; color: var(--algo-muted); margin-inline-end: 3px; }
.st21-legend b { font-weight: 700; }
.st21-legend.is-up b { color: var(--algo-positive); }
.st21-legend.is-down b { color: var(--algo-negative); }
#asst-chart .st21-legend { left: 58px; }                 /* laisse la place à la barre d'outils de dessin */

/* ---------------------------------------------------------------- pastille d'état « en direct » */
body.st21-tool #sig-status, body.st21-tool #asst-status {
  display: inline-flex; align-items: center; gap: 7px;
}
body.st21-tool #sig-status::before, body.st21-tool #asst-status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--algo-positive); box-shadow: 0 0 0 0 color-mix(in srgb, var(--algo-positive) 55%, transparent);
  animation: st21-live 2s ease-out infinite;
}
@keyframes st21-live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--algo-positive) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 8px transparent; } }

/* ---------------------------------------------------------------- boutons et pastilles */
body.st21-tool .asst-topbtn, body.st21-tool .sig-chip, body.st21-tool .asst-tab, body.st21-tool .asst-tool-btn, body.st21-tool .algo-mkt-trigger {
  transition: transform .2s cubic-bezier(.16,1,.3,1), background-color .2s ease, border-color .2s ease, box-shadow .25s ease, color .2s ease;
}
@media (hover: hover) {
  body.st21-tool .asst-topbtn:hover, body.st21-tool .sig-chip:hover, body.st21-tool .algo-mkt-trigger:hover { transform: translateY(-1px); border-color: var(--algo-accent); }
  body.st21-tool .asst-tool-btn:hover { transform: scale(1.08); }
}
body.st21-tool .sig-chip.is-on, body.st21-tool .asst-topbtn.is-on, body.st21-tool .asst-tool-btn.is-on, body.st21-tool .asst-tab.is-on {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--algo-accent) 55%, transparent), 0 6px 18px -6px color-mix(in srgb, var(--algo-accent) 55%, transparent);
}

/* ---------------------------------------------------------------- cartes et fenêtres en verre */
body.st21-tool .algo-card {
  background: color-mix(in srgb, var(--algo-surface) 78%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(1.25); backdrop-filter: blur(12px) saturate(1.25);
  border-color: color-mix(in srgb, var(--algo-accent) 16%, var(--algo-border));
}
body.st21-tool .algo-modal-backdrop { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
body.st21-tool .algo-modal-card {
  border: 1px solid color-mix(in srgb, var(--algo-accent) 28%, var(--algo-border));
  box-shadow: var(--algo-shadow-lg), 0 0 60px -20px color-mix(in srgb, var(--algo-accent) 50%, transparent);
}

/* ---------------------------------------------------------------- Assistant IA : barre, panneaux, saisie */
body.st21-tool .asst-topbar {
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--algo-accent) 20%, var(--algo-border));
}
body.st21-tool .asst-chat-panel, body.st21-tool .asst-sig-panel, body.st21-tool .asst-ind-panel {
  border-color: color-mix(in srgb, var(--algo-accent) 26%, var(--algo-border));
  box-shadow: var(--algo-shadow-lg), 0 0 50px -22px color-mix(in srgb, var(--algo-accent) 45%, transparent);
}
body.st21-tool .chat-input-wrapper { transition: box-shadow .25s ease, border-color .25s ease; }
body.st21-tool .chat-input-wrapper:focus-within {
  border-color: var(--algo-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--algo-accent) 22%, transparent), 0 10px 30px -12px color-mix(in srgb, var(--algo-accent) 50%, transparent);
}

/* ---------------------------------------------------------------- Assistant IA : bulles de discussion */
body.st21-tool .message-row.ai .message-bubble {
  background: color-mix(in srgb, var(--algo-accent) 6%, var(--algo-surface));
  border: 1px solid color-mix(in srgb, var(--algo-accent) 20%, var(--algo-border));
  box-shadow: 0 10px 30px -16px color-mix(in srgb, var(--algo-accent) 45%, transparent);
}
body.st21-tool .message-row .message-bubble { transition: box-shadow .25s ease, transform .25s ease; }
body.st21-tool .message-row.user .message-bubble { box-shadow: 0 10px 26px -14px color-mix(in srgb, var(--algo-accent) 60%, transparent); }
@media (prefers-reduced-motion: no-preference) {
  body.st21-tool .message-row { animation: st21-rise .45s cubic-bezier(.16,1,.3,1) both; }
}

/* ---------------------------------------------------------------- apparition douce du graphique */
@media (prefers-reduced-motion: no-preference) {
  body.st21-tool .algo-chart-frame, body.st21-tool .asst-chart-wrap { animation: st21-rise .7s cubic-bezier(.16,1,.3,1) both; }
}
@keyframes st21-rise { from { opacity: 0; transform: translateY(14px) scale(.99); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  body.st21-tool #sig-status::before, body.st21-tool #asst-status::before { animation: none; }
  body.st21-tool .asst-topbtn, body.st21-tool .sig-chip, body.st21-tool .asst-tab, body.st21-tool .asst-tool-btn, body.st21-tool .algo-mkt-trigger { transition: none; transform: none !important; }
}
@media (max-width: 720px) { .st21-legend { font-size: 10.5px; gap: 3px 8px; padding: 4px 8px; } #asst-chart .st21-legend { left: 10px; inset-block-start: 40px; } }

/* ---------------------------------------------------------------- tableaux et KPI (journal, watchlist, résultats, acteurs du marché) */
body.st21-tool .algo-table tbody tr, body.st21-tool .calc-table tbody tr, body.st21-tool #wl-table tbody tr {
  transition: background-color .2s ease;
}
@media (hover: hover) {
  body.st21-tool .algo-table tbody tr:hover, body.st21-tool .calc-table tbody tr:hover, body.st21-tool #wl-table tbody tr:hover {
    background: color-mix(in srgb, var(--algo-accent) 8%, transparent);
  }
}
body.st21-tool .jr-kpi {
  background: color-mix(in srgb, var(--algo-surface) 70%, transparent);
  border-color: color-mix(in srgb, var(--algo-accent) 18%, var(--algo-border));
  transition: transform .25s cubic-bezier(.16,1,.3,1), border-color .25s ease, box-shadow .25s ease;
}
@media (hover: hover) {
  body.st21-tool .jr-kpi:hover { transform: translateY(-2px); border-color: var(--algo-accent); box-shadow: 0 10px 24px -14px color-mix(in srgb, var(--algo-accent) 60%, transparent); }
}
body.st21-tool #jr-svg { filter: drop-shadow(0 6px 10px color-mix(in srgb, var(--algo-accent) 25%, transparent)); }
@media (prefers-reduced-motion: reduce) { body.st21-tool .jr-kpi, body.st21-tool .jr-kpi:hover { transition: none; transform: none; } }

/* ---------------------------------------------------------------- jauge en anneau (taux de réussite réel) */
.st21-gauge { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 14px auto 4px; }
.st21-gauge[hidden] { display: none; }
.st21-gauge svg { width: 132px; height: 132px; overflow: visible; }
.st21-gauge--lg svg { width: 150px; height: 150px; }
.st21-gauge circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.st21-g-bg { stroke: var(--algo-border); }
.st21-g-ci { stroke: color-mix(in srgb, var(--algo-accent) 28%, transparent); }
.st21-g-val { stroke: var(--algo-accent); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--algo-accent) 55%, transparent)); }
.st21-g-txt { font: 700 17px var(--algo-font-display, system-ui); fill: var(--algo-ink); }
.st21-g-cap { font-size: .8rem; color: var(--algo-muted); text-align: center; max-width: 18ch; }

/* ---------------------------------------------------------------- courbe du capital : zone sous la courbe + point final */
body.st21-tool #jr-svg .st21-area { animation: st21-fade 1.2s ease .3s both; }
body.st21-tool #jr-svg .st21-dot { animation: st21-pop .5s cubic-bezier(.34,1.56,.64,1) 1s both; transform-box: fill-box; transform-origin: center; }
@keyframes st21-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes st21-pop { from { opacity: 0; transform: scale(.2); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- watchlist : clignotement du prix qui change */
.st21-flash-up { animation: st21-fup .9s ease-out; }
.st21-flash-dn { animation: st21-fdn .9s ease-out; }
@keyframes st21-fup { 0% { background: color-mix(in srgb, var(--algo-positive) 35%, transparent); color: var(--algo-positive); } 100% { background: transparent; } }
@keyframes st21-fdn { 0% { background: color-mix(in srgb, var(--algo-negative) 35%, transparent); color: var(--algo-negative); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) {
  body.st21-tool #jr-svg .st21-area, body.st21-tool #jr-svg .st21-dot, .st21-flash-up, .st21-flash-dn { animation: none; }
  .st21-g-val { transition: none !important; }
}

/* ---------------------------------------------------------------- Journal : garde-fous et check-list */
.st21-guard__status { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--algo-border); background: var(--algo-surface-2); }
.st21-guard__status.is-ok { border-color: color-mix(in srgb, var(--algo-positive) 45%, transparent); background: color-mix(in srgb, var(--algo-positive) 10%, transparent); }
.st21-guard__status.is-near { border-color: color-mix(in srgb, #F59E0B 55%, transparent); background: color-mix(in srgb, #F59E0B 12%, transparent); }
.st21-guard__status.is-hit { border-color: color-mix(in srgb, var(--algo-negative) 55%, transparent); background: color-mix(in srgb, var(--algo-negative) 12%, transparent); }
.st21-guard__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px dashed var(--algo-border); }
.st21-guard__row:last-child { border-bottom: 0; }
.st21-guard__val { font-variant-numeric: tabular-nums; font-weight: 600; text-align: end; }
.st21-guard__val small { color: var(--algo-muted); font-weight: 400; }
.st21-guard__bar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--algo-border); overflow: hidden; }
.st21-guard__bar i { display: block; height: 100%; border-radius: 3px; background: var(--algo-positive); transition: width .6s cubic-bezier(.16,1,.3,1); }
.st21-guard__row.is-near .st21-guard__bar i { background: #F59E0B; }
.st21-guard__row.is-hit .st21-guard__bar i { background: var(--algo-negative); }
.st21-check label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.st21-check input[type=checkbox] { margin-top: 4px; accent-color: var(--algo-accent); }
.st21-check__out { margin: 10px 0 0; padding: 10px 14px; border-radius: 12px; font-weight: 600; border: 1px solid var(--algo-border); }
.st21-check__out.is-ok { border-color: color-mix(in srgb, var(--algo-positive) 45%, transparent); background: color-mix(in srgb, var(--algo-positive) 10%, transparent); }
.st21-check__out.is-near { border-color: color-mix(in srgb, #F59E0B 55%, transparent); background: color-mix(in srgb, #F59E0B 12%, transparent); }
@media (prefers-reduced-motion: reduce) { .st21-guard__bar i { transition: none; } }
