/* ═══════════════════════════════════════════════════
   PayGate — Pay-Per-Call API Marketplace
   ═══════════════════════════════════════════════════ */

:root {
  --bg: #06060a;
  --bg2: #0c0c14;
  --surface: #111119;
  --surface2: #16161f;
  --border: #1e1e2e;
  --border-h: #2a2a3e;
  --accent: #6c5ce7;
  --accent-g: linear-gradient(135deg, #6c5ce7, #a29bfe);
  --accent2: #00cec9;
  --accent3: #fd79a8;
  --accent4: #fdcb6e;
  --green: #00b894;
  --red: #e17055;
  --text: #e8e8f0;
  --text2: #9898aa;
  --text3: #55556a;
  --font: 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --radius: 14px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Particle Canvas */
#particleCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ── NAV ─────────────────────────────────────── */
nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; height: 60px;
  background: rgba(6,6,10,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav-left { display: flex; align-items: center; gap: 32px; }

.nav-logo {
  font-size: 18px; font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}
.nav-logo span { color: var(--accent); }

.nav-links { display: flex; gap: 4px; }

.nav-tab {
  background: none; border: none; color: var(--text3);
  font-family: var(--font); font-size: 13px; font-weight: 500;
  padding: 8px 16px; border-radius: 8px;
  cursor: pointer; transition: all 0.2s;
}
.nav-tab:hover { color: var(--text2); background: var(--surface); }
.nav-tab.active { color: var(--text); background: var(--surface2); }

.wallet-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 6px 8px 6px 14px; border-radius: 100px;
}

.wallet-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red);
  transition: background 0.3s;
}
.wallet-dot.live { background: var(--green); animation: pulse 2s infinite; }

.wallet-bal {
  font-family: var(--mono); font-size: 13px;
  font-weight: 600; color: var(--accent2);
  min-width: 52px;
}

.wallet-connect-btn {
  background: var(--accent-g); border: none;
  color: #fff; font-family: var(--mono); font-size: 11px;
  font-weight: 700; padding: 6px 14px;
  border-radius: 100px; cursor: pointer;
  transition: all 0.2s; letter-spacing: 0.5px;
}
.wallet-connect-btn:hover { transform: scale(1.03); box-shadow: 0 2px 12px rgba(108,92,231,0.4); }
.wallet-connect-btn.done { background: var(--green); cursor: default; }

/* ── TABS ────────────────────────────────────── */
.tab-content { display: none; padding: 0 32px 48px; max-width: 1100px; margin: 0 auto; position: relative; z-index: 1; }
.tab-content.active { display: block; animation: fadeIn 0.35s ease; }

/* ── HERO ────────────────────────────────────── */
.hero { text-align: center; padding: 48px 0 36px; }

.hero-badge {
  display: inline-block;
  font-family: var(--mono); font-size: 11px;
  color: var(--accent); letter-spacing: 1.5px;
  background: rgba(108,92,231,0.1);
  border: 1px solid rgba(108,92,231,0.2);
  padding: 6px 16px; border-radius: 100px;
  margin-bottom: 18px;
}

.hero h1 { font-size: clamp(32px, 6vw, 52px); font-weight: 900; letter-spacing: -1.5px; line-height: 1.1; }

.grad-text {
  background: var(--accent-g);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  margin-top: 12px; font-size: 15px;
  color: var(--text2); max-width: 500px;
  margin-left: auto; margin-right: auto; line-height: 1.5;
}

/* ── API GRID ────────────────────────────────── */
.api-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

.api-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  cursor: pointer; transition: all 0.25s;
  position: relative; overflow: hidden;
}
.api-card:hover { border-color: var(--border-h); transform: translateY(-3px); box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
.api-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent-g); opacity: 0; transition: opacity 0.25s;
}
.api-card:hover::before { opacity: 1; }

