/* style.css - ChartPilot Production Complète */
:root {
  --bg: #0d111c;
  --panel: #1a2030;
  --muted: #94a3b8;
  --green: #10b981;
  --red: #ef4444;
  --orange: #f59e0b;
  --blue: #3b82f6;
  --yellow: #facc15;
  --purple: #ba68c8;
  --ring: rgba(16, 185, 129, .35);
  --shadow: 0 6px 18px rgba(0, 0, 0, .25);
}

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

body {
  background: linear-gradient(135deg, #0f1530, #101826 60%, #0b1224);
  color: #fff;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, Arial, sans-serif;
  min-height: 100vh;
}

.wrap {
  display: grid;
  grid-template-columns: 320px 1fr 360px 340px;
  gap: 15px;
  min-height: 100vh;
  padding: 15px;
}

.card {
  background: var(--panel);
  border: 1px solid #0d111c;
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow);
}

h1, h2, h3 {
  margin: 0 0 8px;
}

h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

/* KPI Circle */
#kpi-circle {
  display: grid;
  place-items: center;
  height: 220px;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  margin-bottom: 15px;
}

#kpi-circle .circle {
  width: 160px;
  height: 160px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #252f45;
  box-shadow: 0 0 0 10px #223, 0 0 50px var(--ring) inset;
}

#kpi-signal {
  font-weight: 700;
  font-size: 32px;
  color: var(--green);
}

#state-btn {
  margin-top: 8px;
  padding: 5px 14px;
  background: var(--green);
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  border: none;
  color: #fff;
  cursor: default;
}

#kpi-reason {
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  max-width: 200px;
}

/* Gauges */
.g {
  margin-top: 8px;
}

.g .lbl {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
}

.bar-track {
  height: 8px;
  background: #2b344b;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  width: 40%;
  background: var(--green);
  transition: width .4s ease, background .4s ease;
  border-radius: 999px;
}

.gauge-val {
  font: 600 11px/1 monospace;
  color: #d6e0ff;
}

/* Stats Grid - ESPACEMENTS CORRIGÉS */
.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 50px;
}

.stat {
  background: #253048;
  border-radius: 6px;
  text-align: center;
  padding: 10px 4px;
  min-width: 0;
  overflow: hidden;
}

.stat .val {
  font: 700 14px/1.1 monospace;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Valeurs spécifiques plus petites */
#stat-support,
#stat-resistance,
#stat-atr,
#stat-ema20,
#stat-ema50,
#stat-donchian-h,
#stat-donchian-l {
  font-size: 12px;
}

#stat-quality,
#stat-rr {
  font-size: 14px;
}

.stat .lab {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: -0.3px;
}

/* Selectors */
#tf-selector,
#symbol-selector {
  display: flex;
  gap: 5px;
  background: #1c2436;
  border-radius: 8px;
  padding: 5px 6px;
  margin-bottom: 8px;
}

#tf-selector {
  position: sticky;
  top: 10px;
  z-index: 10;
  margin-bottom: 12px;
}

.tf-item,
.sym-item {
  padding: 6px 8px;
  border-radius: 6px;
  background: #2a344e;
  color: #cdd7ff;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  border: none;
  transition: all 0.3s;
}

.tf-item.active {
  background: var(--blue);
  color: #fff;
}

.sym-item.active {
  background: var(--purple);
  color: #fff;
}

/* Chart Area - FIX CHROME */
#chart-area {
  height: 400px;
  position: relative;
  background: #161b2e;
  border-radius: 8px;
  padding: 20px;
}

#chart {
  width: 100%;
  height: 100%;
  pointer-events: auto !important;
  touch-action: manipulation !important;
}

/* FIX POUR CHROME - DÉSACTIVER PASSIVE LISTENERS */
#chart .u-wrap {
  pointer-events: auto !important;
  touch-action: manipulation !important;
}

#chart .u-over {
  pointer-events: auto !important;
  touch-action: none !important;
  cursor: crosshair !important;
  will-change: transform !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

#chart .u-under {
  pointer-events: none !important;
}

#chart canvas {
  pointer-events: none !important;
}

#loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  color: var(--green);
  pointer-events: none;
}

/* Zoom Controls */
.zoom-controls {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1000;
  display: flex;
  gap: 4px;
}

.zoom-controls button {
  padding: 4px 8px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
}

.zoom-controls button:hover {
  background: var(--orange);
}

/* Signals */
.sig {
  display: grid;
  gap: 8px;
}

.sig .item {
  display: flex;
  gap: 8px;
}

.badge {
  min-width: 70px;
  text-align: center;
  padding: 5px 8px;
  border-radius: 5px;
  font: 700 10px/1.1 system-ui;
}

