/* ================= APEX CRYPTO — UI LAYER =================
   Base styles and the small component set every page is built from. Tokens live in
   theme.css; Tailwind (apex-tw.js) handles layout. Component classes are prefixed ax-.

   Type: IBM Plex Sans (Latin + Cyrillic), IBM Plex Sans Arabic for Arabic, IBM Plex Mono
   for prices and amounts only. One family in three scripts keeps EN / RU / AR consistent. */

/* ---------------------------------------------------------------- base */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: rgb(var(--c-canvas));
  color: rgb(var(--c-body));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
html[lang="ar"] body,
html[dir="rtl"] body { font-family: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif; }

.font-mono, .ax-num { font-variant-numeric: tabular-nums; letter-spacing: 0; }
html[lang="ar"] .font-mono { font-family: "IBM Plex Mono", "IBM Plex Sans Arabic", ui-monospace, monospace; }

::selection { background: rgb(var(--c-accent) / .18); }

:focus-visible { outline: 2px solid rgb(var(--c-accent)); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* every field on the site, including ones scripts build, gets the same focus treatment */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):focus,
select:focus, textarea:focus {
  border-color: rgb(var(--c-accent)) !important;
  box-shadow: 0 0 0 3px rgb(var(--c-accent) / .16);
  outline: none;
}
input[type="checkbox"], input[type="radio"] { accent-color: rgb(var(--c-accent)); }
input::placeholder, textarea::placeholder { color: rgb(var(--c-muted) / .8); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgb(var(--c-line-strong)); border-radius: 8px; border: 2px solid rgb(var(--c-canvas)); }
::-webkit-scrollbar-thumb:hover { background: rgb(var(--c-muted)); }

/* calmer versions of effects older markup (and script-built rows) still carry */
.animate-bounce { animation: none !important; }
.animate-ping { animation: ax-live 1.8s ease-in-out infinite !important; }
.btn-glow-up { animation: none !important; }
@keyframes ax-live { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

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

/* ---------------------------------------------------------------- icons */
.ax-icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ax-icon-sm { width: 16px; height: 16px; }
.ax-icon-lg { width: 22px; height: 22px; }
html[dir="rtl"] .ax-flip { transform: scaleX(-1); }

/* ---------------------------------------------------------------- header */
.ax-header {
  position: sticky; top: 0; z-index: 40;
  background: rgb(var(--c-surface) / .9);
  -webkit-backdrop-filter: saturate(1.5) blur(12px);
  backdrop-filter: saturate(1.5) blur(12px);
  border-bottom: 1px solid rgb(var(--c-line));
}
.ax-header-inner {
  max-width: 1600px; margin: 0 auto; height: 64px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
@media (min-width: 640px) { .ax-header-inner { padding: 0 24px; } }

.ax-logo { display: inline-flex; align-items: center; gap: 10px; color: rgb(var(--c-ink)); text-decoration: none; flex-shrink: 0; }
.ax-logo-mark { width: 32px; height: 32px; flex-shrink: 0; color: rgb(var(--c-accent)); }
.ax-logo-word { display: flex; flex-direction: column; line-height: 1; }
.ax-logo-name { font-size: 17px; font-weight: 700; letter-spacing: .04em; color: rgb(var(--c-ink)); white-space: nowrap; }
.ax-logo-name b { font-weight: 700; }
.ax-logo-name span { font-weight: 400; color: rgb(var(--c-muted)); }
.ax-logo-tag { font-size: 11px; color: rgb(var(--c-muted)); margin-top: 4px; white-space: nowrap; }

.ax-nav { display: flex; align-items: center; gap: 2px; }
.ax-nav-link {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  border-radius: 8px; font-size: 14px; font-weight: 500; white-space: nowrap;
  color: rgb(var(--c-body)); transition: background-color .15s, color .15s;
}
.ax-nav-link:hover { color: rgb(var(--c-ink)); background: rgb(var(--c-raised)); }
.ax-nav-link.is-active, .ax-nav-link[aria-current="page"] { color: rgb(var(--c-accent)); background: rgb(var(--c-accent-soft)); font-weight: 600; }

/* ---------------------------------------------------------------- buttons */
.ax-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
  text-decoration: none; user-select: none;
}
.ax-btn:disabled, .ax-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.ax-btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; gap: 6px; }
.ax-btn-lg { height: 48px; padding: 0 20px; font-size: 15px; }
.ax-btn-xl { height: 56px; padding: 0 22px; font-size: 16px; border-radius: 12px; }
.ax-btn-block { width: 100%; }

