/* ═══════════════════════════════════════════════════════════════════
   AurumSwap — Gold-denominated trading dashboard
   ═══════════════════════════════════════════════════════════════════ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --gold: #D4A843;
  --gold-light: #F0D78C;
  --gold-dark: #A67C2E;
  --bg-primary: #0A0A0F;
  --bg-secondary: #111118;
  --bg-card: #16161F;
  --bg-input: #1A1A25;
  --text-primary: #F2F0ED;
  --text-secondary: #8A8A9A;
  --text-muted: #5A5A6A;
  --border: rgba(212, 168, 67, 0.12);
  --border-active: rgba(212, 168, 67, 0.3);
  --green: #16C784;
  --green-bg: rgba(22, 199, 132, 0.1);
  --green-dark: #0F8F5C;
  --red: #EA3943;
  --red-bg: rgba(234, 57, 67, 0.1);
  --red-dark: #B22D35;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  top: -40%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 900px;
  background: radial-gradient(circle, rgba(212, 168, 67, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#app { position: relative; z-index: 1; min-height: 100vh; }

/* ── Loading ──────────────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

/* ── Logo ─────────────────────────────────────────────────── */
.logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #0A0A0F;
}

/* ── Navigation ───────────────────────────────────────────── */
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-left { display: flex; align-items: center; }
.nav-center { display: flex; gap: 4px; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-tab {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.nav-tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.nav-tab.active { color: var(--gold); background: rgba(212, 168, 67, 0.08); }
.user-email { color: var(--text-muted); font-size: 0.8rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #0A0A0F;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-active); }
.btn-buy {
  background: var(--green);
  color: #fff;
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
}
.btn-buy:hover { background: var(--green-dark); }
.btn-sell {
  background: var(--red);
  color: #fff;
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
}
.btn-sell:hover { background: var(--red-dark); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid rgba(234,57,67,0.2); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Inputs ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--gold); }
.form-input::placeholder { color: var(--text-muted); }
.form-input.mono { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; }
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

/* ── Auth ─────────────────────────────────────────────────── */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-card .logo { justify-content: center; margin-bottom: 32px; }
.auth-card h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 24px;
}
.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.auth-switch a {
  color: var(--gold);
  cursor: pointer;
  text-decoration: none;
}
.auth-switch a:hover { text-decoration: underline; }

/* ── Main content ─────────────────────────────────────────── */
.main-content { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* ── Trade layout ─────────────────────────────────────────── */
.market-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.pair-selector {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--gold);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
  outline: none;
}
.pair-selector option { background: var(--bg-card); color: var(--text-primary); }
.market-stats { display: flex; gap: 32px; flex-wrap: wrap; }
.stat-label { display: block; font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 600;
}
.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }

.trade-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  margin-bottom: 20px;
}

/* ── Order Book ───────────────────────────────────────────── */
.orderbook-panel { min-height: 400px; }
.orderbook-header {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.orderbook-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  position: relative;
  transition: background 0.15s;
}
.orderbook-row:hover { background: rgba(255,255,255,0.03); }
.orderbook-row .depth {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  opacity: 0.08;
  pointer-events: none;
}
.ob-ask .ob-price { color: var(--red); }
.ob-ask .depth { background: var(--red); }
.ob-bid .ob-price { color: var(--green); }
.ob-bid .depth { background: var(--green); }
.ob-qty { color: var(--text-secondary); }
.orderbook-spread {
  display: flex;
  justify-content: center;
  padding: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
}

