@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

[hidden] { display: none !important; }

/* ─── Tokens ─────────────────────────────────────────────────────── */
:root,
:root[data-theme="dark"] {
  --bg:           #030508;
  --glass:        rgba(255, 255, 255, 0.038);
  --glass-hover:  rgba(255, 255, 255, 0.058);
  --border:       rgba(255, 255, 255, 0.072);
  --border-bright:rgba(255, 255, 255, 0.14);
  --text:         #f0f4ff;
  --text-muted:   rgba(255, 255, 255, 0.38);
  --text-subtle:  rgba(255, 255, 255, 0.18);
  --accent:       #06d6f5;
  --accent-rgb:   6, 214, 245;
  --accent-glow:  rgba(6, 214, 245, 0.22);
  --violet:       #8b5cf6;
  --violet-rgb:   139, 92, 246;
  --positive:     #10f07a;
  --positive-bg:  rgba(16, 240, 122, 0.10);
  --positive-border: rgba(16, 240, 122, 0.25);
  --negative:     #ff3e6c;
  --negative-bg:  rgba(255, 62, 108, 0.10);
  --negative-border: rgba(255, 62, 108, 0.25);
  --error-bg:     rgba(255, 62, 108, 0.08);
  --error-text:   #ff7096;
  --r: 16px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg:           #f0f0f5;
  --glass:        rgba(255, 255, 255, 0.72);
  --glass-hover:  rgba(255, 255, 255, 0.88);
  --border:       rgba(0, 0, 0, 0.08);
  --border-bright:rgba(0, 0, 0, 0.15);
  --text:         #0a0c18;
  --text-muted:   rgba(10, 12, 24, 0.45);
  --text-subtle:  rgba(10, 12, 24, 0.22);
  --accent:       #0095b3;
  --accent-rgb:   0, 149, 179;
  --accent-glow:  rgba(0, 149, 179, 0.18);
  --violet:       #6d3fc4;
  --violet-rgb:   109, 63, 196;
  --positive:     #009950;
  --positive-bg:  rgba(0, 153, 80, 0.08);
  --positive-border: rgba(0, 153, 80, 0.2);
  --negative:     #d4003a;
  --negative-bg:  rgba(212, 0, 58, 0.07);
  --negative-border: rgba(212, 0, 58, 0.2);
  --error-bg:     rgba(212, 0, 58, 0.06);
  --error-text:   #a0002c;
  color-scheme: light;
}

/* ─── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100vh; }

body {
  font-family: 'Sora', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ─── Fundo com orbs animados ────────────────────────────────────── */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  will-change: transform;
}

.orb-1 {
  width: 720px;
  height: 720px;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.28) 0%, transparent 70%);
  top: -280px;
  left: -180px;
  animation: orbDrift1 24s ease-in-out infinite;
}

.orb-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(var(--violet-rgb), 0.22) 0%, transparent 70%);
  bottom: -200px;
  right: -160px;
  animation: orbDrift2 30s ease-in-out infinite;
}

.orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.12) 0%, transparent 70%);
  top: 45%;
  left: 55%;
  animation: orbDrift3 20s ease-in-out infinite;
}

@keyframes orbDrift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(60px, 80px) scale(1.06); }
  66%       { transform: translate(-40px, 120px) scale(0.94); }
}
@keyframes orbDrift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40%       { transform: translate(-80px, -60px) scale(1.05); }
  70%       { transform: translate(50px, -100px) scale(0.95); }
}
@keyframes orbDrift3 {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%       { transform: translate(-44%, -56%) scale(1.12); }
}

[data-theme="light"] .orb-1 {
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.18) 0%, transparent 70%);
}
[data-theme="light"] .orb-2 {
  background: radial-gradient(circle, rgba(var(--violet-rgb), 0.14) 0%, transparent 70%);
}
[data-theme="light"] .orb-3 {
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.08) 0%, transparent 70%);
}

/* ─── Header ─────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  background: rgba(3, 5, 8, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  transition: background 0.3s ease;
}

[data-theme="light"] header {
  background: rgba(240, 240, 245, 0.75);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 32px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.8);
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.8); }
  50%       { box-shadow: 0 0 20px rgba(var(--accent-rgb), 1), 0 0 40px rgba(var(--accent-rgb), 0.4); }
}

.logo-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text);
}

.logo-suffix {
  font-weight: 300;
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--text-muted);
  margin-left: 4px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pair-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  padding: 5px 12px;
  border-radius: 999px;
}

#theme-toggle {
  font-family: inherit;
  font-size: 18px;
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

#theme-toggle:hover {
  border-color: var(--border-bright);
  color: var(--accent);
}

/* ─── Área de anúncio ────────────────────────────────────────────── */
.ad-bar {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 32px 0;
  display: flex;
  justify-content: center;
}

.ad-bar ins {
  display: block;
  width: 100%;
  max-width: 728px;
  min-height: 0 !important;
  height: auto !important;
  background: transparent !important;
}

/* ─── Layout principal ───────────────────────────────────────────── */
main {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 32px 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ─── Grid: painel de preço + gráfico ───────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ─── Mixin de card de vidro ─────────────────────────────────────── */
.price-panel,
.chart-panel,
#history-table {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--r);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  transition: background 0.3s ease, border-color 0.3s ease;
  overflow: hidden;
}

