/* BTC Market Bias Dashboard - Professional Design */

/* NO global resets - everything scoped to .btc-bias-app */

:root {
  --bg-dark: #0a0e27;
  --bg-card: #1f2937;
  --bg-card-hover: #1a1e27;
  --border: #374151;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.15);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.15);
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.15);
  --blue: #3b82f6;
}

.btc-bias-app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1rem;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.btc-bias-app *,
.btc-bias-app *::before,
.btc-bias-app *::after {
  box-sizing: border-box;
}

/* Top Bar */
.btc-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.btc-title h1 {
  font-size: 1.75rem;
  margin: 0 0 0.5rem 0;
  font-weight: 700;
}

.btc-sub {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.btc-pill {
  background: var(--amber-bg);
  color: var(--amber);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 0.5rem;
}

.btc-pill.live {
  background: var(--green-bg);
  color: var(--green);
}

.btc-pill.demo {
  background: var(--amber-bg);
  color: var(--amber);
}

.btc-actions {
  display: flex;
  gap: 0.75rem;
}

.btc-btn {
  background: var(--blue);
  color: white;
  border: none;
  padding: 0.625rem 1.25rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.875rem;
}

.btc-btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.btc-btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btc-btn-ghost:hover {
  background: var(--bg-card-hover);
  border-color: var(--blue);
}

/* Card */
.btc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

/* Hero Section */
.btc-hero {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 3rem;
  align-items: start;
}

.btc-kicker {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.btc-headline {
  margin-bottom: 1rem;
}

.btc-badge {
  display: inline-block;
  font-size: 1.5rem;
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.btc-badge.bullish {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green);
}

.btc-badge.bearish {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red);
}

.btc-badge.neutral {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber);
}

.btc-summary {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* Score Row */
.btc-score-row {
  display: flex;
  gap: 2rem;
  align-items: center;
  margin-bottom: 2rem;
}

.btc-score {
  min-width: 200px;
}

.btc-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.btc-value {
  font-size: 2.5rem;
  font-weight: 700;
}

.btc-value .btc-muted {
  color: var(--text-muted);
  font-size: 1.5rem;
}

/* Meter */
.btc-meter {
  flex: 1;
}

.btc-meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.btc-meter-track {
  position: relative;
  height: 8px;
  background: linear-gradient(to right,
    #ef4444 0%,
    #f59e0b 50%,
    #10b981 100%
  );
  border-radius: 4px;
}

.btc-meter-marker {
  position: absolute;
  width: 3px;
  height: 16px;
  background: white;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
  transition: left 0.5s ease;
}

.btc-source {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

/* Mini Cards Grid */
.btc-mini-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.btc-mini {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  min-height: 150px;
  display: flex;
  flex-direction: column;
}

.btc-mini-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.btc-mini-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.btc-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btc-tag.red {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red);
}

.btc-tag.amber {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber);
}

.btc-tag.green {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green);
}

.btc-spark {
  width: 100%;
  height: 60px;
  margin: 0.5rem 0;
  flex-grow: 1;
}

.btc-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: auto;
}