/* ── Order Form ───────────────────────────────────────────── */
.order-panel { }
.side-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.side-btn {
  padding: 10px;
  border: none;
  border-radius: var(--radius-xs);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  color: var(--text-secondary);
}
.side-btn.buy-active { background: var(--green); color: #fff; }
.side-btn.sell-active { background: var(--red); color: #fff; }
.type-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}
.type-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.type-btn.active { border-color: var(--gold); color: var(--gold); background: rgba(212,168,67,0.06); }
.order-summary {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 16px 0;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 4px 0;
}
.summary-row .label { color: var(--text-muted); }
.summary-row .value { font-family: 'JetBrains Mono', monospace; color: var(--text-primary); }

/* ── Portfolio ────────────────────────────────────────────── */
.portfolio-hero {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.portfolio-hero::before {
  content: '';
  position: absolute;
  top: -60%;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(212,168,67,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.portfolio-hero .hero-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  position: relative;
}
.portfolio-hero .hero-oz {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--gold);
  position: relative;
}
.portfolio-hero .hero-oz span { font-size: 1.2rem; color: var(--text-secondary); margin-left: 8px; }
.portfolio-hero .hero-usd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-top: 4px;
  position: relative;
}

/* ── Holdings table ───────────────────────────────────────── */
.holdings-table { width: 100%; border-collapse: collapse; }
.holdings-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.holdings-table th:last-child,
.holdings-table td:last-child { text-align: right; }
.holdings-table td {
  padding: 14px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.holdings-table tr:hover td { background: rgba(255,255,255,0.02); }
.coin-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.coin-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--gold);
  border: 1px solid var(--border);
}
.mono { font-family: 'JetBrains Mono', monospace; }
.gold-text { color: var(--gold); }
.alloc-bar {
  width: 60px;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-input);
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
}
.alloc-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--gold);
}

/* ── Orders ───────────────────────────────────────────────── */
.orders-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}
.orders-tab {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.orders-tab.active { border-color: var(--gold); color: var(--gold); background: rgba(212,168,67,0.06); }
.orders-table { width: 100%; border-collapse: collapse; }
.orders-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.orders-table td {
  padding: 10px 12px;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  font-family: 'JetBrains Mono', monospace;
}
.orders-table td.text { font-family: 'DM Sans', sans-serif; }
.side-buy { color: var(--green); font-weight: 600; }
.side-sell { color: var(--red); font-weight: 600; }
.status-filled { color: var(--green); }
.status-cancelled { color: var(--text-muted); }
.status-new { color: var(--gold); }

/* ── Settings ─────────────────────────────────────────────── */
.settings-grid { max-width: 640px; }
.connection-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.connected { background: var(--green); box-shadow: 0 0 8px rgba(22,199,132,0.4); }
.status-dot.disconnected { background: var(--red); }
.status-text { font-size: 0.9rem; }
.status-label { color: var(--text-muted); font-size: 0.8rem; }

/* ── Onboarding prompt ────────────────────────────────────── */
.onboarding {
  text-align: center;
  padding: 60px 24px;
}
.onboarding h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  margin-bottom: 12px;
}
.onboarding p {
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto 24px;
}
.onboarding .steps {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin: 32px 0;
  flex-wrap: wrap;
}
.onboarding .step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 200px;
  text-align: center;
}
.onboarding .step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(212,168,67,0.1);
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.onboarding .step h4 { font-size: 0.9rem; margin-bottom: 4px; }
.onboarding .step p { font-size: 0.8rem; color: var(--text-muted); }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 9999;
  transition: transform 0.3s ease;
  pointer-events: none;
  max-width: 90vw;
}
.toast-show { transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-info { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.toast-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(22,199,132,0.3); }
.toast-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(234,57,67,0.3); }

/* ── Section title ────────────────────────────────────────── */
.section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 20px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .trade-grid { grid-template-columns: 1fr; }
  .market-stats { gap: 16px; }
  .portfolio-hero .hero-oz { font-size: 2rem; }
  .nav-center { display: none; }
  .mobile-nav {
    display: flex;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 8px 0;
    z-index: 100;
  }
  .mobile-nav .nav-tab { font-size: 0.75rem; padding: 6px 10px; }
  .main-content { padding: 16px; padding-bottom: 72px; }
}
@media (min-width: 901px) {
  .mobile-nav { display: none; }
}
