/* ============================================
   Local Stablecoins — Main Stylesheet
   Dark theme. Desktop-first (1440px+), readable at 768px.
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Dark theme palette */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a25;
  --bg-hover: #22222f;
  --border: #2a2a3a;

  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #555570;

  --accent-blue: #7bafd4;
  --accent-green: #8dcbb0;
  --accent-red: #d98a8a;
  --accent-yellow: #d4c47b;

  /* Currency colors — muted organic palette */
  --color-eur: #7bafd4;
  --color-jpy: #d98a8a;
  --color-brl: #8dcbb0;
  --color-gbp: #b0a0d4;
  --color-sgd: #d4c47b;
  --color-cad: #d4a87b;
  --color-try: #c98aad;
  --color-chf: #7bbdc4;
  --color-aud: #a8c47b;
  --color-zar: #9b8ac4;

  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Loading State --- */
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 1rem;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- App Layout --- */
.app { max-width: 1440px; margin: 0 auto; padding: 1.5rem; }

/* --- Header --- */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.header-logo-link { display: flex; align-items: center; }
.header-logo { height: 36px; width: auto; }
.header-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; font-size: 0.75rem; }
.freshness-badge { color: var(--text-muted); font-family: var(--font-mono); }
.data-source { color: var(--text-secondary); }

/* --- Sections --- */
.section { margin-bottom: 3rem; }
.section h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 1rem; }

/* --- Table Controls --- */
.table-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { outline: none; border-color: var(--accent-blue); }

.filter-group { display: flex; gap: 0.5rem; }

.filter-select {
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.875rem;
}

/* --- Table --- */
.table-container { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th:hover { color: var(--text-primary); }

td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tr:hover td { background: var(--bg-hover); }

/* Numeric alignment */
td.num, th.num { text-align: right; font-family: var(--font-mono); }

/* Color-coded change percentages */
.change-positive { color: var(--accent-green); }
.change-negative { color: var(--accent-red); }
.change-neutral { color: var(--text-muted); }

/* Result count */
.table-result-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Rank column */
.rank-cell { color: var(--text-muted); font-size: 0.75rem; width: 2rem; }

/* Name cell with issuer */
.name-cell { display: flex; flex-direction: column; gap: 0.125rem; }
.name-issuer { font-size: 0.7rem; color: var(--text-muted); font-weight: 400; }

/* Currency tag */
.currency-tag {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  border: 1px solid;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

/* Type badges */
.type-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.type-c { background: rgba(123, 175, 212, 0.15); color: var(--accent-blue); }
.type-d { background: rgba(141, 203, 176, 0.15); color: var(--accent-green); }

/* Dominance bar */
.dominance-cell {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 80px;
  justify-content: flex-end;
}

.dominance-bar {
  height: 4px;
  border-radius: 2px;
  min-width: 2px;
  flex-shrink: 0;
  max-width: 50px;
}

.dominance-cell span {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Sortable header styling */
th.sortable { cursor: pointer; }
th:not(.sortable) { cursor: default; }

/* No data indicator */
.no-data { color: var(--text-muted); font-style: italic; }

/* Table separator */
.table-separator td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.table-separator span {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* Catalog-only row styling */
tr.catalog-only td { color: var(--text-muted); opacity: 0.5; }
.tag-no-data {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* --- Cards (for hero section) --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.stat-large {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

/* --- Hero Grid --- */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.hero-card { display: flex; flex-direction: column; gap: 0.25rem; }
.hero-card-wide { grid-column: 1 / -1; }

.card-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 500;
}

.card-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-label {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-secondary);
}

/* Currency pills */
.currency-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.currency-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid;
  border-radius: 999px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  font-weight: 500;
}

.pill-pct {
  font-weight: 400;
  opacity: 0.7;
  font-size: 0.7rem;
}

/* --- Currency Deep Dives --- */
.currency-dives {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dive-card { padding: 1.25rem; }

.dive-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.dive-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dive-currency-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.875rem;
  color: #0a0a0f;
}

.dive-stats { display: flex; flex-direction: column; }

.dive-mcap {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

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

.dive-summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.dive-body {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.dive-chart-col {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dive-table-col {
  flex: 1;
  overflow-x: auto;
}

.dive-table { font-size: 0.8rem; }
.dive-table th { font-size: 0.65rem; padding: 0.5rem; }
.dive-table td { padding: 0.5rem; }

.dive-catalog-note {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* --- Sparkline --- */
.sparkline-cell { width: 80px; height: 28px; }
.sparkline-cell canvas { display: block; }

/* --- Footer --- */
.footer {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .app { padding: 1rem; }
  .header { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
  .header-meta { align-items: flex-start; }
  .stat-large { font-size: 1.5rem; }
  .hero-grid { grid-template-columns: 1fr; }
  .dive-body { flex-direction: column; }
  .dive-chart-col { align-self: center; }
}
