/* ==========================================
   BTC PREDICTOR - DARK THEME
   ========================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a1f2e;
  --bg-card-hover: #222840;
  --border: #2a3042;
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.1);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --yellow: #f59e0b;
  --yellow-bg: rgba(245, 158, 11, 0.1);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.1);
  --purple: #8b5cf6;
  --orange: #f97316;
  --btc-gold: #f7931a;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* ==========================================
   HEADER
   ========================================== */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 700;
  color: var(--btc-gold);
}

.version {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 4px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.update-time {
  font-size: 13px;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--btc-gold);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-refresh {
  font-family: 'JetBrains Mono', monospace;
}

/* ==========================================
   SIGNAL CARD
   ========================================== */

.signal-section {
  margin-bottom: 24px;
}

.signal-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 2px solid var(--border);
  padding: 32px;
  box-shadow: var(--shadow);
  transition: border-color 0.3s;
}

.signal-card.buy-strong { border-color: var(--green); background: linear-gradient(135deg, var(--bg-secondary), rgba(16, 185, 129, 0.05)); }
.signal-card.buy { border-color: #34d399; }
.signal-card.neutral { border-color: var(--yellow); }
.signal-card.sell { border-color: #f87171; }
.signal-card.sell-strong { border-color: var(--red); background: linear-gradient(135deg, var(--bg-secondary), rgba(239, 68, 68, 0.05)); }

.signal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.signal-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.signal-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  padding: 8px 20px;
  border-radius: 8px;
  letter-spacing: 1px;
}

.signal-badge.buy-strong { background: var(--green-bg); color: var(--green); }
.signal-badge.buy { background: rgba(52, 211, 153, 0.1); color: #34d399; }
.signal-badge.neutral { background: var(--yellow-bg); color: var(--yellow); }
.signal-badge.sell { background: rgba(248, 113, 113, 0.1); color: #f87171; }
.signal-badge.sell-strong { background: var(--red-bg); color: var(--red); }

.signal-body {
  display: flex;
  align-items: center;
  gap: 40px;
  margin-bottom: 24px;
}

.score-gauge {
  flex: 1;
}

.gauge-bar {
  position: relative;
  height: 12px;
  background: linear-gradient(90deg, #ef4444, #f87171, #f59e0b, #34d399, #10b981);
  border-radius: 6px;
  margin-bottom: 8px;
}

.gauge-fill {
  display: none;
}

.gauge-pointer {
  position: absolute;
  top: -6px;
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: left 0.5s ease;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.score-number {
  text-align: center;
  min-width: 120px;
}

.score-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
}

.score-max {
  font-size: 18px;
  color: var(--text-muted);
}

.signal-price {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.price-label {
  font-size: 14px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 4px;
}

.price-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 32px;
  font-weight: 700;
  color: var(--btc-gold);
}

.price-change {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
}

.price-change.positive { color: var(--green); background: var(--green-bg); }
.price-change.negative { color: var(--red); background: var(--red-bg); }

/* ==========================================
   CHARTS SECTION
   ========================================== */

.charts-section {
  margin-bottom: 32px;
}

.charts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.period-selector {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border-radius: 8px;
  padding: 4px;
  border: 1px solid var(--border);
}

.period-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.2s;
}

.period-btn:hover {
  color: var(--text-primary);
}

.period-btn.active {
  background: var(--btc-gold);
  color: #000;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

@media (max-width: 768px) {
  .charts-grid { grid-template-columns: 1fr; }
  .charts-header { flex-direction: column; gap: 12px; align-items: flex-start; }
}

/* SETUP DETECTION */
.setup-section { margin-bottom: 24px; }

.setup-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 2px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow);
}

.setup-card.bull { border-color: var(--green); background: linear-gradient(135deg, var(--bg-secondary), rgba(16, 185, 129, 0.05)); }
.setup-card.bear { border-color: var(--red); background: linear-gradient(135deg, var(--bg-secondary), rgba(239, 68, 68, 0.05)); }
.setup-card.bottom { border-color: var(--blue); background: linear-gradient(135deg, var(--bg-secondary), rgba(59, 130, 246, 0.05)); }
.setup-card.top { border-color: var(--orange); background: linear-gradient(135deg, var(--bg-secondary), rgba(249, 115, 22, 0.05)); }

.setup-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.setup-label {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  letter-spacing: 1px; text-transform: uppercase;
}

.setup-name {
  font-family: 'JetBrains Mono', monospace; font-size: 16px; font-weight: 700;
  padding: 6px 16px; border-radius: 8px; letter-spacing: 0.5px;
}

.setup-card.bull .setup-name { background: var(--green-bg); color: var(--green); }
.setup-card.bear .setup-name { background: var(--red-bg); color: var(--red); }
.setup-card.bottom .setup-name { background: var(--blue-bg); color: var(--blue); }
.setup-card.top .setup-name { background: rgba(249, 115, 22, 0.1); color: var(--orange); }

.setup-confidence { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.setup-conf-label { font-size: 13px; color: var(--text-secondary); min-width: 80px; }
.setup-conf-bar { flex: 1; height: 8px; background: var(--bg-primary); border-radius: 4px; overflow: hidden; }
.setup-conf-fill { height: 100%; border-radius: 4px; transition: width 0.5s; background: var(--btc-gold); }
.setup-conf-value { font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; color: var(--btc-gold); min-width: 40px; }

.setup-description { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ==========================================
   METRICS GRID
   ========================================== */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.metric-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.metric-card:hover {
  border-color: var(--btc-gold);
  transform: translateY(-2px);
}

.metric-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.metric-icon {
  font-size: 20px;
}

.metric-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.metric-bar {
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ==========================================
   SECTION TITLES
   ========================================== */

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ==========================================
   INDICATORS GRID
   ========================================== */

.indicators-section {
  margin-bottom: 32px;
}

.indicators-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.indicator-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
}

.indicator-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.indicator-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.indicator-score.positive { color: var(--green); }
.indicator-score.negative { color: var(--red); }
.indicator-score.neutral-color { color: var(--yellow); }

.indicator-interpretation {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.indicator-details {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ==========================================
   MACRO SECTION
   ========================================== */

.derivatives-section, .calendar-section {
  margin-bottom: 32px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.calendar-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-card.bullish { border-left: 3px solid var(--green); }
.calendar-card.bearish { border-left: 3px solid var(--red); }
.calendar-card.volatile { border-left: 3px solid var(--yellow); }

.calendar-event-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.calendar-event-detail {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.calendar-score-badge {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  width: fit-content;
}

.macro-section, .technical-section {
  margin-bottom: 32px;
}

.macro-grid, .tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.macro-card, .tech-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.macro-label, .tech-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.macro-value, .tech-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.tech-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================
   HISTORY TABLE
   ========================================== */

.history-section {
  margin-bottom: 32px;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.signals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.signals-table th {
  background: var(--bg-secondary);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.signals-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

.signals-table tr:hover {
  background: var(--bg-card-hover);
}

.signals-table tr:last-child td {
  border-bottom: none;
}

.signal-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.signal-tag.COMPRA_FORTE { background: var(--green-bg); color: var(--green); }
.signal-tag.COMPRA { background: rgba(52, 211, 153, 0.1); color: #34d399; }
.signal-tag.NEUTRO { background: var(--yellow-bg); color: var(--yellow); }
.signal-tag.VENDA { background: rgba(248, 113, 113, 0.1); color: #f87171; }
.signal-tag.VENDA_FORTE { background: var(--red-bg); color: var(--red); }

/* ==========================================
   API STATUS
   ========================================== */

.api-section {
  margin-bottom: 32px;
}

.api-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.api-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border-radius: 8px;
  padding: 12px 16px;
  border: 1px solid var(--border);
}

.api-name {
  font-size: 14px;
  font-weight: 500;
}

.api-status-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
}

.api-status-badge.active {
  background: var(--green-bg);
  color: var(--green);
}

.api-status-badge.inactive {
  background: var(--red-bg);
  color: var(--red);
}

/* ==========================================
   CONFIG PANEL
   ========================================== */

.config-section {
  margin-bottom: 32px;
}

.config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.config-toggle-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.config-panel {
  margin-top: 16px;
}

.config-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.config-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.config-card.disabled {
  opacity: 0.4;
}

.config-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.config-card-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--green);
  border-color: var(--green);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: white;
}

.config-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.config-weight-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.config-weight-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  min-width: 40px;
}

.config-weight-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-primary);
  outline: none;
}

.config-weight-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--btc-gold);
  cursor: pointer;
  border: 2px solid var(--bg-card);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.config-weight-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--btc-gold);
  cursor: pointer;
  border: 2px solid var(--bg-card);
}

.config-weight-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--btc-gold);
  min-width: 36px;
  text-align: right;
}

