/* ══════════════════════════════════════════════════════════
   GoldTrack Pro — Premium Dark Theme
   ══════════════════════════════════════════════════════════ */

:root {
  --bg: #0a0e1a;
  --bg2: #0f1525;
  --surface: #141b2d;
  --surface2: #1a2340;
  --border: #1e2a45;
  --border2: #283656;

  --text: #e8ecf4;
  --text2: #94a3b8;
  --text3: #64748b;
  --muted: #475569;

  --gold: #f5c518;
  --gold2: #d4a20a;
  --gold-glow: rgba(245, 197, 24, 0.15);
  --gold-soft: rgba(245, 197, 24, 0.08);

  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.12);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.12);
  --accent: #8b5cf6;
  --accent-bg: rgba(139, 92, 246, 0.12);

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Ambient glow background */
body::before {
  content: '';
  position: fixed;
  top: -200px;
  left: -100px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--gold-glow) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -200px;
  right: -100px;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--blue-bg) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 24px;
}

/* ═══ Header ═══ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  font-size: 36px;
  filter: drop-shadow(0 0 12px rgba(245, 197, 24, 0.4));
  animation: pulse-gold 3s ease-in-out infinite;
}

@keyframes pulse-gold {

  0%,
  100% {
    filter: drop-shadow(0 0 8px rgba(245, 197, 24, 0.3));
  }

  50% {
    filter: drop-shadow(0 0 20px rgba(245, 197, 24, 0.6));
  }
}

.logo h1 {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--text);
}

.logo .pro {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text3);
  font-size: 13px;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border2);
  background: var(--surface);
  transition: var(--transition);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  transition: var(--transition);
}

.status-badge.online .status-dot {
  background: var(--green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.status-badge.online {
  border-color: rgba(16, 185, 129, 0.3);
  background: var(--green-bg);
  color: var(--green);
}

.status-badge.updating .status-dot {
  background: var(--gold);
  box-shadow: 0 0 8px rgba(245, 197, 24, 0.6);
  animation: blink 0.6s ease-in-out infinite;
}

.status-badge.updating {
  border-color: rgba(245, 197, 24, 0.3);
  background: rgba(245, 197, 24, 0.1);
  color: var(--gold);
}

.table-footer {
  display: flex;
  justify-content: space-between;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text3);
}

.update-time {
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
}

.main {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 24px;
}

.clock {
  font-size: 13px;
  color: var(--text3);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ═══ Stats Bar ═══ */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.gold {
  background: var(--gold-soft);
}

.stat-icon.red {
  background: var(--red-bg);
}

.stat-icon.green {
  background: var(--green-bg);
}

.stat-icon.blue {
  background: var(--blue-bg);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* ═══ Main Grid ═══ */
.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 1080px) {
  .main-grid {
    grid-template-columns: 1fr 380px;
    align-items: start;
  }
}

.right-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ═══ Cards ═══ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.gold-header {
  background: linear-gradient(135deg, rgba(245, 197, 24, 0.06) 0%, transparent 60%);
}

.gold-header h2 {
  color: var(--gold);
}

.card-sub {
  font-size: 12px;
  color: var(--text3);
  margin-top: 3px;
}

.card-body {
  padding: 16px 20px;
}

.card-footer {
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text3);
  text-align: center;
}

/* ═══ Price Table ═══ */
.table-wrapper {
  overflow-x: auto;
  max-height: 480px;
  overflow-y: auto;
}

#priceTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#priceTable thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

#priceTable th {
  background: var(--bg2);
  color: var(--text3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.th-name {
  text-align: left;
}

.th-price {
  text-align: right;
}

.muted-col {
  color: var(--muted) !important;
}

#priceTable td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

#priceTable tbody tr {
  transition: background var(--transition);
}

#priceTable tbody tr:hover {
  background: rgba(245, 197, 24, 0.04);
}

.gold-name {
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  font-size: 13px;
}

.gold-name.featured {
  color: var(--gold);
}