/* ─── Painel de preço ────────────────────────────────────────────── */
.price-panel {
  position: relative;
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 0;
  animation: slideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.05s;

  /* Borda luminosa no topo */
  border-top: 1px solid rgba(var(--accent-rgb), 0.5);
  box-shadow:
    0 0 0 1px rgba(var(--accent-rgb), 0.08),
    inset 0 1px 0 rgba(var(--accent-rgb), 0.12),
    0 24px 60px rgba(0,0,0,0.4);
}

.price-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.6) 40%, rgba(var(--violet-rgb), 0.4) 70%, transparent);
}

.price-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 20px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--positive);
  box-shadow: 0 0 8px rgba(16, 240, 122, 0.6);
  animation: livePulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes livePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.3); opacity: 0.7; }
}

.price-hero {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.price-currency {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.price-big {
  font-family: 'Sora', sans-serif;
  font-size: 50px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  max-width: 100%;
  text-shadow:
    0 0 60px rgba(var(--accent-rgb), 0.35),
    0 0 120px rgba(var(--accent-rgb), 0.12);
}

@media (max-width: 900px) {
  .price-big { font-size: 44px; letter-spacing: -1px; }
}

@media (max-width: 540px) {
  .price-big { font-size: 38px; }
}

.change-badge {
  display: inline-flex;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  margin-bottom: 28px;
  align-self: flex-start;
  letter-spacing: 0.5px;
  transition: color 0.3s, background 0.3s;
}

.change-badge.positive {
  color: var(--positive);
  background: var(--positive-bg);
  border: 1px solid var(--positive-border);
  box-shadow: 0 0 16px rgba(16, 240, 122, 0.15);
}

.change-badge.negative {
  color: var(--negative);
  background: var(--negative-bg);
  border: 1px solid var(--negative-border);
  box-shadow: 0 0 16px rgba(255, 62, 108, 0.15);
}

.price-divider {
  height: 1px;
  background: linear-gradient(90deg, var(--border-bright), transparent);
  margin-bottom: 24px;
}

.price-secondary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sec-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-subtle);
  text-transform: uppercase;
}

.sec-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

.price-watermark {
  position: absolute;
  bottom: -10px;
  right: -8px;
  font-family: 'Sora', sans-serif;
  font-size: 120px;
  font-weight: 800;
  color: rgba(var(--accent-rgb), 0.04);
  letter-spacing: -4px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  transition: color 0.3s;
}

/* ─── Painel do gráfico ──────────────────────────────────────────── */
.chart-panel {
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 0;
  animation: slideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.15s;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

.chart-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
}

.chart-heading {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ─── Botões de filtro ───────────────────────────────────────────── */
.filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 7px 14px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.filter-btn:hover {
  border-color: var(--border-bright);
  color: var(--text);
  background: var(--glass-hover);
}

.filter-btn.active {
  background: rgba(var(--accent-rgb), 0.14);
  border-color: rgba(var(--accent-rgb), 0.5);
  color: var(--accent);
  box-shadow:
    0 0 12px rgba(var(--accent-rgb), 0.2),
    inset 0 1px 0 rgba(var(--accent-rgb), 0.1);
}

/* ─── Painel de data personalizada ──────────────────────────────── */
#custom-date-panel {
  background: rgba(var(--accent-rgb), 0.04);
  border: 1px solid rgba(var(--accent-rgb), 0.15);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  animation: fadeDown 0.18s ease;
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.custom-date-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.custom-date-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.custom-date-fields .field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1 1 140px;
}

.custom-date-fields label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.custom-date-fields input[type="date"] {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 9px 14px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.custom-date-fields input[type="date"]:focus {
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

/* ─── Aviso de dia alternativo ───────────────────────────────────── */
#day-info {
  background: rgba(var(--accent-rgb), 0.07);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#day-info::before {
  content: '○';
  font-size: 9px;
  opacity: 0.7;
  flex-shrink: 0;
}

/* ─── Erro ───────────────────────────────────────────────────────── */
#range-error {
  background: var(--error-bg);
  border: 1px solid rgba(255, 62, 108, 0.2);
  border-radius: 8px;
  padding: 11px 16px;
  margin-bottom: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--error-text);
}

/* ─── Gráfico ────────────────────────────────────────────────────── */
.chart-container {
  flex: 1;
  position: relative;
  min-height: 280px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ─── Tabela ─────────────────────────────────────────────────────── */
#history-table {
  padding: 28px 32px;
  animation: slideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.25s;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}

.table-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.table-heading {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.table-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-subtle);
  background: var(--glass);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.5px;
}

.table-wrapper { overflow-x: auto; }

#history-table table {
  width: 100%;
  border-collapse: collapse;
}

#history-table th,
#history-table td {
  padding: 13px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

#history-table th {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding-bottom: 14px;
}

#history-table tbody tr {
  transition: background 0.12s ease;
}

#history-table tbody tr:hover {
  background: var(--glass-hover);
}

#history-table tbody tr:last-child td {
  border-bottom: none;
}

/* ─── Rodapé ─────────────────────────────────────────────────────── */
footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 32px 32px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--text-subtle);
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

footer a:hover { color: var(--accent); }

/* ─── Entrada de página ──────────────────────────────────────────── */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-bright);
  border-radius: 999px;
}

/* ─── Responsivo mobile ──────────────────────────────────────────── */
@media (max-width: 540px) {
  main { padding: 16px 32px 48px; }
  .price-panel, .chart-panel, #history-table { padding: 24px 20px; }
  .price-big { font-size: 48px; letter-spacing: -1.5px; }
  .price-watermark { font-size: 80px; }
  .chart-top { flex-direction: column; align-items: flex-start; }
}