.config-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.config-total {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-secondary);
}

.config-total span {
  font-weight: 700;
  font-size: 18px;
}

.config-actions {
  display: flex;
  gap: 8px;
}

.config-btn-save {
  background: var(--green) !important;
  color: #000 !important;
  border-color: var(--green) !important;
  font-weight: 600;
}

.config-btn-save:hover {
  background: #059669 !important;
}

.config-btn-reset {
  color: var(--text-muted) !important;
}

@media (max-width: 768px) {
  .config-grid { grid-template-columns: 1fr; }
  .config-footer { flex-direction: column; gap: 12px; }
}

/* ==========================================
   FOOTER
   ========================================== */

.footer {
  text-align: center;
  padding: 24px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.disclaimer {
  margin-top: 8px;
  padding: 12px;
  background: var(--yellow-bg);
  color: var(--yellow);
  border-radius: 8px;
  font-weight: 500;
}

/* ==========================================
   LOADING & ANIMATIONS
   ========================================== */

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-style: italic;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.refreshing {
  animation: pulse 1s infinite;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 768px) {
  .app { padding: 12px; }
  .header { flex-direction: column; gap: 12px; text-align: center; }
  .signal-body { flex-direction: column; gap: 20px; }
  .signal-price { flex-direction: column; gap: 12px; text-align: center; }
  .price-value { font-size: 24px; }
  .score-value { font-size: 36px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .gauge-labels { font-size: 8px; }
  .indicators-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .macro-grid, .tech-grid { grid-template-columns: repeat(2, 1fr); }
}