.ax-btn-primary { background: rgb(var(--c-accent)); color: rgb(var(--c-on-accent)); box-shadow: 0 1px 0 rgb(255 255 255 / .12) inset, var(--shadow-1); }
.ax-btn-primary:hover { background: rgb(var(--c-accent-hover)); }
.ax-btn-secondary { background: rgb(var(--c-surface)); color: rgb(var(--c-ink)); border-color: rgb(var(--c-line-strong)); box-shadow: var(--shadow-1); }
.ax-btn-secondary:hover { background: rgb(var(--c-raised)); }
.ax-btn-ghost { background: transparent; color: rgb(var(--c-body)); }
.ax-btn-ghost:hover { background: rgb(var(--c-raised)); color: rgb(var(--c-ink)); }
.ax-btn-up { background: rgb(var(--c-up)); color: #fff; }
.ax-btn-up:hover { background: rgb(var(--c-up-hover)); }
.ax-btn-down { background: rgb(var(--c-down)); color: #fff; }
.ax-btn-down:hover { background: rgb(var(--c-down-hover)); }
.ax-btn-gold { background: rgb(var(--c-gold)); color: #fff; }
.ax-btn-gold:hover { background: rgb(var(--c-gold-hover)); }
.ax-btn-danger { background: transparent; color: rgb(var(--c-down)); border-color: rgb(var(--c-down) / .4); }
.ax-btn-danger:hover { background: rgb(var(--c-down) / .08); }

.ax-icon-btn {
  width: 36px; height: 36px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid rgb(var(--c-line)); background: rgb(var(--c-surface));
  color: rgb(var(--c-body)); transition: background-color .15s, color .15s; cursor: pointer;
}
.ax-icon-btn:hover { background: rgb(var(--c-raised)); color: rgb(var(--c-ink)); }

.ax-link { color: rgb(var(--c-accent)); font-weight: 500; text-decoration: none; }
.ax-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- surfaces */
.ax-page { max-width: 1600px; margin: 0 auto; width: 100%; padding: 20px 16px 48px; }
@media (min-width: 640px) { .ax-page { padding: 28px 24px 64px; } }
.ax-page-narrow { max-width: 1100px; }

.ax-card { background: rgb(var(--c-surface)); border: 1px solid rgb(var(--c-line)); border-radius: 14px; box-shadow: var(--shadow-1); }
.ax-card-pad { padding: 20px; }
@media (min-width: 640px) { .ax-card-pad { padding: 24px; } }
.ax-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid rgb(var(--c-line)); }
.ax-inset { background: rgb(var(--c-canvas)); border: 1px solid rgb(var(--c-line)); border-radius: 10px; }

.ax-eyebrow { font-size: 13px; font-weight: 500; color: rgb(var(--c-muted)); }
.ax-h1 { font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.015em; color: rgb(var(--c-ink)); }
@media (min-width: 768px) { .ax-h1 { font-size: 34px; } }
.ax-h2 { font-size: 20px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; color: rgb(var(--c-ink)); }
.ax-title { font-size: 15px; line-height: 1.35; font-weight: 600; color: rgb(var(--c-ink)); }
.ax-sub { font-size: 13px; line-height: 1.5; color: rgb(var(--c-muted)); }
.ax-lead { font-size: 15px; line-height: 1.6; color: rgb(var(--c-body)); max-width: 68ch; }

.ax-kpi-label { font-size: 13px; color: rgb(var(--c-muted)); }
.ax-kpi-value { font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; color: rgb(var(--c-ink)); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- forms */
.ax-label { display: block; font-size: 13px; font-weight: 500; color: rgb(var(--c-body)); margin-bottom: 6px; }
.ax-help { font-size: 12px; color: rgb(var(--c-muted)); margin-top: 6px; }
.ax-input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: 10px;
  background: rgb(var(--c-canvas)); border: 1px solid rgb(var(--c-line)); color: rgb(var(--c-ink));
  font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.ax-input:hover { border-color: rgb(var(--c-line-strong)); }
textarea.ax-input { height: auto; min-height: 96px; padding: 10px 14px; line-height: 1.5; }
select.ax-input {
  appearance: none; -webkit-appearance: none; padding-inline-end: 38px; cursor: pointer;
  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='%236A7588' stroke-width='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;
}
html[dir="rtl"] select.ax-input { background-position: left 12px center; }
.ax-input-group { display: flex; align-items: stretch; border-radius: 10px; border: 1px solid rgb(var(--c-line)); background: rgb(var(--c-canvas)); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.ax-input-group:focus-within { border-color: rgb(var(--c-accent)); box-shadow: 0 0 0 3px rgb(var(--c-accent) / .16); }
.ax-input-group input { flex: 1; min-width: 0; background: transparent; border: 0; height: 44px; padding: 0 14px; color: rgb(var(--c-ink)); font-size: 14px; }
.ax-input-group input:focus { box-shadow: none; }
.ax-addon { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; font-size: 13px; font-weight: 500; color: rgb(var(--c-muted)); background: rgb(var(--c-raised)); }

/* segmented control */
.ax-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: rgb(var(--c-canvas)); border: 1px solid rgb(var(--c-line)); border-radius: 12px; }
.ax-seg-btn { height: 36px; border-radius: 8px; font-size: 13px; font-weight: 500; color: rgb(var(--c-muted)); transition: background-color .15s, color .15s; white-space: nowrap; padding: 0 10px; }
.ax-seg-btn:hover { color: rgb(var(--c-ink)); }
.ax-seg-btn.is-active { background: rgb(var(--c-surface)); color: rgb(var(--c-ink)); font-weight: 600; box-shadow: var(--shadow-1); border: 1px solid rgb(var(--c-line)); }

/* ---------------------------------------------------------------- chips + alerts */
.ax-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap; line-height: 1;
  background: rgb(var(--c-raised)); color: rgb(var(--c-body)); border: 1px solid rgb(var(--c-line));
}
.ax-chip-up { background: rgb(var(--c-up) / .1); color: rgb(var(--c-up)); border-color: rgb(var(--c-up) / .22); }
.ax-chip-down { background: rgb(var(--c-down) / .1); color: rgb(var(--c-down)); border-color: rgb(var(--c-down) / .22); }
.ax-chip-gold { background: rgb(var(--c-gold) / .1); color: rgb(var(--c-gold)); border-color: rgb(var(--c-gold) / .25); }
.ax-chip-accent { background: rgb(var(--c-accent-soft)); color: rgb(var(--c-accent)); border-color: rgb(var(--c-accent) / .22); }
.ax-chip-info { background: rgb(var(--c-info) / .1); color: rgb(var(--c-info)); border-color: rgb(var(--c-info) / .22); }
.ax-dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; flex-shrink: 0; }
.ax-live { animation: ax-live 1.8s ease-in-out infinite; }

.ax-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.5; border: 1px solid rgb(var(--c-line)); background: rgb(var(--c-raised)); color: rgb(var(--c-body)); }
.ax-alert-down { background: rgb(var(--c-down) / .07); border-color: rgb(var(--c-down) / .3); color: rgb(var(--c-down)); }
.ax-alert-up { background: rgb(var(--c-up) / .07); border-color: rgb(var(--c-up) / .3); color: rgb(var(--c-up)); }
.ax-alert-gold { background: rgb(var(--c-gold) / .08); border-color: rgb(var(--c-gold) / .3); color: rgb(var(--c-gold)); }
.ax-alert-info { background: rgb(var(--c-accent-soft)); border-color: rgb(var(--c-accent) / .25); color: rgb(var(--c-accent)); }

