/* ============================================================
   RMG — base.css
   Shared design tokens, resets, and component styles used
   across all pages. Page-specific styles stay in <style> tags.
   ============================================================ */

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

/* ── DESIGN TOKENS ── */
:root {
  /* Colours */
  --forest:   #1b3d2a;
  --forest2:  #2c6243;
  --sage:     #7ec8a0;
  --sage-dim: rgba(126,200,160,0.12);
  --black:    #0c0c0c;
  --ink:      #1c1c1c;
  --white:    #ffffff;
  --cream:    #f9f8f5;
  --cream2:   #f3f2ef;
  --mist:     #eceae6;
  --mid:      #595959;
  --dim:      #8c8c8c;
  --hairline: rgba(0,0,0,0.08);
  --danger:   #c0392b;
  --green:    #2c9e5a;
  --green-bg: #eaf6ee;
  --red:      #c0392b;
  --red-bg:   #fdecea;

  /* Typography */
  --serif: 'Libre Baskerville', Georgia, serif;
  --body:  -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --mono:  'Courier New', monospace;

  /* Layout */
  --sidebar: 240px;
}

/* ── BASE HTML ── */
html { -webkit-font-smoothing: antialiased; }
a    { color: inherit; text-decoration: none; }
img  { display: block; max-width: 100%; }

/* ============================================================
   AUTH PAGES  (login, register, register_key, register_key_validation)
   Shared card layout with background image
   ============================================================ */
.auth-body {
  font-family: var(--body);
  min-height: 100vh;
  margin: 0;
  padding: 64px 20px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  background: #000;
}
.auth-bg {
  position: fixed; inset: 0;
  background-image: url('https://images.pexels.com/photos/1366919/pexels-photo-1366919.jpeg?auto=compress&cs=tinysrgb&w=1600&q=85');
  background-size: cover; background-position: center;
  filter: brightness(0.5) saturate(1.3); z-index: 0;
}
.auth-bg-tint {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, rgba(10,28,18,0.55) 0%, rgba(27,61,42,0.3) 100%);
  z-index: 1;
}
.auth-card {
  position: relative; z-index: 2;
  background: #fff;
  border-radius: 24px;
  padding: 36px 28px 32px;
  width: 100%; max-width: 420px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.4);
}
.auth-card.wide { max-width: 480px; }
.auth-card.wider { max-width: 460px; }

.auth-logo { margin-bottom: 20px; }
.auth-logo img { height: 40px; width: auto; display: block; }

.auth-divider {
  border: none; border-top: 0.5px solid var(--hairline);
  margin: 0 0 28px;
}
.auth-divider.tight { margin: 0 0 24px; }

.auth-title {
  font-family: var(--serif); font-size: 22px; font-weight: 700;
  color: var(--ink); letter-spacing: -0.02em; margin-bottom: 5px;
}
.auth-sub { font-size: 13px; color: var(--mid); margin-bottom: 28px; line-height: 1.5; }
.auth-sub.spaced { margin-bottom: 24px; }

/* ── Auth field ── */
.auth-field { margin-bottom: 16px; }
.auth-field label {
  display: block; font-size: 11px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--dim); margin-bottom: 6px;
}
.auth-field input {
  width: 100%; background: #fff;
  border: 1.5px solid #d8d5d0; border-radius: 10px;
  padding: 12px 14px; font-family: var(--body);
  font-size: 15px; color: var(--ink); outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  -webkit-appearance: none; appearance: none;
}
.auth-field input::placeholder { color: #c4c1bc; }
.auth-field input:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(27,61,42,0.09);
}
.auth-field input.input-error { border-color: var(--danger); }
.auth-field input.input-error:focus {
  box-shadow: 0 0 0 3px rgba(192,57,43,0.09);
}
.auth-field .field-error {
  display: none; margin-top: 5px;
  font-size: 11px; color: var(--danger); line-height: 1.4;
}
.auth-field .field-error.visible { display: block; }

