/* css/main.css */
@import './reset.css';

/* ─── Design Tokens ──────────────────────────────────── */
:root {
  /* Colors */
  --bg:            #0a0a0a;
  --surface:       #111111;
  --surface-2:     #1a1a1a;
  --surface-3:     #222222;
  --border:        #2a2a2a;
  --border-light:  #333333;

  --primary:       #f97316;
  --primary-dark:  #ea6c0a;
  --primary-glow:  rgba(249,115,22,0.15);

  --success:       #22c55e;
  --success-bg:    rgba(34,197,94,0.1);
  --warning:       #eab308;
  --warning-bg:    rgba(234,179,8,0.1);
  --error:         #ef4444;
  --error-bg:      rgba(239,68,68,0.1);
  --info:          #3b82f6;
  --info-bg:       rgba(59,130,246,0.1);

  --text:          #f0f0f0;
  --text-2:        #a0a0a0;
  --text-3:        #555555;

  /* Typography */
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Spacing */
  --s1:  4px;
  --s2:  8px;
  --s3:  12px;
  --s4:  16px;
  --s5:  20px;
  --s6:  24px;
  --s8:  32px;
  --s10: 40px;
  --s12: 48px;
  --s16: 64px;

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.6);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.7);

  /* Layout */
  --max-w:    430px;
  --nav-h:    68px;
  --header-h: 60px;
}

/* ─── Base ───────────────────────────────────────────── */
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  height: 100%;
}

/* ─── App Shell ──────────────────────────────────────── */
.app {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
}

/* ─── Page ───────────────────────────────────────────── */
.page {
  flex: 1;
  overflow-y: auto;
  padding: var(--s4);
  padding-top: calc(var(--header-h) + var(--s4));
  padding-bottom: calc(var(--nav-h) + var(--s4));
}

/* ─── Header ─────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w);
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s4);
  z-index: 100;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.03em;
}

/* ─── Bottom Nav ─────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w);
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 var(--s2);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: var(--s2) var(--s4);
  border-radius: var(--r-md);
  transition: color 0.15s;
  min-width: 60px;
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.nav-item.active { color: var(--primary); }
.nav-item:hover  { color: var(--text-2);  }

/* ─── Cards ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s5);
}

.card + .card,
.card + .section-title,
.section-title + .card {
  margin-top: var(--s4);
}

/* ─── Balance Hero ───────────────────────────────────── */
.balance-hero {
  background: linear-gradient(135deg, #111827 0%, #1a1a2e 50%, #16213e 100%);
  border: 1px solid #1e2a4a;
  border-radius: var(--r-xl);
  padding: var(--s8) var(--s6);
  text-align: center;
  position: relative;
  overflow: hidden;
  margin-bottom: var(--s4);
}

.balance-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(249,115,22,0.05) 0%,
    transparent 60%
  );
  pointer-events: none;
}

.balance-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: var(--s2);
}

.balance-amount {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
  margin-bottom: var(--s3);
}

.balance-amount .currency {
  font-size: 20px;
  font-weight: 400;
  color: var(--text-2);
  margin-left: var(--s2);
}

.balance-status {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-size: 12px;
  color: var(--text-2);
  background: rgba(255,255,255,0.05);
  padding: 4px var(--s3);
  border-radius: var(--r-full);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-dot.active   { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.pending  { background: var(--warning); }
.status-dot.inactive { background: var(--text-3);  }

/* ─── Action Grid ────────────────────────────────────── */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
  margin-bottom: var(--s6);
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.15s;
  cursor: pointer;
}

.action-btn svg {
  width: 24px;
  height: 24px;
  color: var(--primary);
}

.action-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.action-btn:active {
  transform: translateY(0);
}

/* ─── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 14px var(--s6);
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 600;
  width: 100%;
  transition: all 0.15s;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(249,115,22,0.3);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  padding: var(--s2) var(--s3);
  width: auto;
}

.btn-danger {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(239,68,68,0.2);
}

.btn:active:not(:disabled) { transform: translateY(0) !important; }
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ─── Forms ──────────────────────────────────────────── */
.form-group {
  margin-bottom: var(--s4);
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: var(--s2);
}

.form-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px var(--s4);
  color: var(--text);
  font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-input::placeholder { color: var(--text-3); }
.form-input:read-only    { opacity: 0.6; cursor: default; }

.form-hint {
  font-size: 12px;
  color: var(--text-2);
  margin-top: var(--s2);
}

.form-error-msg {
  font-size: 13px;
  color: var(--error);
  margin-top: var(--s2);
}

/* ─── Section Title ──────────────────────────────────── */
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: var(--s3);
}

/* ─── List Items ─────────────────────────────────────── */
.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.list-item {
  display: flex;
  align-items: center;
  padding: var(--s4);
  border-bottom: 1px solid var(--border);
  gap: var(--s3);
}

.list-item:last-child { border-bottom: none; }

.list-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.list-item-icon.incoming { background: var(--success-bg); }
.list-item-icon.outgoing { background: var(--error-bg);   }
.list-item-icon.pending  { background: var(--warning-bg); }

.list-item-body {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

.list-item-right {
  text-align: right;
  flex-shrink: 0;
}

.list-item-amount {
  font-size: 14px;
  font-weight: 700;
}

.list-item-amount.positive { color: var(--success); }
.list-item-amount.negative { color: var(--error);   }

.list-item-date {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ─── Badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--s2);
  border-radius: var(--r-full);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error   { background: var(--error-bg);   color: var(--error);   }
.badge-info    { background: var(--info-bg);    color: var(--info);    }
.badge-neutral { background: var(--surface-3);  color: var(--text-2);  }

/* ─── Info Box ───────────────────────────────────────── */
.info-box {
  background: var(--info-bg);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: var(--r-md);
  padding: var(--s4);
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}

.warning-box {
  background: var(--warning-bg);
  border: 1px solid rgba(234,179,8,0.2);
  border-radius: var(--r-md);
  padding: var(--s4);
  font-size: 13px;
  color: var(--warning);
  line-height: 1.6;
}

/* ─── Address Box ────────────────────────────────────── */
.address-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s4);
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.address-text {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
  line-height: 1.4;
}

