/* ══════════════════════════════════════════════════
   Qbea Dashboard Stylesheet
   Dashboard components for /intel/ and /peak/.
   Extends common.css — loaded after it.
   ══════════════════════════════════════════════════ */

/* ── Dashboard tokens ── */
:root {
  --dash-max-width: 1200px;
  --card-radius: 8px;
  --status-green: #1a7f37;
  --status-green-bg: rgba(34, 134, 58, 0.1);
  --status-red: #cb2431;
  --status-red-bg: rgba(203, 36, 49, 0.1);
  --status-yellow: #b08800;
  --status-yellow-bg: rgba(176, 136, 0, 0.1);
  --status-blue: #0277FC;
  --status-blue-bg: rgba(2, 119, 252, 0.08);
}
[data-theme="dark"] {
  --status-green: #56d364;
  --status-green-bg: rgba(86, 211, 100, 0.12);
  --status-red: #f85149;
  --status-red-bg: rgba(248, 81, 73, 0.12);
  --status-yellow: #e3b341;
  --status-yellow-bg: rgba(227, 179, 65, 0.12);
  --status-blue: #58a6ff;
  --status-blue-bg: rgba(88, 166, 255, 0.12);
}

/* ══════ Layout ══════ */
.dashboard-wrapper {
  max-width: var(--dash-max-width);
  margin: 0 auto;
  padding: 24px 24px 0;
}

/* ── Update notice ── */
.update-notice {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  margin-bottom: 16px;
}

/* ── Cross-links ── */
.cross-links {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 20px;
}
.cross-links a { color: var(--accent); text-decoration: none; }
.cross-links a:hover { text-decoration: underline; }
.cross-links .sep { margin: 0 8px; }

/* ══════ Hero Bar ══════ */
.hero-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  margin-bottom: 20px;
}
.hero-price {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.02em;
}
.hero-change {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
}
.hero-change.positive { color: var(--status-green); background: var(--status-green-bg); }
.hero-change.negative { color: var(--status-red); background: var(--status-red-bg); }
.hero-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.hero-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.hero-badge.badge-flat { color: var(--text-muted); }
.hero-badge.badge-long { color: var(--status-green); background: var(--status-green-bg); border-color: transparent; }
.hero-badge.badge-hold { color: var(--text-muted); opacity: 0.7; font-size: 10px; }
.hero-badge.badge-buy { color: var(--status-green); background: var(--status-green-bg); border-color: transparent; }
.hero-badge.badge-sell { color: var(--status-red); background: var(--status-red-bg); border-color: transparent; }
.hero-badge.badge-bull { color: var(--status-green); background: var(--status-green-bg); border-color: transparent; }
.hero-badge.badge-bear { color: var(--status-red); background: var(--status-red-bg); border-color: transparent; }
.hero-badge.badge-dump { color: var(--status-red); background: var(--status-red-bg); border-color: transparent; }
.hero-badge.badge-range { color: var(--status-yellow); background: var(--status-yellow-bg); border-color: transparent; }
.hero-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ══════ Card Grids ══════ */
.card-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}
.card-grid-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Stat card ── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 16px 20px;
  text-align: center;
}
.stat-card-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1.2;
}
.stat-card-value.small { font-size: 22px; }
.stat-card-value.green { color: var(--status-green); }
.stat-card-value.red { color: var(--status-red); }
.stat-card-value.yellow { color: var(--status-yellow); }
.stat-card-value.blue { color: var(--status-blue); }
.stat-card-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
}
.stat-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ══════ Chart Section ══════ */
.chart-section { margin-bottom: 20px; }
.chart-container {
  width: 100%;
  height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  overflow: hidden;
  background: var(--surface);
}
.chart-range-selector {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 8px;
}
.chart-range-btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.chart-range-btn:hover { border-color: var(--accent); color: var(--accent); }
.chart-range-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ══════ Section Headers ══════ */
.dash-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--mono);
  margin: 8px 0 12px;
}

