/* Dashboard do bot — Fase 6 (auditoria 2026-09-15).
   CSS partido do index.html monolítico (D27). */

:root {
  --bg: #F4F7FE;
  --card: #FFFFFF;
  --card2: #F8FAFC;
  --border: #E2E8F0;
  --text: #2B3674;
  --text2: #A3AED0;
  --green: #05CD99;
  --red: #EE5D50;
  --blue: #3965FF;
  --yellow: #FFCE20;
  --accent: #4318FF;
  --shadow: 0px 18px 40px rgba(112, 144, 176, 0.12);
  --shadow-hover: 0px 20px 45px rgba(112, 144, 176, 0.2);
}

[data-theme="dark"] {
  --bg: #0B1437;
  --card: #111C44;
  --card2: #1B254B;
  --border: #2B3674;
  --text: #FFFFFF;
  --text2: #A3AED0;
  --shadow: 0px 18px 40px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0px 20px 45px rgba(0, 0, 0, 0.6);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 24px 32px;
}
.num { font-variant-numeric: tabular-nums; }

/* ── Header ── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text2);
  background: var(--card);
  padding: 10px 22px;
  border-radius: 30px;
  box-shadow: var(--shadow);
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--red); }
.last-update { font-size: 13px; font-weight: 500; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 8px;
  background: var(--card);
  border-radius: 16px;
  padding: 8px;
  box-shadow: var(--shadow);
}
.tab-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: 0px 10px 20px rgba(67, 24, 255, 0.2);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.stat-card .label { font-size: 14px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 700; }
.stat-card .sub { font-size: 12px; font-weight: 500; color: var(--text2); margin-top: 6px; }
.stat-card.positive .value { color: var(--green); }
.stat-card.negative .value { color: var(--red); }

/* ── Barras de progresso ── */
.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ── Secções e grelhas de gráficos ── */
.chart-section, .positions-section {
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}
.chart-header h3 { font-size: 18px; font-weight: 700; }
.chart-wrapper { position: relative; height: 300px; width: 100%; }
.chart-wrapper-small { position: relative; height: 200px; width: 100%; }
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.charts-grid-3 {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* ── Tabelas ── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.table th {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  font-weight: 500;
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}
.table tbody tr:hover td { background: var(--bg); }
.table tr.clickable { cursor: pointer; }
.table .win { color: var(--green); font-weight: 700; }
.table .loss { color: var(--red); font-weight: 700; }
.table .muted { color: var(--text2); }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text2);
  font-weight: 500;
}

/* ── Badges ── */
.regime-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}
.regime-badge.GRID { background: rgba(67, 24, 255, 0.1); color: var(--accent); }
.regime-badge.BREAKOUT { background: rgba(5, 205, 153, 0.1); color: var(--green); }
.regime-badge.NO_TRADE { background: rgba(238, 93, 80, 0.1); color: var(--red); }
.regime-badge.default { background: var(--border); color: var(--text2); }
.block-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  margin: 2px 4px 2px 0;
}
.block-badge.active { background: rgba(238, 93, 80, 0.15); color: var(--red); }
.block-badge.inactive { background: rgba(5, 205, 153, 0.1); color: var(--green); }

/* ── Indicadores ── */
.indicators-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.indicator-card {
  background: var(--bg);
  border-radius: 16px;
  padding: 16px;
}
.indicator-card .ind-label { font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 4px; }
.indicator-card .ind-value { font-size: 18px; font-weight: 700; }
.indicator-card .ind-sub { font-size: 12px; margin-top: 4px; color: var(--text2); font-weight: 500; }
.indicator-card.warn .ind-value { color: var(--yellow); }
.indicator-card.good .ind-value { color: var(--green); }
.indicator-card.bad .ind-value { color: var(--red); }

/* ── Period bar / filtros ── */
.period-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--card);
  border-radius: 16px;
  padding: 8px;
  width: fit-content;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.period-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  transition: all 0.2s;
}
.period-btn:hover { color: var(--text); }
.period-btn.active { background: var(--bg); color: var(--accent); }
.custom-range {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  background: var(--card);
  border-radius: 16px;
  padding: 12px 16px;
  width: fit-content;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.custom-range.show { display: flex; }
.custom-range input[type="date"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
}
.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  box-shadow: 0px 10px 20px rgba(67, 24, 255, 0.2);
}
.btn:hover { opacity: 0.9; }
.btn-ghost {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
}

/* ── Chips de estratégia ── */
.strategy-chips {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.chip {
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
}
.chip.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ── Filtros de trades ── */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.filters select, .filters input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
}

/* ── Motor / status ── */
.motor-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  flex-wrap: wrap;
  gap: 8px;
}
.motor-row:last-child { border-bottom: none; }
.motor-row .k { color: var(--text2); }
.heartbeat-ok { color: var(--green); font-weight: 700; }
.heartbeat-bad { color: var(--red); font-weight: 700; }

/* ── Margem segmentada ── */
.margin-bar {
  display: flex;
  height: 18px;
  border-radius: 9px;
  overflow: hidden;
  background: var(--bg);
  margin-top: 8px;
}
.margin-seg { height: 100%; transition: width 0.3s ease; }

/* ── Tema ── */
.theme-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 30px;
  padding: 4px;
  gap: 4px;
}
.theme-btn {
  background: transparent;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--text2);
}
.theme-btn.active { background: var(--card); box-shadow: var(--shadow); }
[data-theme="dark"] .theme-btn.active { background: var(--accent); color: white; }

/* ── Paginação ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text2);
  font-weight: 500;
}

@media (max-width: 1024px) {
  .stats-grid, .charts-grid, .charts-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .indicators-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .stats-grid, .charts-grid, .charts-grid-3 { grid-template-columns: 1fr; }
  body { padding: 16px; }
  .header { flex-direction: column; align-items: flex-start; }
  .tabs { width: 100%; }
  .tab-btn { flex: 1; text-align: center; padding: 10px; }
}