/* ── Two-col row ── */
.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Auth button ── */
.auth-btn {
  width: 100%; height: 50px;
  background: var(--forest); color: #fff;
  border: none; border-radius: 10px;
  font-family: var(--body); font-size: 13px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer; transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 24px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.auth-btn:hover:not(:disabled) { background: var(--forest2); }
.auth-btn:disabled { opacity: 0.45; pointer-events: none; }

/* ── Loading spinner inside button ── */
.btn-spinner {
  display: none; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-spinner.visible { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Auth bottom links ── */
.auth-divider2 { border: none; border-top: 0.5px solid var(--hairline); margin: 0 0 20px; }
.auth-link-row { text-align: center; font-size: 13px; color: var(--dim); }
.auth-link-row a { color: var(--forest); font-weight: 600; text-decoration: none; }
.auth-link-row a:hover { text-decoration: underline; }

/* ── Secure badge ── */
.auth-secure {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; margin-top: 16px; font-size: 11px; color: #c0bdb8;
}
.auth-secure svg {
  width: 11px; height: 11px; stroke: var(--sage); fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}

/* ── Auth notice ── */
.auth-notice {
  margin-top: 16px; font-size: 11px;
  color: #c0bdb8; text-align: center; line-height: 1.6;
}

/* ── Auth forgot ── */
.auth-forgot { text-align: right; margin-top: -4px; margin-bottom: 24px; }
.auth-forgot a { font-size: 12px; color: var(--forest2); text-decoration: none; }
.auth-forgot a:hover { text-decoration: underline; }

/* ── Global form error banner ── */
.form-error-banner {
  display: none;
  background: #fdf3f2; border: 1px solid #e8b4b0;
  border-radius: 10px; padding: 12px 16px; margin-bottom: 20px;
  font-size: 12px; color: var(--danger); line-height: 1.6;
  align-items: flex-start; gap: 10px;
}
.form-error-banner.visible { display: flex; }
.form-error-banner svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }

/* ============================================================
   APP PAGES  (dashboard, deposit, withdraw, profile, etc.)
   Shared sidebar layout
   ============================================================ */
.app-body {
  background: var(--cream2);
  font-family: var(--body);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
}

.main {
  margin-left: var(--sidebar);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--hairline);
  padding: 0 36px; height: 60px;
  display: flex; align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left  { display: flex; flex-direction: column; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-title {
  font-family: var(--serif); font-size: 17px; font-weight: 700;
  color: var(--ink); letter-spacing: -0.01em;
}
.topbar-date {
  font-family: var(--mono); font-size: 10px;
  color: var(--dim); letter-spacing: 0.08em; margin-top: 1px;
}

/* ── Hamburger (mobile) ── */
.hamburger {
  display: none; width: 34px; height: 34px;
  border: 1px solid var(--mist); border-radius: 4px;
  background: transparent; cursor: pointer;
  align-items: center; justify-content: center; flex-shrink: 0;
  -webkit-appearance: none; appearance: none; color: var(--ink);
}
.hamburger svg { stroke: var(--ink); display: block; }

/* ── Main content area ── */
.content {
  padding: 28px 36px;
  display: flex; flex-direction: column; gap: 24px; flex: 1;
}

/* ── Panel (white card) ── */
.panel { background: var(--white); border: 1px solid var(--hairline); border-radius: 4px; }
.panel-head {
  padding: 18px 22px; border-bottom: 1px solid var(--hairline);
  display: flex; justify-content: space-between; align-items: center;
}
.panel-title {
  font-family: var(--serif); font-size: 15px; font-weight: 700;
  color: var(--ink); letter-spacing: -0.01em;
}
.panel-link {
  font-size: 12px; color: var(--forest2);
  text-decoration: none; cursor: pointer;
  background: none; border: none; font-family: var(--body);
}
.panel-link:hover { text-decoration: underline; }
.panel-body { padding: 24px 22px; display: flex; flex-direction: column; gap: 22px; }

/* ── Topbar action button ── */
.topbar-btn {
  height: 34px; padding: 0 18px;
  background: var(--forest); color: #fff;
  font-family: var(--body); font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; border: none; border-radius: 2px;
  cursor: pointer; transition: background 0.2s;
  white-space: nowrap; text-decoration: none;
  display: inline-flex; align-items: center;
}
.topbar-btn:hover { background: var(--forest2); }

/* ── Form field (app pages) ── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label {
  font-family: var(--body); font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim);
}
.field-hint  { font-size: 11px; color: var(--dim); line-height: 1.5; }
.field-error-msg {
  display: none; font-size: 11px;
  color: var(--danger); line-height: 1.4;
}
.field-error-msg.visible { display: block; }

.field-input {
  width: 100%; background: transparent; border: none;
  border-bottom: 1.5px solid #d0cec9; border-radius: 0;
  padding: 10px 0; font-family: var(--body); font-size: 14px;
  color: var(--ink); outline: none; transition: border-color 0.2s;
}
.field-input::placeholder { color: #c8c5c0; }
.field-input:focus        { border-bottom-color: var(--forest); }
.field-input.error        { border-bottom-color: var(--danger); }

/* ── Amount row ── */
.amount-row {
  display: flex; border: 1.5px solid #d0cec9;
  border-radius: 2px; overflow: hidden; transition: border-color 0.2s;
}
.amount-row:focus-within { border-color: var(--forest); }
.amount-row.error        { border-color: var(--danger); }
.amount-prefix {
  padding: 0 14px; font-family: var(--mono); font-size: 14px;
  color: var(--dim); background: var(--cream);
  border-right: 1px solid var(--hairline);
  height: 48px; display: flex; align-items: center; flex-shrink: 0;
}
.amount-input {
  flex: 1; border: none; outline: none; padding: 0 16px;
  font-size: 16px; font-weight: 600; color: var(--ink);
  background: var(--white); height: 48px; font-family: var(--body);
}
.amount-input::placeholder { color: #c8c5c0; font-weight: 400; }

/* ── Warning box ── */
.min-warning {
  padding: 10px 12px; background: #fff8e6;
  border: 1px solid #f0d070; border-radius: 3px;
  font-size: 11px; color: #7a5a00; line-height: 1.6; display: none;
}
.min-warning.visible { display: block; }

/* ── Primary action button (app pages) ── */
.primary-btn {
  height: 48px; padding: 0 32px;
  background: var(--forest); color: #fff; border: none; border-radius: 2px;
  font-family: var(--body); font-size: 13px; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  cursor: pointer; transition: background 0.2s;
  display: inline-flex; align-items: center; gap: 8px;
}
.primary-btn:hover:not(:disabled) { background: var(--forest2); }
.primary-btn:disabled             { opacity: 0.4; cursor: not-allowed; }
.primary-btn.full                 { width: 100%; justify-content: center; }

/* ── Back button ── */
.back-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--dim);
  padding: 0; transition: color 0.15s;
}
.back-btn:hover { color: var(--ink); }
.back-btn svg   { stroke: currentColor; }

/* ── Nav row ── */
.nav-row {
  display: flex; align-items: center;
  justify-content: space-between; gap: 16px; padding-top: 4px;
}

/* ── Success / Pending overlay ── */
.success-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); z-index: 500;
  align-items: center; justify-content: center; padding: 20px;
}
.success-overlay.visible { display: flex; }
.success-card {
  background: var(--white); border-radius: 6px;
  padding: 40px 36px; max-width: 440px; width: 100%;
  text-align: center;
  animation: popIn 0.32s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes popIn { from { transform: scale(0.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.success-icon {
  width: 60px; height: 60px; background: rgba(27,61,42,0.07);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; margin: 0 auto 20px;
}
.success-title {
  font-family: var(--serif); font-size: 22px; font-weight: 700;
  color: var(--ink); margin-bottom: 10px; letter-spacing: -0.01em;
}
.success-sub   { font-size: 13px; color: var(--mid); line-height: 1.7; margin-bottom: 24px; }
.success-ref {
  font-family: var(--mono); font-size: 11px;
  background: var(--cream); border: 1px solid var(--hairline);
  border-radius: 3px; padding: 10px 14px;
  color: var(--dim); margin-bottom: 24px;
}
.success-ref span { color: var(--ink); font-weight: 700; }
.success-btns { display: flex; gap: 10px; }
.success-btn-primary {
  flex: 1; height: 44px; background: var(--forest); color: #fff;
  border: none; border-radius: 2px; font-size: 12px; font-weight: 700;
  letter-spacing: 0.06em; cursor: pointer; transition: background 0.2s;
  text-decoration: none; display: flex; align-items: center; justify-content: center;
}
.success-btn-primary:hover { background: var(--forest2); }
.success-btn-ghost {
  flex: 1; height: 44px; background: transparent;
  color: var(--forest); border: 1px solid var(--mist);
  border-radius: 2px; font-size: 12px; font-weight: 700;
  letter-spacing: 0.06em; cursor: pointer; transition: all 0.2s;
}
.success-btn-ghost:hover { border-color: var(--forest); }

/* ── Pending badge ── */
.pending-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff8e6; border: 1px solid #f0d070;
  border-radius: 2px; padding: 5px 12px;
  font-family: var(--mono); font-size: 10px;
  color: #7a5a00; margin-bottom: 16px;
}
.pending-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #e6a817; animation: pulse 1.4s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── Empty state ── */
.empty-state {
  padding: 48px 22px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-icon {
  width: 48px; height: 48px; background: var(--cream2);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.empty-title { font-family: var(--serif); font-size: 15px; font-weight: 700; color: var(--ink); }
.empty-sub   { font-size: 12px; color: var(--dim); line-height: 1.6; max-width: 200px; }
.empty-btn {
  margin-top: 4px; height: 36px; padding: 0 20px;
  background: var(--forest); color: #fff; border: none; border-radius: 2px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; transition: background 0.2s;
}
.empty-btn:hover { background: var(--forest2); }

/* ── Grid helpers ── */
.grid-2   { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3-1 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }

/* ── Wallet display box ── */
.wallet-box {
  background: var(--cream); border: 1px solid var(--hairline);
  border-radius: 3px; padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.wallet-addr {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink); word-break: break-all; line-height: 1.6;
}
.copy-btn {
  flex-shrink: 0; padding: 7px 14px;
  border: 1px solid var(--mist); border-radius: 2px;
  background: var(--white); font-size: 11px; font-weight: 600;
  color: var(--forest); cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.copy-btn:hover  { border-color: var(--forest); background: rgba(27,61,42,0.04); }
.copy-btn.copied { color: var(--sage); border-color: var(--sage); }

/* ── Coin selector (deposit / withdraw) ── */
.coin-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.coin-opt {
  border: 1px solid var(--mist); border-radius: 3px;
  padding: 12px 16px; cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; background: none;
}
.coin-opt:hover    { border-color: rgba(27,61,42,0.3); background: var(--cream); }
.coin-opt.selected { border-color: var(--forest); background: rgba(27,61,42,0.04); }
.coin-sym     { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--ink); }
.coin-network { font-size: 10px; color: var(--dim); }

/* ── Network selector ── */
.network-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.net-opt {
  border: 1px solid var(--mist); border-radius: 3px;
  padding: 8px 16px; cursor: pointer; transition: all 0.15s;
  font-family: var(--body); font-size: 11px; font-weight: 600;
  color: var(--mid); background: none;
}
.net-opt:hover    { border-color: rgba(27,61,42,0.3); }
.net-opt.selected { border-color: var(--forest); background: rgba(27,61,42,0.04); color: var(--forest); }

/* ── Notice box ── */
.notice-box {
  background: rgba(27,61,42,0.04); border: 1px solid rgba(27,61,42,0.1);
  border-radius: 3px; padding: 12px 14px;
  font-size: 11px; color: var(--mid); line-height: 1.7;
}

/* ── Status badges ── */
.badge {
  display: inline-block; font-family: var(--mono); font-size: 10px;
  font-weight: 600; padding: 3px 8px; border-radius: 2px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.badge-pending  { background: #fff8e6; color: #b8860b; }
.badge-done     { background: var(--green-bg); color: var(--green); }
.badge-failed   { background: var(--red-bg); color: var(--red); }
.badge-active   { background: var(--sage-dim); color: var(--forest); }

/* ============================================================
   RESPONSIVE — shared breakpoints
   ============================================================ */
@media (max-width: 768px) {
  .hamburger  { display: flex; }
  .main       { margin-left: 0; }
  .topbar     { padding: 0 16px; }
  .topbar-date { display: none; }
  .content    { padding: 16px; gap: 16px; }
  .panel-body { padding: 18px 16px; gap: 18px; }
  .panel-head { padding: 14px 16px; }
  .grid-2, .grid-3-1 { grid-template-columns: 1fr; }
  .auth-body  { padding: 52px 16px 40px; }
  .auth-card  { padding: 28px 20px 28px; border-radius: 20px; }
  .auth-title { font-size: 20px; }
  .auth-sub   { margin-bottom: 20px; }
  .auth-logo img { height: 36px; }
  .auth-btn   { height: 48px; margin-bottom: 20px; }
}
@media (max-width: 480px) {
  .auth-row { grid-template-columns: 1fr; gap: 0; }
}