/* Card Header */
.btc-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.btc-title2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btc-sub2 {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.btc-asof {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Table */
.btc-table {
  margin-bottom: 2rem;
}

.btc-row {
  display: grid;
  grid-template-columns: 2fr 1.5fr 3fr;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.btc-row.btc-header {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btc-row:last-child {
  border-bottom: none;
}

.btc-strategy-name {
  font-weight: 600;
  color: var(--text-primary);
}

.btc-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.btc-dot.allowed {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.btc-dot.reduced {
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber);
}

.btc-dot.standby {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

.btc-status-text {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.btc-status-text.allowed {
  color: var(--green);
}

.btc-status-text.reduced {
  color: var(--amber);
}

.btc-status-text.standby {
  color: var(--red);
}

.btc-guidance {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Divider */
.btc-divider {
  height: 1px;
  background: var(--border);
  margin: 2rem 0;
}

/* Risk Box */
.btc-riskbox {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 2rem;
}

.btc-title-sm {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.btc-risk-mode {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.btc-chips {
  display: grid;
  /* 4-up on desktop keeps the risk posture chips clean and aligned */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.btc-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: rgba(11, 18, 32, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  min-height: 72px;
  overflow: hidden;
}

.btc-k {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0;
  line-height: 1.2;
}

.btc-v {
  display: block;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
  word-break: normal;
}

/* Risk posture chips: prevent awkward wrapping */
.btc-chip .btc-v {
  white-space: nowrap;
  text-align: right;
  margin-left: auto;
}

@media (max-width: 520px) {
  .btc-chip .btc-v {
    white-space: normal;
  }
}

/* Evidence block */
.btc-evidence {
  margin-top: 1.25rem;
}

.btc-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.btc-title2 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.btc-sub2 {
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.btc-evidence-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

.btc-ev {
  background: rgba(11, 18, 32, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  min-height: 92px;
}

.btc-ev-k {
  color: var(--text-muted);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.btc-ev-v {
  margin-top: 0.35rem;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.btc-ev-n {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.25;
}

.btc-ev.good .btc-ev-v { color: var(--green); }
.btc-ev.bad .btc-ev-v { color: var(--red); }
.btc-ev.neutral .btc-ev-v { color: var(--amber); }

.btc-evidence-help {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.btc-help-title {
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.btc-help-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-muted);
}

.btc-help-list li {
  margin: 0.35rem 0;
}

.btc-help-foot {
  margin-top: 0.6rem;
  color: var(--text-primary);
  font-size: 0.92rem;
}

@media (max-width: 1100px) {
  .btc-evidence-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .btc-evidence-grid {
    grid-template-columns: 1fr;
  }
}

/* Context Grid */
.btc-context-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.btc-context-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.btc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.btc-list li {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 0.75rem;
  padding-left: 1.25rem;
  position: relative;
}

.btc-list li:before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--blue);
  font-weight: bold;
}

/* Details */
.btc-details {
  margin-top: 1.5rem;
}

.btc-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.875rem;
  user-select: none;
}

.btc-details summary:hover {
  color: var(--text-primary);
}

/* Footer */
.btc-foot {
  text-align: center;
  padding: 2rem 0;
  font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 1200px) {
  .btc-hero {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .btc-mini-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Keep chips readable on smaller desktops */
  .btc-chips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .btc-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .btc-mini-cards {
    grid-template-columns: 1fr;
  }
  
  .btc-score-row {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .btc-riskbox {
    grid-template-columns: 1fr;
  }
  
  .btc-context-grid {
    grid-template-columns: 1fr;
  }
  
  .btc-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .btc-chips {
    grid-template-columns: 1fr;
  }
}

/* Tooltip styling */
[title] {
  cursor: help;
  position: relative;
}

/* Better tooltip appearance */
.btc-mini-label[title],
.btc-title2[title],
.btc-title-sm[title],
.btc-kicker[title],
.btc-label[title] {
  cursor: help;
  border-bottom: 1px dotted var(--text-muted);
}

/* Last Updated Timestamp */
.btc-last-updated {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Auto-refresh Toggle */
.btc-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.btc-toggle input[type="checkbox"] {
  width: 40px;
  height: 20px;
  appearance: none;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
}

.btc-toggle input[type="checkbox"]:checked {
  background: var(--green);
}

.btc-toggle input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
}

.btc-toggle input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}

.btc-toggle-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* API Status Indicator */
#apiStatus {
  background: transparent;
  color: var(--green);
  font-size: 0.6rem;
  padding: 0.2rem 0.5rem;
  animation: pulse 2s infinite;
}

#apiStatus.error {
  color: var(--red);
  animation: none;
}

#apiStatus.warning {
  color: var(--amber);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Component Weight Visualization */
.btc-weights {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(31, 41, 55, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.btc-weight-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  cursor: help;
  border-bottom: 1px dotted var(--text-muted);
  display: inline-block;
}

.btc-weight-bars {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btc-weight-item {
  display: grid;
  grid-template-columns: 120px 1fr 40px;
  align-items: center;
  gap: 0.75rem;
}

.btc-weight-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.btc-weight-bar-container {
  height: 16px;
  background: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.btc-weight-bar {
  height: 100%;
  transition: all 0.5s ease;
  border-radius: 8px;
  position: relative;
}

.btc-weight-bar[data-score="1"] {
  width: 33.33%;
  background: var(--green);
  float: right;
}

.btc-weight-bar[data-score="-1"] {
  width: 33.33%;
  background: var(--red);
  float: left;
}

.btc-weight-bar[data-score="0"] {
  width: 0%;
  background: var(--amber);
}

.btc-weight-value {
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
}

/* Button States */
.btc-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btc-btn.refreshing {
  background: var(--amber);
}
