/* WebSignal — Generate Signal UI (Block 3) */

:root {
  --bg:        #0a0e14;
  --surface:   #11161f;
  --surface-2: #161d29;
  --border:    #263041;
  --text:      #e6edf3;
  --muted:     #8b98a9;
  --green:     #22c55e;
  --green-bg:  rgba(34, 197, 94, .12);
  --red:       #ef4444;
  --red-bg:    rgba(239, 68, 68, .12);
  --blue:      #3b82f6;
  --yellow:    #eab308;
  --radius:    14px;
}

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

[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand h1 { font-size: 1.5rem; letter-spacing: .5px; }
.brand h1 span { color: var(--blue); }
.brand p { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.clock {
  font-variant-numeric: tabular-nums;
  font-size: 1.2rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 10px;
}

/* Layout */
.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* Controls */
.controls-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}
.field label {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field select {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
}
.timeframe {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--blue);
}

/* Generate button */
.btn-generate {
  width: 100%;
  padding: 16px 20px;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  color: #fff;
  transition: transform .1s ease, opacity .2s ease, box-shadow .2s ease;
  box-shadow: 0 8px 20px rgba(59, 130, 246, .25);
}
.btn-generate:hover:not(:disabled) { box-shadow: 0 10px 26px rgba(59, 130, 246, .4); }
.btn-generate:active:not(:disabled) { transform: scale(.98); }
.btn-generate:disabled { opacity: .55; cursor: not-allowed; }
.hint { color: var(--muted); font-size: .78rem; margin-top: 10px; text-align: center; }

/* Timing engine (Etap 4) */
.timing-engine {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 10px; margin: 12px 0; font-size: .85rem; color: var(--muted);
}
.timing-state {
  font-weight: 700; letter-spacing: .03em; padding: 3px 10px; border-radius: 999px;
  background: rgba(148, 163, 184, .15);
}
.timing-state.ready {
  color: #16a34a; background: rgba(22, 163, 74, .15);
}
.timing-countdown { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Result card */
.result-card { min-height: 220px; display: flex; flex-direction: column; }

.placeholder, .analyzing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: .95rem;
  text-align: center;
}

/* Etap 7 (fix) — wonn loading animasyon. Vèsyon anvan an (conic-gradient +
   mask/-webkit-mask) render envizib sou kèk browser/WebView ki pa sipòte
   konbinezon mask+gradient sa a byen (silent failure — okenn erè, jis
   yon wonn transparan). Ranplase ak yon border-spinner klasik: border-radius
   + border-top-color diferan + rotation — sipòte pa TOUT browser, zewo
   depandans sou mask/conic-gradient. Zewo chanjman JS/state logic. */
.spinner {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 6px solid rgba(59, 130, 246, .18);
  border-top-color: var(--blue);
  animation: spin 1.1s linear infinite;
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, .45));
}
@keyframes spin { to { transform: rotate(360deg); } }

.analyzing p {
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }

.scan-line {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.scan-line::after {
  content: "";
  position: absolute;
  top: 0; left: -40%;
  width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  animation: scan 1.2s ease-in-out infinite;
}
@keyframes scan { to { left: 100%; } }

#state-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.result-direction {
  font-size: 3.4rem;
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1;
}
.result-direction.buy  { color: var(--green); }
.result-direction.sell { color: var(--red); }

.result-pair { font-size: 1.5rem; font-weight: 700; margin-top: 6px; }
.result-confidence { font-size: 1rem; color: var(--muted); margin-top: 4px; }

.strength {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 12px;
}
.strength-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--yellow), var(--green));
  border-radius: 6px;
  transition: width .4s ease;
}

.result-pattern {
  margin-top: 8px;
  color: var(--yellow);
  font-size: .9rem;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  justify-content: center;
  margin-top: 16px;
}
.result-meta span { font-size: .85rem; color: var(--muted); }
.result-meta strong { color: var(--text); }

.result-reasons {
  width: 100%;
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  list-style: none;
  text-align: left;
}
.result-reasons li {
  font-size: .85rem;
  color: var(--text);
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.result-reasons li:last-child { border-bottom: none; }
.result-reasons li::before { content: "✓ "; color: var(--green); }

.result-strength { font-size: .85rem; color: var(--muted); margin-top: 6px; }
.result-setup { font-size: .8rem; color: var(--muted); font-style: italic; }

.result-warnings {
  width: 100%;
  margin-top: 10px;
  padding: 12px 16px;
  background: rgba(234, 179, 8, .08);
  border: 1px solid rgba(234, 179, 8, .35);
  border-radius: 10px;
  list-style: none;
  text-align: left;
}
.result-warnings li {
  font-size: .8rem;
  color: var(--text);
  padding: 4px 0;
}

/* Banners */
.banner {
  border-radius: 12px;
  padding: 14px 16px;
  font-size: .9rem;
  line-height: 1.45;
}
.banner--error { background: var(--red-bg); border: 1px solid var(--red); color: #fecaca; }
.banner--warn  { background: rgba(234, 179, 8, .1); border: 1px solid var(--yellow); color: #fde68a; }

/* Focus accessibility */
button:focus-visible, select:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Responsive */
@media (max-width: 600px) {
  .app-header { flex-direction: column; align-items: flex-start; }
  .clock { align-self: stretch; text-align: center; }
  .controls-grid { grid-template-columns: 1fr; }
  .result-direction { font-size: 2.6rem; }
}