.api-icon { font-size: 28px; margin-bottom: 12px; }
.api-name { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.api-desc { font-size: 12px; color: var(--text2); line-height: 1.5; margin-bottom: 14px; }

.api-meta { display: flex; justify-content: space-between; align-items: center; }

.api-price {
  font-family: var(--mono); font-size: 15px;
  font-weight: 700; color: var(--accent2);
}

.api-calls {
  font-family: var(--mono); font-size: 10px;
  color: var(--text3); letter-spacing: 0.5px;
}

.api-dynamic {
  font-family: var(--mono); font-size: 9px;
  color: var(--accent3); margin-top: 6px;
  display: flex; align-items: center; gap: 4px;
}

/* ── CALL PANEL ──────────────────────────────── */
.call-panel-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  z-index: 60; opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.call-panel-overlay.active { opacity: 1; pointer-events: all; }

.call-panel {
  position: fixed; top: 0; right: -480px;
  width: 460px; max-width: 90vw; height: 100vh;
  background: var(--bg2); border-left: 1px solid var(--border);
  z-index: 61; padding: 28px;
  overflow-y: auto; transition: right 0.35s cubic-bezier(0.4,0,0.2,1);
}
.call-panel.active { right: 0; }

.call-panel-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.call-panel-header h3 { font-size: 20px; font-weight: 800; }

.cp-price { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--accent2); }
.cp-calls { font-family: var(--mono); font-size: 11px; color: var(--text3); margin-left: 10px; }

.cp-close {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text3); width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; font-size: 14px;
  transition: all 0.15s;
}
.cp-close:hover { color: var(--text); border-color: var(--border-h); }

.cp-desc { font-size: 13px; color: var(--text2); line-height: 1.5; margin-bottom: 20px; }

.cp-label { font-family: var(--mono); font-size: 10px; color: var(--text3); letter-spacing: 1.5px; text-transform: uppercase; display: block; margin-bottom: 8px; }

#cpInput {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; color: var(--text);
  font-family: var(--mono); font-size: 13px; resize: vertical;
  outline: none; transition: border-color 0.2s; margin-bottom: 16px;
}
#cpInput:focus { border-color: rgba(108,92,231,0.5); }

.cp-call-btn {
  width: 100%; padding: 14px;
  background: var(--accent-g); border: none;
  color: #fff; font-family: var(--font); font-size: 14px;
  font-weight: 700; border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.cp-call-btn:hover { box-shadow: 0 4px 20px rgba(108,92,231,0.35); transform: translateY(-1px); }
.cp-call-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

.cp-result-area { margin-top: 20px; }
.cp-result {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
  font-family: var(--mono); font-size: 12px;
  color: var(--accent2); line-height: 1.7;
  white-space: pre-wrap; max-height: 200px;
  overflow-y: auto;
}

/* Pipeline mini */
.cp-pipeline {
  margin-top: 20px; display: flex; align-items: center;
  gap: 6px; justify-content: center; flex-wrap: wrap;
}
.pipe-step {
  font-family: var(--mono); font-size: 10px; color: var(--text3);
  padding: 6px 10px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--border);
  transition: all 0.3s;
}
.pipe-step.active { color: var(--accent); border-color: var(--accent); background: rgba(108,92,231,0.1); }
.pipe-step.done { color: var(--green); border-color: var(--green); background: rgba(0,184,148,0.08); }
.pipe-step.fail { color: var(--red); border-color: var(--red); background: rgba(225,112,85,0.08); }
.pipe-arrow { color: var(--text3); font-family: var(--mono); font-size: 12px; }

/* ── DASHBOARD ───────────────────────────────── */
.dash-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }

.dash-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; text-align: center;
}
.dash-card.accent { border-color: rgba(108,92,231,0.3); }
.dash-card.accent2 { border-color: rgba(0,206,201,0.3); }

.dash-val { font-family: var(--mono); font-size: 26px; font-weight: 800; }
.dash-card.accent .dash-val { color: var(--accent); }
.dash-card.accent2 .dash-val { color: var(--accent2); }
.dash-lbl { font-size: 11px; color: var(--text3); margin-top: 4px; font-family: var(--mono); letter-spacing: 0.5px; }

.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 28px; }

.chart-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
}
.chart-box h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; color: var(--text2); }
.chart-box canvas { width: 100% !important; height: auto !important; }

.log-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
}
.log-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 14px; }

.log-list { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }

.log-entry {
  font-family: var(--mono); font-size: 11px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  animation: slideIn 0.3s ease;
}
.log-entry .log-left { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 0; }
.log-tag { padding: 2px 8px; border-radius: 4px; font-size: 9px; font-weight: 700; letter-spacing: 0.5px; }
.log-tag.user { background: rgba(108,92,231,0.15); color: var(--accent); }
.log-tag.system { background: rgba(0,206,201,0.15); color: var(--accent2); }
.log-msg { color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-cost { color: var(--accent3); white-space: nowrap; margin-left: 8px; }
.log-time { color: var(--text3); white-space: nowrap; }
.log-empty { text-align: center; color: var(--text3); font-size: 13px; padding: 32px; }

/* ── GATEWAY ─────────────────────────────────── */
.gw-flow {
  display: flex; align-items: center; justify-content: center;
  gap: 0; padding: 40px 0; flex-wrap: wrap;
}

.gw-node {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 20px;
  text-align: center; width: 150px; transition: all 0.4s;
}
.gw-node.active { border-color: var(--accent); box-shadow: 0 0 24px rgba(108,92,231,0.2); }
.gw-node.done { border-color: var(--green); box-shadow: 0 0 24px rgba(0,184,148,0.15); }

.gw-icon { font-size: 28px; margin-bottom: 8px; }
.gw-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.gw-sub { font-size: 10px; color: var(--text3); }

.gw-connector { display: flex; align-items: center; width: 50px; justify-content: center; position: relative; }
.gw-line { width: 100%; height: 2px; background: var(--border); }
.gw-dot {
  position: absolute; width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); left: 0; transition: all 0.5s;
}
.gw-dot.moving { background: var(--accent); left: calc(100% - 8px); box-shadow: 0 0 8px var(--accent); }
.gw-dot.done { background: var(--green); left: calc(100% - 8px); }

.gw-demo { text-align: center; margin: 24px 0; }

.gw-demo-btn {
  background: var(--accent-g); border: none; color: #fff;
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  padding: 12px 28px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.2s;
}
.gw-demo-btn:hover { box-shadow: 0 4px 20px rgba(108,92,231,0.3); }
.gw-demo-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.gw-log {
  margin-top: 16px; font-family: var(--mono); font-size: 11px;
  color: var(--text3); max-height: 120px; overflow-y: auto;
  text-align: left; max-width: 500px; margin-left: auto; margin-right: auto;
}
.gw-log div { padding: 4px 0; border-bottom: 1px solid var(--border); animation: slideIn 0.2s ease; }
.gw-log .gw-ok { color: var(--green); }
.gw-log .gw-info { color: var(--accent); }

.gw-stats {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; margin-top: 28px;
}
.gw-stats h3 { font-size: 16px; font-weight: 700; margin-bottom: 18px; text-align: center; }

.gw-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.gw-stat { text-align: center; }
.gw-stat span { display: block; font-family: var(--mono); font-size: 22px; font-weight: 800; color: var(--accent2); }
.gw-stat small { font-size: 10px; color: var(--text3); font-family: var(--mono); letter-spacing: 0.5px; }

/* ── MODAL ───────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; animation: overlayIn 0.4s ease; }

.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 36px; width: 90%; max-width: 360px;
  text-align: center;
  transform: scale(0) translateY(40px);
  opacity: 0;
  transition: none;
}
.modal-overlay.active .modal {
  animation: popBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s forwards;
}
.modal-icon { font-size: 44px; margin-bottom: 14px; }
.modal h2 { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.modal p { font-size: 13px; color: var(--text2); margin-bottom: 20px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; }
.btn-confirm {
  flex: 1; background: var(--accent-g); border: none; color: #fff;
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  padding: 12px; border-radius: 8px; cursor: pointer; transition: all 0.2s;
}
.btn-confirm:hover { opacity: 0.85; transform: scale(1.02); }

/* ── FOOTER ──────────────────────────────────── */
footer {
  text-align: center; padding: 32px;
  font-family: var(--mono); font-size: 10px;
  color: var(--text3); letter-spacing: 1.5px;
  position: relative; z-index: 1;
}

/* ── ANIMATIONS ──────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(0,184,148,0.4); } 50% { box-shadow: 0 0 0 5px rgba(0,184,148,0); } }

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popBounce {
  0% { opacity: 0; transform: scale(0.3) translateY(40px); }
  50% { opacity: 1; transform: scale(1.08) translateY(-5px); }
  70% { transform: scale(0.96) translateY(2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 768px) {
  nav { padding: 0 16px; }
  .nav-links { display: none; }
  .tab-content { padding: 0 16px 40px; }
  .dash-stats { grid-template-columns: 1fr 1fr; }
  .chart-row { grid-template-columns: 1fr; }
  .gw-stat-grid { grid-template-columns: 1fr 1fr; }
  .gw-flow { flex-direction: column; }
  .gw-connector { width: auto; height: 30px; flex-direction: column; }
  .gw-line { width: 2px; height: 100%; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