/* ══════ Tables ══════ */
.table-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.prediction-section { margin-bottom: 20px; }
.prediction-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.prediction-tab {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.prediction-tab.active {
  background: var(--surface);
  color: var(--text-strong);
  border-color: var(--text-muted);
}
.dash-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  font-size: 14px;
}
.dash-table th {
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.dash-table td {
  padding: 9px 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
}
.dash-table tr:last-child td { border-bottom: none; }

/* ══════ Direction Bar ══════ */
.direction-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0 4px;
}
.direction-bar-up { background: var(--status-green); }
.direction-bar-down { background: var(--status-red); }
.direction-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
}
.direction-labels .up { color: var(--status-green); }
.direction-labels .down { color: var(--status-red); }

/* ══════ Indicator Card (Peak) ══════ */
.indicator-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 14px 16px;
}
.indicator-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-strong);
  margin-bottom: 8px;
}
.indicator-card-value {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.indicator-card-distance {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.indicator-card-status {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 8px;
}
.indicator-card-status.status-ok { background: var(--status-green-bg); color: var(--status-green); }
.indicator-card-status.status-warning { background: var(--status-yellow-bg); color: var(--status-yellow); }
.indicator-card-status.status-neutral { background: var(--status-yellow-bg); color: var(--status-yellow); }
.indicator-card-status.status-sell { background: var(--status-red-bg); color: var(--status-red); }
.indicator-card-status.status-bear { background: var(--status-red-bg); color: var(--status-red); font-weight: 600; }
.indicator-card-rule {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* ══════ Gauge (Peak dual scores) ══════ */
.gauge-wrapper {
  text-align: center;
  padding: 24px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
}
.gauge-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 8px;
}
.gauge-ring::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--gauge-color, var(--accent)) calc(var(--gauge-pct, 0) * 3.6deg), var(--border) 0);
}
.gauge-ring::after {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--surface);
}
.gauge-ring-value {
  position: relative;
  z-index: 1;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-strong);
}
.gauge-label {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}
.gauge-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
}

/* ══════ Dashboard Separator ══════ */
.dashboard-separator {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: var(--dash-max-width);
  margin: 40px auto;
  padding: 0 24px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.dashboard-separator::before,
.dashboard-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ══════ Loading / Error ══════ */
.dash-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-style: italic;
}
.dash-error {
  text-align: center;
  padding: 60px 20px;
  color: var(--status-red);
}

/* ══════ Score interpretation (Peak) ══════ */
.score-interpretation {
  font-size: 15px;
  color: var(--text);
  text-align: center;
  margin: 8px 0 0;
  line-height: 1.6;
}

/* ══════ Collapsible sections ══════ */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 8px 0;
}
.collapsible-header .arrow {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.collapsible-header.open .arrow { transform: rotate(180deg); }
.collapsible-body {
  display: none;
  padding-top: 8px;
}
.collapsible-body.open { display: block; }

/* ══════ Responsive ══════ */
@media (max-width: 1000px) {
  .card-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .hero-bar { padding: 12px 16px; gap: 10px; }
  .hero-price { font-size: 24px; }
  .chart-container { height: 350px; }
  .card-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .dashboard-wrapper { padding: 16px 16px 0; }
  .hero-bar { flex-direction: column; gap: 8px; }
  .hero-price { font-size: 28px; }
  .hero-badges {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
  }
  .hero-badges .hero-change,
  .hero-badges .hero-badge {
    text-align: center;
    justify-self: stretch;
  }
  .chart-container { height: 280px; }
  .card-grid-4,
  .card-grid-3 { grid-template-columns: 1fr 1fr; }
  .card-grid-2 { grid-template-columns: 1fr; }
  .stat-card-value { font-size: 24px; }
  .stat-card-value.small { font-size: 18px; }
  .chart-range-selector { flex-wrap: wrap; }
  .gauge-ring { width: 100px; height: 100px; }
  .gauge-ring-value { font-size: 18px; }
}
@media (max-width: 400px) {
  .card-grid-4 { grid-template-columns: 1fr; }
}
