/* ─── VergeMesh Relay PWA — Dark Theme ───────────────────────────────────── */
:root {
  --bg-primary:    #0a0f14;
  --bg-secondary:  #111921;
  --bg-card:       #151e28;
  --bg-input:      #1a2430;
  --border:        #243040;
  --border-focus:  #00d17f;
  --text-primary:  #e8ecf0;
  --text-secondary:#8899aa;
  --text-muted:    #556677;
  --accent:        #00d17f;
  --accent-dim:    #00a866;
  --accent-glow:   rgba(0, 209, 127, 0.15);
  --danger:        #ff4c6a;
  --danger-dim:    #cc3d55;
  --warning:       #ffb347;
  --success:       #00d17f;
  --radius:        12px;
  --radius-sm:     8px;
  --font-body:     'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:     'JetBrains Mono', 'Courier New', monospace;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── SCREENS ─────────────────────────────────────────────────────────── */
.screen {
  display: none;
  padding: 16px;
  padding-top: 72px;
  padding-bottom: 32px;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  animation: fadeIn 0.2s ease;
}
.screen.active { display: block; }

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

/* ─── STATUS BAR ──────────────────────────────────────────────────────── */
#statusBar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(10, 15, 20, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.status-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-text {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.status-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}
.status-badge.offline {
  background: rgba(255, 76, 106, 0.15);
  color: var(--danger);
}
.status-badge.online {
  background: rgba(0, 209, 127, 0.15);
  color: var(--accent);
}

/* ─── BALANCE CARD ────────────────────────────────────────────────────── */
.balance-card {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin-bottom: 24px;
}
.balance-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}
.balance-amount {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
}
.balance-unit {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 400;
}
.balance-meta {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.address-chip {
  font-family: var(--font-mono);
  background: var(--bg-input);
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}

/* ─── ACTION GRID ─────────────────────────────────────────────────────── */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-body);
}
.action-btn:active {
  transform: scale(0.97);
  background: var(--bg-input);
}
.action-btn.primary {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.action-btn.primary svg { color: var(--accent); }

/* ─── SECTION LABELS ──────────────────────────────────────────────────── */
.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ─── ACTIVITY LOG ────────────────────────────────────────────────────── */
.activity-log {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 100px;
  max-height: 200px;
  overflow-y: auto;
}
.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
  font-size: 0.85rem;
}
.activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-item .activity-type { color: var(--accent); font-weight: 600; }
.activity-item .activity-time { color: var(--text-muted); font-size: 0.72rem; }

/* ─── BOTTOM ACTIONS ──────────────────────────────────────────────────── */
.bottom-actions {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 24px;
}
.link-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: color 0.2s;
}
.link-btn:active { color: var(--accent); }

/* ─── SCREEN HEADERS ──────────────────────────────────────────────────── */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.screen-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
}
.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--font-body);
  padding: 4px 0;
}

/* ─── FORMS ───────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.input-row {
  display: flex;
  gap: 8px;
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--border-focus);
}
.form-group input[type="number"] {
  font-family: var(--font-mono);
}
.field-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 4px;
  min-height: 1.2em;
}
.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.field-hint a { color: var(--accent); text-decoration: none; }

.icon-btn, .text-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 8px 14px;
  white-space: nowrap;
  transition: background 0.2s;
}
.icon-btn:active, .text-btn:active { background: var(--border); }
.text-btn { font-weight: 600; color: var(--accent); }

/* ─── TX SUMMARY ──────────────────────────────────────────────────────── */
.tx-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.summary-row span:last-child {
  font-family: var(--font-mono);
  color: var(--text-primary);
}
.summary-row.total {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding-top: 12px;
  font-weight: 600;
}
.summary-row.total span:last-child { color: var(--accent); }

/* ─── BUTTONS ─────────────────────────────────────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 14px 24px;
  background: var(--accent);
  color: #0a0f14;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-primary:active { background: var(--accent-dim); transform: scale(0.98); }
.btn-primary:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 12px 24px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.2s;
}
.btn-secondary:active { background: var(--bg-input); }

.btn-danger {
  display: block;
  width: 100%;
  padding: 12px 24px;
  background: rgba(255, 76, 106, 0.12);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
}

/* ─── PREVIEW CARD ────────────────────────────────────────────────────── */
.preview-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.preview-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  gap: 12px;
}
.preview-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.preview-row span:last-child {
  text-align: right;
  word-break: break-all;
}

.mono { font-family: var(--font-mono); font-size: 0.85rem; }

/* ─── WARNING BOX ─────────────────────────────────────────────────────── */
.warning-box {
  background: rgba(255, 179, 71, 0.1);
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 0.82rem;
  color: var(--warning);
  line-height: 1.5;
}

/* ─── QR CONTAINERS ───────────────────────────────────────────────────── */
.qr-container {
  display: flex;
  justify-content: center;
  padding: 24px;
  background: #ffffff;
  border-radius: var(--radius);
  margin: 16px 0;
}
.qr-instruction {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.qr-instruction.sub {
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.divider-or {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 20px 0 12px;
  position: relative;
}
.divider-or::before, .divider-or::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border);
}
.divider-or::before { left: 0; }
.divider-or::after { right: 0; }

.hex-input {
  width: 100%;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  resize: vertical;
  outline: none;
}
.hex-input:focus { border-color: var(--border-focus); }

/* ─── PROGRESS ────────────────────────────────────────────────────────── */
.progress-container {
  display: flex;
  justify-content: center;
  margin: 32px 0 24px;
}
.progress-ring {
  position: relative;
  width: 120px;
  height: 120px;
}
.progress-ring svg { width: 100%; height: 100%; }
.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent);
}

.sending-status {
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.chunk-log {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  max-height: 150px;
  overflow-y: auto;
  line-height: 1.6;
}
.chunk-log .sent { color: var(--accent); }
.chunk-log .error { color: var(--danger); }
.chunk-log .waiting { color: var(--warning); }

/* ─── RESULT ──────────────────────────────────────────────────────────── */
.result-icon {
  width: 80px;
  height: 80px;
  margin: 40px auto 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}
.result-icon.success {
  background: rgba(0, 209, 127, 0.15);
  color: var(--accent);
}
.result-icon.error {
  background: rgba(255, 76, 106, 0.15);
  color: var(--danger);
}

#screenResult h2 {
  text-align: center;
  font-size: 1.2rem;
  margin-bottom: 8px;
}
.result-message {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 24px;
}

.txid-display {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  text-align: center;
  word-break: break-all;
  margin-bottom: 24px;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 20px;
}

/* ─── SCANNER ─────────────────────────────────────────────────────────── */
.scanner-screen {
  padding: 0;
  padding-top: 56px;
}
.scanner-viewport {
  position: relative;
  width: 100%;
  height: calc(100dvh - 120px);
  overflow: hidden;
  background: #000;
}
.scanner-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scanner-frame {
  width: 240px;
  height: 240px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
}
.scanner-status {
  text-align: center;
  padding: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ─── SETTINGS ────────────────────────────────────────────────────────── */
.settings-toggles {
  margin-bottom: 24px;
}
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  cursor: pointer;
}
.settings-info {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.settings-info h3 {
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--text-secondary);
}
.settings-info p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 4px;
}

.uri-display {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  word-break: break-all;
  padding: 8px;
}

/* ─── TOAST ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 0.85rem;
  z-index: 200;
  transition: bottom 0.3s ease;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.toast.show { bottom: 32px; }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--accent); color: var(--accent); }

/* ─── SPINNER OVERLAY ─────────────────────────────────────────────────── */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 20, 0.85);
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-message {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

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