.copy-btn {
  flex-shrink: 0;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--s2) var(--s3);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}

.copy-btn:hover   { background: var(--primary); color: #fff; border-color: var(--primary); }
.copy-btn.copied  { background: var(--success);  color: #fff; border-color: var(--success);  }

/* ─── Empty State ────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s12) var(--s8);
  text-align: center;
  gap: var(--s3);
}

.empty-state-icon { font-size: 40px; }

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.empty-state-sub {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}

/* ─── Toasts ─────────────────────────────────────────── */
#toast-root {
  position: fixed;
  top: calc(var(--header-h) + var(--s2));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - var(--s8));
  max-width: calc(var(--max-w) - var(--s8));
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  pointer-events: none;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--s3);
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease forwards;
  pointer-events: all;
}

.toast.removing { animation: toast-out 0.2s ease forwards; }

.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--error);   }
.toast-warning { border-left: 3px solid var(--warning);  }
.toast-info    { border-left: 3px solid var(--info);    }

@keyframes toast-in  {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0);    }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0);    }
  to   { opacity: 0; transform: translateY(-8px); }
}

/* ─── Spinner ────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Skeleton Loader ────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--surface-2) 25%,
    var(--surface-3) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ─── Auth Page ──────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--s8) var(--s6);
  background: var(--bg);
}

.auth-brand {
  text-align: center;
  margin-bottom: var(--s10);
}

.auth-brand-name {
  font-size: 32px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.04em;
}

.auth-brand-tagline {
  font-size: 14px;
  color: var(--text-2);
  margin-top: var(--s1);
}

.auth-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s1);
  margin-bottom: var(--s6);
  gap: var(--s1);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  color: var(--text-2);
  transition: all 0.15s;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--primary);
  color: #fff;
}

.auth-forgot {
  text-align: right;
  margin-top: var(--s2);
}

.auth-link {
  background: none;
  border: 0;
  padding: 0;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
}

.auth-link:hover { text-decoration: underline; }

.auth-footer {
  text-align: center;
  margin-top: var(--s6);
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.6;
}

/* ─── Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: overlay-in 0.2s ease;
}

.modal-overlay.hidden { display: none; }

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s6);
  padding-bottom: calc(var(--s6) + env(safe-area-inset-bottom));
  width: 100%;
  max-width: var(--max-w);
  animation: modal-in 0.25s ease;
}

@keyframes modal-in {
  from { transform: translateY(100%); }
  to   { transform: translateY(0);    }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: var(--r-full);
  margin: 0 auto var(--s5);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--s5);
}

/* ─── Divider ────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--s4) 0;
}

/* ─── Desktop border ─────────────────────────────────── */
@media (min-width: 480px) {
  .app, .auth-page {
    border-left:  1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}
/* ─── Password show/hide ─────────────────────────────── */
.password-field {
  position: relative;
}

.password-field .form-input {
  padding-right: 72px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: var(--s2);
  transform: translateY(-50%);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.password-toggle:hover { background: var(--surface-3); }
.password-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ─── Call-to-action inside a notice ─────────────────── */
.notice-cta {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  margin-top: var(--s3);
  padding: 8px 16px;
  border-radius: var(--r-md);
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}

.notice-cta::after { content: '→'; }

.notice-cta:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(249,115,22,0.3);
}

.notice-cta:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ─── Payment: QR code, waiting state, hash fallback ─── */
.qr-box {
  text-align: center;
  margin-bottom: var(--s3);
}

.qr-box img {
  display: block;
  margin: 0 auto var(--s2);
  border-radius: var(--r-md);
  background: #fff;     /* QR codes need a light background to scan */
  padding: 6px;
}

.qr-caption {
  font-size: 12px;
  color: var(--text-2);
}

.waiting-box {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  background: var(--info-bg);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: var(--s4);
}

.waiting-box strong { color: var(--text); }

.pulse-dot {
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--info);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: 0.3; transform: scale(0.8); }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-dot { animation: none; }
}

.tx-fallback {
  margin-bottom: var(--s2);
}

.tx-fallback > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  padding: var(--s2) 0;
}

.tx-fallback[open] > summary { margin-bottom: var(--s3); }

/* ─── Intro guide pop-ups ────────────────────────────── */
.tour-shade {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
}

/* The highlighted element: a clear window in a dimmed page */
.tour-spot {
  position: fixed;
  border-radius: var(--r-md);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.65);
  outline: 2px solid var(--primary);
  z-index: 1000;
  pointer-events: none;
  transition: left 0.2s, top 0.2s, width 0.2s, height 0.2s;
}

.tour-pop {
  position: fixed;
  z-index: 1001;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg, 16px);
  padding: var(--s4);
  box-shadow: var(--shadow-md);
}

.tour-count {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 4px;
}

.tour-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.tour-text {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: var(--s4);
}

.tour-nav {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.tour-fill { flex: 1; }

.tour-btn {
  padding: 8px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
}

.tour-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tour-skip { background: transparent; border-color: transparent; color: var(--text-2); padding-left: 0; }
.tour-next { background: var(--primary); border-color: var(--primary); color: #fff; }
.tour-next:hover { background: var(--primary-dark); }

@media (prefers-reduced-motion: reduce) {
  .tour-spot { transition: none; }
}
