/* ── Z-Node Dashboard Styles ────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a26;
  --bg-card-hover: #22222e;
  --bg-input: #0f0f17;
  --border: #2a2a3a;
  --border-focus: #6366f1;
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #555570;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --success: #22c55e;
  --success-glow: rgba(34, 197, 94, 0.15);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.1);
  --gradient-1: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
  --gradient-2: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 100%);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
}

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

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

/* ── Layout ──────────────────────────────────────────────────────── */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  width: 100%;
}

.center-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

/* ── Header ──────────────────────────────────────────────────────── */
.header {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
  letter-spacing: -0.5px;
}

.logo span {
  -webkit-text-fill-color: var(--text-muted);
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-email {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: all 0.2s ease;
}

.card:hover {
  border-color: rgba(99, 102, 241, 0.3);
}

.card-sm {
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Auth Card ────────────────────────────────────────────────────── */
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 700;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 8px;
}

/* ── Forms ────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  display: none;
}

.form-error.visible {
  display: block;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gradient-1);
  color: white;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(99, 102, 241, 0.3);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--danger-glow);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
}

/* ── Balance display ──────────────────────────────────────────────── */
.balance-card {
  background: var(--gradient-2);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius);
  padding: 28px;
  position: relative;
  overflow: hidden;
}

.balance-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

.balance-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.balance-value {
  font-size: 40px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 8px;
  position: relative;
}

.balance-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
  position: relative;
}

/* ── API Key display ──────────────────────────────────────────────── */
.key-display {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 12px;
}

.key-value {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
}

.key-copy-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 13px;
  transition: opacity 0.2s;
}

.key-copy-btn:hover {
  opacity: 0.7;
}

/* ── New key reveal ───────────────────────────────────────────────── */
.new-key-reveal {
  background: var(--success-glow);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  display: none;
}

.new-key-reveal.visible {
  display: block;
  animation: fadeIn 0.3s ease;
}

.new-key-reveal h3 {
  color: var(--success);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.new-key-reveal p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 12px;
}

/* ── Key list ─────────────────────────────────────────────────────── */
.key-list {
  list-style: none;
}

.key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.key-item:last-child {
  border-bottom: none;
}

.key-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.key-prefix {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-primary);
}

.key-date {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Top-up grid ──────────────────────────────────────────────────── */
.topup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.topup-option {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.topup-option:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.topup-amount {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.topup-credits {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.topup-tokens {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Section spacing ──────────────────────────────────────────────── */
.section {
  padding: 32px 0;
}

.section-grid {
  display: grid;
  gap: 24px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

/* ── Link ─────────────────────────────────────────────────────────── */
.link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  transition: opacity 0.2s;
}

.link:hover {
  opacity: 0.8;
}

/* ── Toggle ───────────────────────────────────────────────────────── */
.auth-toggle {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-toggle a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

/* ── Badge ────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: var(--success-glow);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-glow);
  color: var(--danger);
}

/* ── Code block ───────────────────────────────────────────────────── */
.code-block {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-primary);
  overflow-x: auto;
  line-height: 1.7;
  position: relative;
}

.code-block .code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.code-block .code-copy-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}

.code-keyword { color: #c792ea; }
.code-string { color: #c3e88d; }
.code-comment { color: var(--text-muted); }
.code-prop { color: #82aaff; }

/* ── Toast ────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14px;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.toast-success {
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--success);
}

/* ── Loading ──────────────────────────────────────────────────────── */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topup-grid {
    grid-template-columns: 1fr;
  }
  
  .auth-card {
    padding: 28px;
  }
  
  .balance-value {
    font-size: 32px;
  }
}

/* ── Setup guide steps ────────────────────────────────────────────── */
.step {
  margin-bottom: 32px;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gradient-1);
  color: white;
  font-size: 13px;
  font-weight: 600;
  margin-right: 10px;
}

.step h3 {
  display: inline;
  font-size: 16px;
  font-weight: 600;
  vertical-align: middle;
}

.step p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 12px;
  margin-left: 38px;
}

.step .code-block {
  margin-top: 12px;
  margin-left: 38px;
}

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

.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: 'Inter', sans-serif;
}

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

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

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}
