/* ==========================================================================
   W-Trader API Portal — Terminal Finance Aesthetic
   ========================================================================== */

:root, [data-theme="dark"] {
  --bg: #0a0e17;
  --bg-card: #111827;
  --bg-card-hover: #1a2332;
  --bg-input: #0d1321;
  --border: #1e293b;
  --border-focus: #3b82f6;
  --text: #e2e8f0;
  --text-dim: #64748b;
  --text-muted: #475569;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --orange: #f97316;
  --nav-bg: rgba(10, 14, 23, 0.85);
  --shadow: rgba(0, 0, 0, 0.3);
  --font-body: 'Instrument Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 8px;
  --radius-lg: 12px;
}

[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --border: #cbd5e1;
  --border-focus: #3b82f6;
  --text: #0f172a;
  --text-dim: #475569;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-glow: rgba(37, 99, 235, 0.1);
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #ca8a04;
  --orange: #ea580c;
  --nav-bg: rgba(248, 250, 252, 0.9);
  --shadow: rgba(15, 23, 42, 0.08);
}

/* Smooth transition when switching themes */
body, .nav, .card, .feature-card, .coverage-card, .dash-card, .auth-card,
input, select, .btn, .btn-ghost, .api-key-display, .terminal, .terminal-body,
.params-table td, .kv-row, .market-tab {
  transition: background-color 0.25s, color 0.25s, border-color 0.25s;
}

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

html { scroll-behavior: smooth; }

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

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

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Nav */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 6px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a { color: var(--text-dim); font-size: 0.9rem; }
.nav-links a:hover, .nav-links a.active { color: var(--text); text-decoration: none; }

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s;
  padding: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-dim); }

.accent { color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #2563eb; text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--text-dim); color: var(--text); text-decoration: none; }

.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Hero */
.hero {
  position: relative;
  padding: 6rem 2rem 4rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  max-width: 1200px;
  margin: 0 auto;
  align-items: center;
}

.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.3;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}

.hero-content { position: relative; z-index: 1; }

.badge {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 20px;
  background: var(--accent-glow);
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--text-dim);
  max-width: 480px;
  margin-bottom: 2rem;
}

.hero-actions { display: flex; gap: 1rem; }

.hero-terminal { position: relative; z-index: 1; }

/* Terminal */
.terminal {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.8);
}

.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.red { background: #ef4444; }
.dot.yellow { background: #eab308; }
.dot.green { background: #22c55e; }

.terminal-title {
  margin-left: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.terminal-body {
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0;
}

.terminal .terminal-body { border: none; border-radius: 0; }

.t-dim { color: var(--text-muted); }
.t-str { color: var(--green); }
.t-num { color: var(--orange); }
.t-key { color: var(--accent); }
.t-url { color: var(--yellow); }
.t-buy { color: var(--green); font-weight: 600; }
.t-hold { color: var(--yellow); font-weight: 600; }
.t-sell { color: var(--red); font-weight: 600; }

/* Sections */
.section-head {
  text-align: center;
  margin-bottom: 3rem;
}

.section-head h2 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-head p { color: var(--text-dim); margin-top: 0.5rem; }

/* Features */
.features {
  padding: 5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: border-color 0.2s, transform 0.2s;
}

.feature-card:hover {
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.feature-card.highlight {
  border-color: rgba(59, 130, 246, 0.4);
  background: linear-gradient(135deg, var(--bg-card), rgba(59, 130, 246, 0.05));
}

.feature-method {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.feature-method.get { background: rgba(34, 197, 94, 0.15); color: var(--green); }

.feature-card h3 {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.feature-card p { color: var(--text-dim); font-size: 0.9rem; }

/* Coverage */
.coverage {
  padding: 5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.coverage-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

.coverage-card {
  text-align: center;
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.coverage-num {
  font-size: 2.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent);
}

.coverage-label { font-weight: 600; margin-top: 0.5rem; }
.coverage-sub { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.25rem; }

/* CTA */
.cta {
  text-align: center;
  padding: 5rem 2rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.cta h2 { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; }
.cta p { color: var(--text-dim); margin-bottom: 2rem; }

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

.footer-sep { margin: 0 0.75rem; }

/* Auth Pages */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 65px);
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
}

.auth-card h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.auth-sub { color: var(--text-dim); margin-bottom: 1.5rem; }

.field { margin-bottom: 1.25rem; }
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-dim);
}

.field input, .field select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus, .field select:focus { border-color: var(--border-focus); }
.field input::placeholder { color: var(--text-muted); }

.auth-footer { text-align: center; margin-top: 1.5rem; font-size: 0.85rem; color: var(--text-dim); }

.error-msg {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Dashboard */
.dashboard {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

.dash-header { margin-bottom: 2rem; }
.dash-header h1 { font-size: 1.75rem; }
.dash-header p { color: var(--text-dim); }

.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

.dash-card h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.dash-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.dash-card-header h2 { margin-bottom: 0; }

.api-key-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.api-key-display code {
  flex: 1;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
  color: var(--green);
  word-break: break-all;
}

.btn-copy {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  display: flex;
}
.btn-copy:hover { color: var(--text); }

.api-key-hint { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.75rem; }

/* Status */
.status-banner {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}

.status-banner.pending {
  background: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.25);
  color: var(--yellow);
}

.status-banner.rejected {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--red);
}

.status-banner p { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.25rem; }
.status-icon { font-size: 1.25rem; margin-top: 2px; }

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 20px;
}

.status-badge.approved { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.status-badge.pending { background: rgba(234, 179, 8, 0.15); color: var(--yellow); }
.status-badge.rejected { background: rgba(239, 68, 68, 0.15); color: var(--red); }

/* Quick Test */
.test-input-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.test-input-row select {
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.test-input-row input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
}

.test-result {
  max-height: 400px;
  overflow: auto;
}

/* Example Tabs */
.example-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 0.5rem 1.25rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-family: var(--font-body);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Docs */
.docs-page {
  display: grid;
  grid-template-columns: 200px 1fr;
  max-width: 1100px;
  margin: 0 auto;
  gap: 3rem;
  padding: 2rem;
}

.docs-sidebar {
  position: sticky;
  top: 80px;
  height: fit-content;
}

.docs-sidebar h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.docs-sidebar a {
  display: block;
  padding: 0.35rem 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.docs-sidebar a:hover { color: var(--text); text-decoration: none; }

.docs-content h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.docs-intro { color: var(--text-dim); margin-bottom: 2rem; }

.doc-section {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
}

.doc-section h2 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.doc-section h3 {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 1.25rem 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.method-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 4px;
}

.method-badge.get { background: rgba(34, 197, 94, 0.15); color: var(--green); }

.params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.params-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.params-table td:first-child {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  white-space: nowrap;
}

.params-table td:nth-child(2) { color: var(--text-muted); white-space: nowrap; }

.try-btn { margin-top: 1rem; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h3 {
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .hero {
    grid-template-columns: 1fr;
    padding: 3rem 1.5rem;
    gap: 2rem;
  }
  .hero h1 { font-size: 2rem; }
  .feature-grid { grid-template-columns: 1fr; }
  .coverage-grid { grid-template-columns: repeat(2, 1fr); }
  .docs-page { grid-template-columns: 1fr; }
  .docs-sidebar { display: none; }
  .hero-actions { flex-direction: column; }
  .test-input-row { flex-direction: column; }
}