/* ---------------------------------------------------------------- tables */
.ax-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ax-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ax-table th {
  font-size: 12px; font-weight: 500;
  padding: 10px 16px; background: rgb(var(--c-canvas)); border-bottom: 1px solid rgb(var(--c-line)); white-space: nowrap;
}
/* alignment and colour at zero specificity so text-end / text-* utilities on a cell win */
:where(.ax-table th) { text-align: start; color: rgb(var(--c-muted)); }
.ax-table td { padding: 12px 16px; border-bottom: 1px solid rgb(var(--c-line)); vertical-align: middle; }
:where(.ax-table td) { color: rgb(var(--c-body)); }
.ax-table tbody tr:last-child td { border-bottom: 0; }
.ax-table tbody tr:hover td { background: rgb(var(--c-raised) / .6); }

/* ---------------------------------------------------------------- overlays */
.ax-backdrop { background: rgb(6 9 16 / .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.ax-modal { background: rgb(var(--c-surface)); border: 1px solid rgb(var(--c-line)); border-radius: 18px; box-shadow: var(--shadow-3); }

/* ---------------------------------------------------------------- footer */
.ax-footer { background: rgb(var(--c-surface)); border-top: 1px solid rgb(var(--c-line)); margin-top: auto; }
.ax-footer-inner { max-width: 1600px; margin: 0 auto; padding: 40px 16px 28px; }
@media (min-width: 640px) { .ax-footer-inner { padding: 48px 24px 32px; } }
.ax-footer h4 { font-size: 13px; font-weight: 600; color: rgb(var(--c-ink)); margin-bottom: 12px; }
.ax-footer a, .ax-footer li > span { font-size: 13px; color: rgb(var(--c-muted)); }
.ax-footer a:hover { color: rgb(var(--c-ink)); }

/* ---------------------------------------------------------------- empty states */
.ax-empty { padding: 40px 20px; text-align: center; color: rgb(var(--c-muted)); font-size: 13px; }

/* ---------------------------------------------------------------- feedback */
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.shake-error { animation: shake .4s ease-in-out; }

/* ---------------------------------------------------------------- header at laptop widths
   Between xl (1280) and 2xl (1536) the full nav, the toggles and the auth buttons only just
   fit, so the spacing tightens and the timezone code drops (the clock itself stays). */
@media (max-width: 1535px) {
  .ax-header .apex-tz-label { display: none; }
  .ax-nav-link { padding: 0 9px; }
  .ax-header-inner > :first-child { gap: 20px !important; }
}

/* ---------------------------------------------------------------- inline field errors (validation.js) */
.apex-field-error { font-size: 12px !important; font-family: inherit !important; line-height: 1.45; margin-top: 6px !important; }
.ax-input-group:has(.border-brand-down) { border-color: rgb(var(--c-down)); }
