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

:root {
  --bg: #0d0d0f;
  --bg2: #141418;
  --bg3: #1a1a20;
  --bg4: #20202a;
  --border: #2a2a35;
  --accent: #2962ff;
  --green: #26a69a;
  --red: #ef5350;
  --orange: #ff9800;
  --text: #d1d4dc;
  --text-dim: #6b7280;
  --text-bright: #ffffff;
  --left-w: 220px;
  --right-w: 260px;
  --topbar-h: 56px;
  --volume-h: 90px;
}

html, body { height: 100%; background: var(--bg); color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; font-size: 13px;
  overflow: hidden; }

/* ── Layout ───────────────────────────────────────────────────────────── */
body { display: flex; height: 100vh; }

#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── Left Sidebar ─────────────────────────────────────────────────────── */
#sidebar-left {
  width: var(--left-w); min-width: var(--left-w);
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
#sidebar-header {
  padding: 14px 12px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 14px;
}
.logo { color: var(--accent); letter-spacing: -0.3px; }
#search-wrap { padding: 8px; }
#symbol-search {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; color: var(--text); font-size: 12px;
  outline: none; transition: border-color 0.15s;
}
#symbol-search:focus { border-color: var(--accent); }
#symbol-list { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

.sym-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; cursor: pointer; border-left: 2px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.sym-item:hover { background: var(--bg3); }
.sym-item.active { background: rgba(41,98,255,0.12); border-left-color: var(--accent); }
.sym-name { font-weight: 600; font-size: 12px; color: var(--text-bright); }
.sym-price { font-size: 11px; color: var(--text-dim); text-align: right; }
.sym-change { font-size: 11px; font-weight: 600; text-align: right; }
.up { color: var(--green); } .dn { color: var(--red); } .neutral { color: var(--text-dim); }

/* ── Right Sidebar: Trade History ─────────────────────────────────────── */
#sidebar-right {
  width: var(--right-w); min-width: var(--right-w);
  background: var(--bg2); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}

#trade-sidebar-header {
  padding: 14px 12px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 13px; display: flex; align-items: center;
  gap: 8px; flex-shrink: 0;
}
.badge {
  background: var(--bg3); color: var(--text-dim); font-size: 11px;
  padding: 2px 7px; border-radius: 10px; font-weight: 600;
}

/* ── Signal Detail Panel ──────────────────────────────────────────────── */
#signal-detail {
  border-bottom: 1px solid var(--border); padding: 10px 12px;
  flex-shrink: 0; background: var(--bg3);
}
#signal-detail.hidden { display: none; }

#signal-detail-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
#sd-symbol { font-size: 14px; font-weight: 700; color: var(--text-bright); }
.dir-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
}
.dir-long { background: rgba(38,166,154,0.2); color: var(--green); }
.dir-short { background: rgba(239,83,80,0.2); color: var(--red); }

.sd-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 0; font-size: 12px;
}
.sd-row label { color: var(--text-dim); font-size: 11px; }
.sd-row span { font-weight: 600; font-variant-numeric: tabular-nums; }
.tp-row span { color: var(--green); }
.sl-row span { color: var(--red); }

.btn-analyze {
  width: 100%; margin-top: 10px; padding: 8px;
  background: linear-gradient(135deg, #2962ff, #1e4fcc);
  color: #fff; border: none; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 600; transition: opacity 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-analyze:hover { opacity: 0.85; }
.btn-analyze.loading { opacity: 0.6; cursor: wait; }
.btn-analyze.loading #analyze-icon { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Analysis Panel ──────────────────────────────────────────────────── */
#analysis-panel {
  border-bottom: 1px solid var(--border);
  background: var(--bg4);
  display: flex; flex-direction: column;
  max-height: 60vh; overflow: hidden;
  flex-shrink: 0;
}
#analysis-panel.hidden { display: none; }

#ap-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 6px; flex-shrink: 0;
}
#ap-bias-icon { font-size: 16px; }
#ap-bias-text { font-weight: 700; font-size: 13px; flex: 1; }
.btn-small {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  padding: 3px 7px; border-radius: 4px; cursor: pointer; font-size: 11px;
  transition: all 0.15s;
}
.btn-small:hover { background: var(--bg3); color: var(--text); }

#ap-summary {
  font-size: 11px; color: var(--text-dim); line-height: 1.5;
  padding: 0 12px 10px; overflow-y: auto; flex: 1;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}

