/* CoinXpe — Global Stylesheet
   user/css/global.css
   Mobile-first | Bungee headings | Chakra Petch body
   ─────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Bungee&family=Chakra+Petch:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');
@import url('https://unpkg.com/@phosphor-icons/web@2.1.1/src/regular/style.css');
@import url('https://unpkg.com/@phosphor-icons/web@2.1.1/src/bold/style.css');
@import url('https://unpkg.com/@phosphor-icons/web@2.1.1/src/fill/style.css');

/* ── CSS Custom Properties ── */
:root {
  /* Palette */
  --c-bg:           #F8F9FC;
  --c-surface:      #FFFFFF;
  --c-surface-2:    #F1F4FA;
  --c-border:       #E4E9F2;
  --c-border-dark:  #CDD5E0;

  --c-primary:      #1A56DB;
  --c-primary-dark: #1342AF;
  --c-primary-light:#EEF3FF;

  --c-green:        #0CA678;
  --c-green-light:  #E6FAF5;
  --c-red:          #E02D3C;
  --c-red-light:    #FEECEE;
  --c-gold:         #D97706;
  --c-gold-light:   #FEF9EE;
  --c-orange:       #EA580C;

  --c-text-1:       #0F172A;
  --c-text-2:       #475569;
  --c-text-3:       #94A3B8;
  --c-text-inv:     #FFFFFF;

  /* Typography */
  --font-head:      'Bungee', sans-serif;
  --font-body:      'Chakra Petch', sans-serif;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* Radius */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  16px;
  --r-xl:  20px;
  --r-full: 9999px;

  /* Shadow */
  --sh-sm:  0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --sh-md:  0 4px 16px rgba(15,23,42,.08);
  --sh-lg:  0 8px 32px rgba(15,23,42,.12);

  /* Transitions */
  --ease: cubic-bezier(.4,0,.2,1);
  --dur:  180ms;

  /* Layout */
  --nav-h:   60px;
  --head-h:  56px;
  --max-w:   430px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--c-text-1);
  background: var(--c-bg);
  min-height: 100dvh;
  max-width: var(--max-w);
  margin: 0 auto;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Disable zoom on inputs (iOS) */
input, select, textarea {
  font-size: 16px;
  font-family: var(--font-body);
}

/* ── Typography ── */
.h-bungee     { font-family: var(--font-head); letter-spacing: .02em; }
.text-xs      { font-size: 11px; line-height: 1.4; }
.text-sm      { font-size: 13px; }
.text-base    { font-size: 14px; }
.text-md      { font-size: 16px; }
.text-lg      { font-size: 18px; }
.text-xl      { font-size: 22px; }
.text-2xl     { font-size: 26px; }
.font-medium  { font-weight: 500; }
.font-semibold{ font-weight: 600; }
.font-bold    { font-weight: 700; }
.text-muted   { color: var(--c-text-2); }
.text-faint   { color: var(--c-text-3); }
.text-green   { color: var(--c-green); }
.text-red     { color: var(--c-red); }
.text-primary { color: var(--c-primary); }
.text-gold    { color: var(--c-gold); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.mono         { font-variant-numeric: tabular-nums; }

/* ── Layout Utilities ── */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1        { gap: var(--sp-1); }
.gap-2        { gap: var(--sp-2); }
.gap-3        { gap: var(--sp-3); }
.gap-4        { gap: var(--sp-4); }
.w-full       { width: 100%; }
.grow         { flex: 1; }

/* ── Page Wrapper ── */
.page-wrap {
  padding: var(--head-h) var(--sp-4) calc(var(--nav-h) + 16px);
  min-height: 100dvh;
}

.page-wrap--no-header { padding-top: var(--sp-4); }
.page-wrap--no-nav    { padding-bottom: var(--sp-8); }

/* ── Card ── */
.card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  border: 1px solid var(--c-border);
  overflow: hidden;
}

.card__body { padding: var(--sp-4); }
.card__header {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 12px 20px;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: .01em;
}

.btn:disabled {
  opacity: .5;
  pointer-events: none;
}

.btn--primary {
  background: var(--c-primary);
  color: var(--c-text-inv);
}
.btn--primary:active { background: var(--c-primary-dark); transform: scale(.98); }

.btn--green {
  background: var(--c-green);
  color: #fff;
}
.btn--green:active { filter: brightness(.92); transform: scale(.98); }

.btn--red {
  background: var(--c-red);
  color: #fff;
}
.btn--red:active { filter: brightness(.92); transform: scale(.98); }

.btn--outline {
  background: transparent;
  border: 1.5px solid var(--c-border-dark);
  color: var(--c-text-1);
}
.btn--outline:active { background: var(--c-surface-2); }

.btn--ghost {
  background: transparent;
  color: var(--c-primary);
  padding: 8px 12px;
}