.b-buy { background: var(--green); color: #fff; }
.b-sell { background: var(--red); color: #fff; }
.b-trend { background: var(--blue); color: #fff; }
.b-alert { background: var(--orange); color: #fff; }
.b-info { background: var(--yellow); color: #222; }

.sig .msg {
  flex: 1;
  background: #253048;
  padding: 6px;
  border-radius: 5px;
}

.sig .time {
  font-size: 10px;
  color: var(--muted);
}

.sig .txt {
  font-size: 11px;
  margin-top: 2px;
  color: #d6e0ff;
}

/* Learning Zone - ESPACEMENTS CORRIGÉS */
.learning-tip {
  background: #253048;
  border-left: 3px solid var(--green);
  padding: 10px;
  margin-top: 20px; /* Augmenté pour éviter la superposition */
  margin-bottom: 15px; /* Espace en bas */
  border-radius: 6px;
  clear: both; /* Évite la superposition */
  position: relative; /* Force le contexte de positionnement */
}

.learning-tip h4 {
  color: var(--green);
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
}

.learning-tip p,
#tip-message {
  font-size: 11px;
  line-height: 1.4;
  color: #d6e0ff;
  margin: 3px 0;
  white-space: pre-line;
}

.learning-tip .action,
#tip-action {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  color: var(--yellow);
}

/* Checklist */
.checklist {
  background: #253048;
  border-radius: 6px;
  padding: 10px;
  margin: 8px 0;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  font-size: 11px;
  color: #d6e0ff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.checklist-item:last-child {
  border-bottom: none;
}

.checklist-item input {
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Score Breakdown - ESPACEMENTS CORRIGÉS */
.score-breakdown {
  background: #253048;
  border-radius: 6px;
  padding: 10px;
  margin: 8px 0;
}

.score-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.score-item:last-child {
  border-bottom: none;
  font-weight: bold;
  margin-top: 5px;
  padding-top: 8px;
  border-top: 2px solid rgba(255, 255, 255, 0.2);
}

.score-label {
  color: #d6e0ff;
}

.score-value {
  color: var(--green);
  font-weight: 600;
}

.score-value.negative {
  color: var(--red);
}

/* Trading Journal */
.journal-entry {
  background: #253048;
  border-radius: 5px;
  padding: 8px;
  margin: 6px 0;
  font-size: 11px;
}

.journal-entry.win {
  border-left: 3px solid var(--green);
}

.journal-entry.loss {
  border-left: 3px solid var(--red);
}

.journal-time {
  color: var(--muted);
  font-size: 10px;
}

.journal-result {
  font-weight: 600;
  margin: 3px 0;
}

.journal-lesson {
  font-style: italic;
  color: #94a3b8;
  font-size: 10px;
}

/* Market Context */
.context-box {
  background: #253048;
  border-radius: 6px;
  padding: 10px;
  margin: 8px 0;
}

.context-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 11px;
}

.context-label {
  color: var(--muted);
}

.context-value {
  color: #d6e0ff;
  font-weight: 600;
}

/* Position Calculator */
.calc-input {
  width: 100%;
  padding: 6px;
  margin: 5px 0;
  background: #2a344e;
  border: 1px solid #0d111c;
  border-radius: 5px;
  color: #fff;
  font-size: 11px;
}

.calc-result {
  background: #2a344e;
  border-radius: 5px;
  padding: 8px;
  margin-top: 8px;
}

.calc-result p {
  font-size: 11px;
  margin: 3px 0;
}

.calc-result .important {
  color: var(--yellow);
  font-weight: 600;
}

/* Degraded Mode Banner */
#degraded-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  color: white;
  padding: 6px 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* Responsive Design */
@media (max-width: 1600px) {
  .wrap {
    grid-template-columns: 280px 1fr 320px 300px;
    gap: 12px;
  }
  
  .stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  
  .stat .val {
    font-size: 13px;
  }
}

@media (max-width: 1400px) {
  .wrap {
    grid-template-columns: 1fr 350px;
    grid-template-rows: auto auto;
    gap: 10px;
  }
  
  .card:nth-child(1) { grid-column: 1; grid-row: 1; }
  .card:nth-child(2) { grid-column: 1; grid-row: 2; }
  .card:nth-child(3) { grid-column: 2; grid-row: 1; }
  .card:nth-child(4) { grid-column: 2; grid-row: 2; }
  
  .stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1200px) {
  .stat .val {
    font-size: 12px;
  }
  
  .stat .lab {
    font-size: 9px;
  }
  
  #chart-area {
    height: 350px;
  }
}

@media (max-width: 1000px) {
  .wrap {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 10px;
  }
  
  .stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }
  
  #chart-area {
    height: 320px;
    padding: 10px;
  }
  
  #kpi-circle {
    height: 180px;
  }
  
  #kpi-circle .circle {
    width: 140px;
    height: 140px;
  }
}

@media (max-width: 600px) {
  .wrap {
    padding: 8px;
    gap: 8px;
  }
  
  .card {
    padding: 10px;
  }
  
  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
  }
  
  .stat {
    padding: 8px 3px;
  }
  
  .stat .val {
    font-size: 11px;
  }
  
  .stat .lab {
    font-size: 8px;
  }
  
  #kpi-circle {
    height: 160px;
  }
  
  #kpi-circle .circle {
    width: 120px;
    height: 120px;
  }
  
  #kpi-signal {
    font-size: 24px;
  }
  
  #chart-area {
    height: 280px;
    padding: 8px;
  }
  
  .tf-item,
  .sym-item {
    padding: 5px 6px;
    font-size: 10px;
  }
  
  h3 {
    font-size: 14px;
  }
  
  h4 {
    font-size: 12px;
  }
}