/* ─────────────────────────────────────────────────────────────────────────────
   Alliance Crypto — shared design system
   Tokens · reset · buttons · fields · badges · alerts · modal · toast · skeleton
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  --bg:         #f5f4fa;
  --surface:    #ffffff;
  --surface-2:  #faf9fd;
  --surface-3:  #f1eff8;
  --line:       #e8e5f1;
  --line-2:     #d9d5e8;

  --ink:        #15111f;
  --ink-2:      #47425a;
  --ink-3:      #6d6884;
  --ink-4:      #a29ebb;

  --brand:      #ec0e8c;
  --brand-600:  #d10a7b;
  --brand-700:  #a50762;
  --brand-50:   #fff1f9;
  --brand-100:  #fde2f1;
  --brand-200:  #fbc4e2;
  --brand-ring: rgba(236, 14, 140, .2);

  --hero:       #0f0b17;

  --ok:         #0f9d63;
  --ok-bg:      #e5f7ee;
  --warn:       #a96300;
  --warn-bg:    #fff2d9;
  --danger:     #d92b52;
  --danger-bg:  #fdebef;

  --font:         'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --mono:         'JetBrains Mono', ui-monospace, Consolas, monospace;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 24px;

  --sh-1: 0 1px 2px rgba(21, 17, 31, .05), 0 1px 1px rgba(21, 17, 31, .03);
  --sh-2: 0 4px 14px rgba(21, 17, 31, .07), 0 1px 3px rgba(21, 17, 31, .05);
  --sh-3: 0 24px 60px rgba(21, 17, 31, .18), 0 4px 14px rgba(21, 17, 31, .08);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.02em; line-height: 1.15; }

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
img, svg, video { display: block; max-width: 100%; }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.input:focus-visible, .select:focus-visible { outline: none; }

.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--r);
  font-size: 14.5px; font-weight: 600; line-height: 1; white-space: nowrap;
  user-select: none; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .08s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-loading { cursor: not-allowed; }
.btn[disabled] { opacity: .55; transform: none; }

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #f0159a, #dc0a81);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 6px 16px -6px rgba(236, 14, 140, .6);
}
.btn-primary:hover:not([disabled]) { background: linear-gradient(180deg, #e8108f, #c9087a); }

.btn-secondary {
  color: var(--ink-2); background: var(--surface);
  border-color: var(--line-2); box-shadow: var(--sh-1);
}
.btn-secondary:hover:not([disabled]) { background: var(--surface-2); border-color: var(--ink-4); color: var(--ink); }

.btn-ghost { color: var(--ink-3); }
.btn-ghost:hover:not([disabled]) { background: var(--surface-3); color: var(--ink); }

.btn-danger { color: var(--danger); background: var(--danger-bg); border-color: #f6c8d2; }
.btn-danger:hover:not([disabled]) { color: #fff; background: var(--danger); border-color: var(--danger); }

.btn-sm { height: 34px; padding: 0 13px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after, .btn-danger.is-loading::after {
  border-color: var(--line-2); border-top-color: var(--brand);
}

/* ─── Fields ───────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }

.input, .select {
  width: 100%; height: 44px; padding: 0 14px;
  font-size: 15px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: var(--ink-4); }
.input:hover, .select:hover { border-color: var(--ink-4); }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); outline: none; }
.input:disabled, .select:disabled { background: var(--surface-3); color: var(--ink-3); cursor: not-allowed; }

.select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236d6884' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.select-sm { height: 34px; padding-left: 10px; font-size: 13px; border-radius: 10px; background-position: right 9px center; padding-right: 30px; }

.input-wrap { position: relative; }
.input-wrap > .input { padding-right: 48px; }
.input-wrap.has-lead > .input { padding-left: 42px; padding-right: 14px; }
.input-wrap.has-lead.has-action > .input { padding-right: 48px; }
.input-wrap > .lead {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ink-4); pointer-events: none;
}
.input-wrap > .input-action {
  position: absolute; right: 4px; top: 4px; width: 36px; height: 36px;
  display: grid; place-items: center; border-radius: 9px; color: var(--ink-3);
}
.input-wrap > .input-action:hover { background: var(--surface-3); color: var(--ink); }

/* ─── Badges / alerts ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap;
  color: var(--ink-2); background: var(--surface-3);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok    { color: #0a7a4c; background: var(--ok-bg); }
.badge-warn  { color: var(--warn); background: var(--warn-bg); }
.badge-brand { color: var(--brand-700); background: var(--brand-100); }
.badge-danger{ color: var(--danger); background: var(--danger-bg); }

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border: 1px solid; border-radius: var(--r);
  font-size: 13.5px; line-height: 1.45;
}
.alert .icon { margin-top: 1px; width: 18px; height: 18px; }
.alert-error   { color: #a81d3f; background: var(--danger-bg); border-color: #f6c8d2; }
.alert-success { color: #0a6f45; background: var(--ok-bg);     border-color: #b6e5cf; }
.alert-info    { color: var(--brand-700); background: var(--brand-50); border-color: var(--brand-100); }

/* ─── Toasts ───────────────────────────────────────────────────────────────── */
#toasts {
  position: fixed; z-index: 500; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
  width: 360px; max-width: calc(100vw - 32px); pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 14px; border-radius: var(--r);
  color: #fff; background: #1d1829; box-shadow: var(--sh-3);
  font-size: 14px; line-height: 1.4; pointer-events: auto;
  animation: toastIn .25s cubic-bezier(.2, .8, .2, 1);
}
.toast .icon { margin-top: 1px; width: 18px; height: 18px; }
.toast-success .icon { color: #4ade9a; }
.toast-error .icon { color: #ff7a96; }
.toast-info .icon { color: #ff7cc6; }
.toast-action { flex: none; align-self: center; margin-left: auto; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; color: #fff; background: rgba(255, 255, 255, .14); }
.toast-action:hover { background: rgba(255, 255, 255, .24); }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }

/* ─── Modal ────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 400;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(15, 11, 23, .5); backdrop-filter: blur(3px);
  animation: fade .15s ease;
}
.modal {
  width: 100%; max-width: 460px; max-height: calc(100dvh - 40px); overflow: auto;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--sh-3);
  animation: pop .2s cubic-bezier(.2, .8, .2, 1);
}
.modal-head { padding: 24px 24px 4px; }
.modal-head h3 { font-size: 19px; }
.modal-sub { margin-top: 6px; font-size: 14px; color: var(--ink-3); line-height: 1.5; }
.modal-body { display: flex; flex-direction: column; gap: 16px; padding: 16px 24px 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 20px 24px 24px; }

/* ─── Skeleton ─────────────────────────────────────────────────────────────── */
.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-3) 25%, #f9f8fd 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

/* ─── Motion ───────────────────────────────────────────────────────────────── */
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes fade    { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop     { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ─── Touch ergonomics ─────────────────────────────────────────────────────── */
@media (pointer: coarse) {
  .btn { height: 46px; }
  .btn-sm { height: 40px; }
  .btn-icon { width: 46px; }
  .btn-icon.btn-sm { width: 40px; }
  .select-sm { height: 40px; }
}
@media (max-width: 560px) {
  .input, .select { font-size: 16px; } /* stops iOS zooming on focus */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); animation: sheet .25s cubic-bezier(.2, .8, .2, 1); }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