#ap-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--text-dim); }
.dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.ob-bull { background: rgba(38,166,154,0.5); border: 1px solid var(--green); }
.ob-bear { background: rgba(239,83,80,0.5); border: 1px solid var(--red); }
.fvg-bull { background: rgba(41,98,255,0.4); border: 1px solid var(--accent); }
.fvg-bear { background: rgba(255,152,0,0.4); border: 1px solid var(--orange); }
.sr-sup { background: rgba(38,166,154,0.3); border: 1px solid rgba(38,166,154,0.8); }
.sr-res { background: rgba(239,83,80,0.3); border: 1px solid rgba(239,83,80,0.8); }

/* ── Signal List ─────────────────────────────────────────────────────── */
#signal-list { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

.empty-msg { text-align: center; color: var(--text-dim); padding: 24px 12px; font-size: 12px; line-height: 1.6; }

.sig-item {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s; border-left: 2px solid transparent;
}
.sig-item:hover { background: var(--bg3); }
.sig-item.active { background: rgba(41,98,255,0.08); border-left-color: var(--accent); }

.sig-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.sig-sym { font-weight: 700; font-size: 13px; color: var(--text-bright); }
.sig-badge {
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 3px;
}
.sig-long { background: rgba(38,166,154,0.2); color: var(--green); }
.sig-short { background: rgba(239,83,80,0.2); color: var(--red); }

.sig-entry { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.sig-levels { display: flex; gap: 6px; margin-top: 3px; }
.sig-tp { font-size: 10px; color: var(--green); }
.sig-sl { font-size: 10px; color: var(--red); }
.sig-time { font-size: 10px; color: var(--text-dim); margin-top: 3px; }

/* ── Topbar ───────────────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h); background: var(--bg2);
  border-bottom: 1px solid var(--border); display: flex;
  align-items: center; padding: 0 16px; gap: 24px; flex-shrink: 0;
}
#symbol-info { display: flex; align-items: baseline; gap: 10px; }
#tb-symbol { font-size: 16px; font-weight: 700; color: var(--text-bright); }
#tb-price { font-size: 20px; font-weight: 700; color: var(--text-bright);
  font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
#tb-change { font-size: 13px; font-weight: 600; }
#tb-stats { display: flex; gap: 20px; margin-left: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.stat span { font-size: 12px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
#tf-buttons { margin-left: auto; display: flex; gap: 4px; }

#indicator-buttons { display: flex; gap: 4px; margin-left: 8px; border-left: 1px solid var(--border); padding-left: 8px; }
.ind-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  padding: 4px 10px; border-radius: 5px; cursor: pointer; font-size: 11px;
  font-weight: 700; letter-spacing: 0.3px; transition: all 0.15s;
}
.ind-btn:hover { background: var(--bg3); color: var(--text); }
.ind-btn.active { background: rgba(41,98,255,0.2); border-color: var(--accent); color: var(--accent); }
.tf-btn {
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  padding: 4px 9px; border-radius: 5px; cursor: pointer; font-size: 12px;
  font-weight: 600; transition: all 0.15s;
}
.tf-btn:hover { background: var(--bg3); color: var(--text); }
.tf-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Chart ─────────────────────────────────────────────────────────────── */
#chart-container { flex: 1; position: relative; min-height: 0; }
#chart { position: absolute; inset: 0; }
#overlay-canvas { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#volume-container { height: var(--volume-h); flex-shrink: 0; position: relative;
  border-top: 1px solid var(--border); }
#volume-chart { position: absolute; inset: 0; }

/* ── Scrollbars ───────────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 4px; } ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Raw message (non-signal) ─────────────────────────────────────────── */
.sig-raw { opacity: 0.55; cursor: default; }
.sig-raw:hover { opacity: 0.75; background: transparent; }
.sig-raw-text {
  font-size: 11px; color: var(--text-dim); line-height: 1.4;
  white-space: pre-wrap; word-break: break-word;
  max-height: 48px; overflow: hidden;
}

/* ── Load More Button ────────────────────────────────────────────────── */
.btn-load-more {
  width: 100%; padding: 10px;
  background: var(--bg3); border: none; border-top: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer; font-size: 12px; font-weight: 600;
  transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.btn-load-more:hover { background: var(--bg4); color: var(--text); }

.hidden { display: none !important; }