.btn--sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: var(--r-sm);
}

.btn--full { width: 100%; }

.btn--pill { border-radius: var(--r-full); }

/* ── Inputs ── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.input-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-2);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.input {
  width: 100%;
  padding: 12px 14px;
  background: var(--c-surface-2);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  color: var(--c-text-1);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  outline: none;
}

.input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.input--error { border-color: var(--c-red) !important; }

.input-addon {
  position: relative;
}
.input-addon .input { padding-right: 60px; }
.input-addon__label {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-2);
  pointer-events: none;
}

/* ── Badge / Chip ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.badge--green  { background: var(--c-green-light);  color: var(--c-green);  }
.badge--red    { background: var(--c-red-light);    color: var(--c-red);    }
.badge--gold   { background: var(--c-gold-light);   color: var(--c-gold);   }
.badge--blue   { background: var(--c-primary-light);color: var(--c-primary);}
.badge--gray   { background: var(--c-surface-2);    color: var(--c-text-2); }

/* ── Divider ── */
.divider {
  width: 100%;
  height: 1px;
  background: var(--c-border);
  margin: var(--sp-3) 0;
}

.divider--label {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--c-text-3);
  font-size: 12px;
  font-weight: 500;
}
.divider--label::before,
.divider--label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

/* ── List Row ── */
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-border);
}
.list-row:last-child { border-bottom: none; }

/* ── Header ── */
.cxp-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w);
  height: var(--head-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-4);
  z-index: 100;
  box-shadow: var(--sh-sm);
}

.cxp-logo {
  font-family: var(--font-head);
  font-size: 18px;
  color: var(--c-primary);
  letter-spacing: .03em;
}

.cxp-logo span { color: var(--c-text-1); }

/* ── 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(--c-surface);
  border-top: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(15,23,42,.06);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 0;
  color: var(--c-text-3);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active { color: var(--c-primary); }

.nav-item__icon { font-size: 22px; line-height: 1; }
.nav-item__label { font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

/* ── Tab Bar ── */
.tab-bar {
  display: flex;
  background: var(--c-surface-2);
  border-radius: var(--r-full);
  padding: 3px;
  gap: 2px;
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-2);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.tab-item.active {
  background: var(--c-surface);
  color: var(--c-primary);
  box-shadow: var(--sh-sm);
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: calc(var(--head-h) + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: calc(var(--max-w) - 32px);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  box-shadow: var(--sh-lg);
  animation: toastIn .25s var(--ease) forwards;
  pointer-events: all;
  border: 1px solid transparent;
}

.toast--success {
  background: var(--c-green-light);
  border-color: #9FEDD7;
  color: #065F46;
}

.toast--error {
  background: var(--c-red-light);
  border-color: #FCA5A5;
  color: #991B1B;
}

.toast--info {
  background: var(--c-primary-light);
  border-color: #BFDBFE;
  color: #1E3A8A;
}

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

/* ── Amount Display ── */
.amount-display {
  font-family: var(--font-body);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.amount-display--lg { font-size: 28px; }
.amount-display--xl { font-size: 36px; }

/* ── Rate Ticker ── */
.rate-ticker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
}

.rate-ticker__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ── Section Title ── */
.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-3);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: var(--sp-3);
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
  gap: var(--sp-3);
}

.empty-state__icon {
  font-size: 48px;
  color: var(--c-text-3);
  margin-bottom: var(--sp-2);
}

.empty-state__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--c-text-2);
}

.empty-state__desc {
  font-size: 13px;
  color: var(--c-text-3);
  line-height: 1.6;
}

/* ── Bottom Sheet ── */
.bs-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);
  backdrop-filter: blur(2px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease);
}

.bs-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: var(--max-w);
  background: var(--c-surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  z-index: 201;
  transition: transform .3s var(--ease);
  max-height: 90dvh;
  overflow-y: auto;
}

.bottom-sheet.open {
  transform: translateX(-50%) translateY(0);
}

.bs-handle {
  width: 36px;
  height: 4px;
  background: var(--c-border-dark);
  border-radius: var(--r-full);
  margin: 10px auto 0;
}

.bs-header {
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--c-border);
}

.bs-title {
  font-family: var(--font-head);
  font-size: 16px;
  color: var(--c-text-1);
}

.bs-close {
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  background: var(--c-surface-2);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-2);
  font-size: 18px;
}

.bs-body { padding: var(--sp-4); }

/* ── Utility ── */
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.p-4  { padding: var(--sp-4); }

.rounded-full { border-radius: var(--r-full); }
.border-top   { border-top: 1px solid var(--c-border); }
.border-bottom{ border-bottom: 1px solid var(--c-border); }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-2);
  font-size: 18px;
  transition: all var(--dur) var(--ease);
}

.icon-btn:active { background: var(--c-border); }

/* ── Safe area bottom ── */
.safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }
