/* ─────────────────────────────────────────────
 *  nstAccept — shared design system
 *  Used by index.html, pay.html and result.html.
 * ───────────────────────────────────────────── */

/* ── Tokens ──────────────────────────────────── */
:root {
  /* Brand palette */
  --navy:        #142847;
  --navy-muted:  #2d3f5c;
  --blue:        #2a7ce8;
  --blue-deep:   #1a5fd4;
  --cyan:        #3eb8ff;

  /* Neutrals */
  --bg:          #f4f6fb;
  --bg-alt:      #fafbfd;
  --surface:     #ffffff;
  --surface-2:   #eef2f9;
  --surface-3:   #f0f4fa;
  --border:      rgba(20, 40, 71, 0.11);
  --border-soft: rgba(20, 40, 71, 0.06);

  /* Text */
  --text:        #142847;
  --muted:       #5c6b85;
  --placeholder: #8b9ab5;

  /* Semantics */
  --success:     #0d9f4a;
  --success-bg:  rgba(13, 159, 74, 0.1);
  --error:       #d92d20;
  --error-bg:    rgba(217, 45, 32, 0.08);
  --warning:     #b54708;

  /* Typography */
  --font-display: 'Outfit', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-body:    'Plus Jakarta Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;

  /* Radii */
  --r-sm: 8px;
  --r:    12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* Elevation */
  --shadow:    0 1px 2px rgba(20, 40, 71, 0.04), 0 16px 48px rgba(20, 40, 71, 0.09);
  --shadow-lg: 0 1px 2px rgba(20, 40, 71, 0.04), 0 20px 50px rgba(20, 40, 71, 0.1);
  --shadow-sm: 0 1px 3px rgba(20, 40, 71, 0.06);
  --ring:      0 0 0 3px rgba(42, 124, 232, 0.18);

  /* Motion */
  --ease:      cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast:  120ms;
  --dur:       200ms;
  --dur-slow:  420ms;
}

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

html { -webkit-text-size-adjust: 100%; }
html, body { min-height: 100%; }

body {
  font-family: var(--font-body);
  /* 16px on mobile avoids iOS input-zoom. Scales up on larger screens. */
  font-size: clamp(15px, 1.05vw, 16px);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Respect iOS safe areas on notched phones. */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(80% 50% at 100% 0%,  rgba(42, 124, 232, 0.09), transparent 55%),
    radial-gradient(60% 40% at 0% 100%,  rgba(62, 184, 255, 0.07), transparent 45%),
    linear-gradient(180deg, var(--bg-alt) 0%, var(--bg) 35%, var(--bg) 100%);
}

img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
a { color: var(--blue-deep); }

/* Visually hidden but available to assistive tech. */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* Focus ring: visible only for keyboard users. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: inherit;
}

/* ── Layout primitives ──────────────────────── */
.site-logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  line-height: 0;
}
.site-logo img {
  height: clamp(34px, 5vw, 48px);
  width: auto;
  max-width: min(280px, 60vw);
  object-fit: contain;
  object-position: left center;
}

/* Trust indicator used in every page header. */
.trust-mini {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--navy-muted);
}
.trust-mini svg { color: var(--blue); flex-shrink: 0; }

/* ── Components ─────────────────────────────── */

/* Card — the primary surface container. */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cyan), var(--blue), var(--blue-deep));
  opacity: 0.95;
}
.card-body { padding: clamp(22px, 4vw, 36px); }

/* Chip — compact pill label. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-muted);
  box-shadow: var(--shadow-sm);
}
.chip svg { color: var(--blue); flex-shrink: 0; }

.partner-pill {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}

/* Buttons */
.btn {
  --btn-bg:  var(--surface);
  --btn-fg:  var(--navy-muted);
  --btn-brd: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;           /* Touch target */
  padding: 12px 22px;
  border-radius: var(--r);
  border: 1px solid var(--btn-brd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    background var(--dur) var(--ease),
    opacity var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
  user-select: none;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  --btn-bg: linear-gradient(135deg, var(--blue) 0%, var(--blue-deep) 100%);
  --btn-fg: #fff;
  --btn-brd: transparent;
  box-shadow: 0 4px 20px rgba(42, 124, 232, 0.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 28px rgba(42, 124, 232, 0.4); }

.btn-ghost {
  --btn-bg: var(--surface);
  --btn-fg: var(--muted);
  font-weight: 600;
}
.btn-ghost:hover:not(:disabled) { color: var(--navy); border-color: rgba(20,40,71,0.18); }

.btn-block { width: 100%; }

/* Icon-only button (copy, edit, etc.) */
.icon-btn {
  width: 32px;
  height: 32px;
  min-height: 0;
  padding: 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--blue); border-color: rgba(42, 124, 232, 0.45); }
.icon-btn.copied { color: var(--success); border-color: rgba(13, 159, 74, 0.45); }

/* Inputs */
.input-group { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.input-group label,
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-muted);
}
.input-group label .muted,
.field-label .muted { font-weight: 500; color: var(--muted); }