.price-val {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.price-val.sell {
  color: var(--gold);
  font-weight: 800;
}

.price-yesterday {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.change-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.change-badge.up {
  background: var(--green-bg);
  color: var(--green);
}

.change-badge.down {
  background: var(--red-bg);
  color: var(--red);
}

.empty-state {
  text-align: center;
  padding: 60px 20px !important;
  color: var(--text3);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.empty-state p {
  margin: 4px 0;
}

.empty-hint {
  font-size: 12px;
  color: var(--muted);
}

.empty-hint code {
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--gold);
}

/* ═══ Buttons ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.btn-icon {
  font-size: 15px;
}

.btn-lg {
  padding: 12px 18px;
  font-size: 13px;
  border-radius: 12px;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #1a1a1a;
  border-color: var(--gold2);
  font-weight: 800;
}

.btn-gold:hover {
  box-shadow: 0 4px 20px rgba(245, 197, 24, 0.3);
}

.btn-primary {
  background: var(--blue-bg);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--blue);
}

.btn-primary:hover {
  background: rgba(59, 130, 246, 0.2);
}

.btn-accent {
  background: var(--accent-bg);
  border-color: rgba(139, 92, 246, 0.3);
  color: var(--accent);
}

.btn-accent:hover {
  background: rgba(139, 92, 246, 0.2);
}

.btn-success {
  background: var(--green-bg);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--green);
}

.btn-success:hover {
  background: rgba(16, 185, 129, 0.2);
}

.btn-danger {
  background: var(--red-bg);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text3);
  padding: 6px 12px;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface2);
}

/* ═══ Actions Grid ═══ */
.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ═══ Form Fields ═══ */
.field-row {
  margin-top: 4px;
}

.field-row label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-row input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: var(--transition);
}

.field-row input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

/* ═══ Scraper Output ═══ */
.scraper-output {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text2);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* ═══ Logs ═══ */
.logs {
  height: 320px;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 12px;
  line-height: 1.5;
}

.logs::-webkit-scrollbar {
  width: 5px;
}

.logs::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 4px;
}

.logs::-webkit-scrollbar-track {
  background: transparent;
}

.log-empty {
  color: var(--muted);
  text-align: center;
  margin-top: 120px;
}

.log-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 6px;
  padding: 4px 0;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.log-time {
  color: var(--muted);
  white-space: nowrap;
  font-family: 'SF Mono', monospace;
  font-size: 11px;
  min-width: 65px;
}

.log-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  min-width: 46px;
  text-align: center;
  flex-shrink: 0;
}

.log-badge.info {
  background: var(--blue-bg);
  color: var(--blue);
}

.log-badge.success {
  background: var(--green-bg);
  color: var(--green);
}

.log-badge.warning {
  background: rgba(245, 197, 24, 0.12);
  color: var(--gold);
}

.log-badge.error {
  background: var(--red-bg);
  color: var(--red);
}

.log-badge.alert {
  background: var(--accent-bg);
  color: var(--accent);
}

.log-text {
  color: var(--text2);
  word-break: break-word;
}

/* ═══ Footer ═══ */
.footer {
  text-align: center;
  padding: 24px 0 12px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 32px;
}

/* ═══ Row Highlight Animation ═══ */
@keyframes priceFlash {
  0% {
    background: rgba(245, 197, 24, 0.15);
  }

  100% {
    background: transparent;
  }
}

.price-flash {
  animation: priceFlash 1.5s ease-out;
}

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
  .app {
    padding: 14px 12px;
  }

  .header {
    flex-direction: column;
    gap: 12px;
  }

  .stats-bar {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card {
    padding: 12px 14px;
  }

  .stat-value {
    font-size: 15px;
  }

  .actions-grid {
    grid-template-columns: 1fr;
  }

  .muted-col {
    display: none;
  }

  #priceTable td,
  #priceTable th {
    padding: 10px 10px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .stats-bar {
    grid-template-columns: 1fr;
  }

  .logo h1 {
    font-size: 22px;
  }
}