.input,
.input-group input,
.input-group select,
.input-group textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 16px;
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.input::placeholder,
.input-group input::placeholder,
.input-group textarea::placeholder { color: var(--placeholder); }

.input:focus,
.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  border-color: rgba(42, 124, 232, 0.55);
  background: var(--surface);
  box-shadow: var(--ring);
}

.input-group input[aria-invalid="true"],
.input-group select[aria-invalid="true"] {
  border-color: rgba(217, 45, 32, 0.5);
  background: rgba(217, 45, 32, 0.04);
}

.input-hint { font-size: 12px; color: var(--muted); }
.input-error {
  font-size: 12px;
  font-weight: 600;
  color: var(--error);
  display: none;
}
.input-group.has-error .input-error { display: block; }

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* Select with a custom caret */
.input-group select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235c6b85' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}

/* Status / alert banners */
.status-msg {
  display: none;
  padding: 12px 16px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}
.status-msg.show { display: block; }
.status-msg.info {
  background: rgba(42, 124, 232, 0.08);
  border: 1px solid rgba(42, 124, 232, 0.2);
  color: var(--blue-deep);
}
.status-msg.error {
  background: var(--error-bg);
  border: 1px solid rgba(217, 45, 32, 0.22);
  color: #b42318;
}
.status-msg.preformatted {
  white-space: pre-wrap;
  word-break: break-word;
  font-weight: 500;
}
.status-msg.success {
  background: var(--success-bg);
  border: 1px solid rgba(13, 159, 74, 0.28);
  color: var(--success);
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

/* Spinner (general purpose) */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.spinner.dark {
  border-color: rgba(42, 124, 232, 0.22);
  border-top-color: var(--blue);
}
.spinner.lg { width: 40px; height: 40px; border-width: 3px; }
.spinner.xl { width: 48px; height: 48px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Full-screen overlay (verification, etc.) */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
}
.overlay.show { display: flex; }
.overlay p {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  text-align: center;
}

/* Skeleton placeholder */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    rgba(20, 40, 71, 0.05) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Brand/footer pills */
.payment-brand,
.brand-pill {
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
}

/* Hide util (overrides layout display). */
[hidden] { display: none !important; }

/* ── Motion preferences ─────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .btn:hover:not(:disabled) { transform: none; }
}

/* ── Small-screen defaults ──────────────────── */
@media (max-width: 640px) {
  .card-body { padding: 22px 18px; }
  .input-row { grid-template-columns: 1fr; }
  .btn { min-height: 52px; font-size: 16px; } /* Slightly chunkier on phones */
}

/* ── Print (receipt-friendly) ───────────────── */
@media print {
  body::before { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #e5e7eb; }
  .btn, .overlay, .icon-btn { display: none !important; }
}

/* ── Language toggle ───────────────────────── */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
}
.lang-toggle button {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
}
.lang-toggle button:hover { color: var(--navy); }
.lang-toggle button.active {
  background: rgba(42, 124, 232, 0.12);
  color: var(--blue-deep);
}

/* ── Arabic typography ─────────────────────── */
html[lang="ar"] {
  --font-display: 'Tajawal', 'Outfit', system-ui, sans-serif;
  --font-body:    'Tajawal', 'Plus Jakarta Sans', system-ui, sans-serif;
}

/* ── RTL layout fixes ──────────────────────── */
[dir="rtl"] .site-logo img {
  object-position: right center;
}

[dir="rtl"] .header-right,
[dir="rtl"] footer {
  flex-direction: row-reverse;
}

[dir="rtl"] .trust-mini svg { order: 1; }

[dir="rtl"] .input-group select {
  background-position: left 14px center;
  padding-right: 16px;
  padding-left: 40px;
}

[dir="rtl"] .summary-value,
[dir="rtl"] .order-row .value {
  text-align: left;
}

[dir="rtl"] .detail-row .val {
  text-align: left;
  justify-content: flex-start;
}

[dir="rtl"] .eyebrow::before {
  order: 1;
}

[dir="rtl"] .btn svg {
  transform: scaleX(-1);
}

@media (max-width: 520px) {
  [dir="rtl"] .detail-row .val {
    text-align: right;
    justify-content: flex-end;
  }
}
