/* =========================================================
   ICFSME Payment — design system
   Mobile-first · RTL/LTR via logical properties · WCAG 2.2 AA
   ========================================================= */
:root {
  --brand: #13727b;          /* teal — 5.6:1 on white */
  --brand-strong: #0e5a61;
  --brand-soft: #e7f4f5;
  --accent: #d7262f;         /* logo red */
  --ink: #14212b;
  --ink-2: #47545e;          /* 7.6:1 */
  --ink-3: #66727b;          /* 4.8:1 */
  --line: #dbe2e6;
  --surface: #ffffff;
  --bg: #f3f6f8;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --success: #1b7a3d;
  --success-soft: #e6f4ea;
  --warning: #8a5a00;
  --warning-soft: #fff4dc;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  --focus: 0 0 0 3px #fff, 0 0 0 5px var(--brand);
  --font: "Tajawal", "Inter", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --font-num: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--surface); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
html[lang="en"] body { font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.3; margin: 0; }
p { margin: 0; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

.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;
}
.skip-link {
  position: absolute; inset-inline-start: 1rem; top: -100px; z-index: 100;
  background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 1rem; }

:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.site-header__inner {
  max-width: 1120px; margin-inline: auto;
  padding: .6rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: inherit; min-width: 0; }
.brand img { height: 36px; width: auto; }
.brand__text { display: none; border-inline-start: 1px solid var(--line); padding-inline-start: .75rem; }
.brand__title { font-size: 1rem; font-weight: 700; }
.brand__sub { font-size: .8rem; color: var(--ink-3); }
@media (min-width: 640px) {
  .brand img { height: 44px; }
  .brand__text { display: block; }
}
.lang-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  min-height: 44px; padding: 0 1rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 700; font-size: .875rem; cursor: pointer;
}
.lang-btn:hover { background: var(--bg); }

/* ---------- Layout ---------- */
.page { flex: 1; width: 100%; max-width: 1120px; margin-inline: auto; padding: 1.25rem 1rem 2.5rem; }
.page-head { margin-block-end: 1.25rem; }
.page-head h1 { font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.85rem); font-weight: 800; }
.page-head p { color: var(--ink-2); margin-top: .25rem; }

.layout { display: grid; gap: 1.25rem; }
@media (min-width: 960px) {
  .page { padding-top: 2rem; }
  .layout { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; gap: 1.5rem; }
  .layout__aside { position: sticky; top: 88px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
@media (min-width: 640px) { .card { padding: 1.75rem; } }

.section + .section { margin-top: 1.75rem; padding-top: 1.75rem; border-top: 1px solid var(--line); }
.section__title { float: inline-start; width: 100%; display: flex; align-items: center; gap: .6rem; font-size: 1.1rem; font-weight: 700; margin: 0 0 1rem; padding: 0; }
.section__step {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-strong); font-size: .85rem; font-weight: 800;
  font-family: var(--font-num);
}
legend.section__title + * { clear: both; }
.section::after { content: ""; display: block; clear: both; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

/* ---------- Form fields ---------- */
.grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .grid--2 { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.label { font-weight: 600; font-size: .95rem; }
.label .req { color: var(--danger); margin-inline-start: 2px; }
.label .opt { color: var(--ink-3); font-weight: 400; font-size: .85rem; }
.hint { font-size: .85rem; color: var(--ink-3); }

.input, .select {
  width: 100%;
  min-height: 48px;
  padding: .65rem .9rem;
  font: inherit;
  font-size: 1rem;           /* ≥16px prevents iOS zoom */
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid #c3ccd2;
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.input::placeholder { color: #8a959d; }
.input:hover, .select:hover { border-color: #9aa6ae; }
.input:focus, .select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(19, 114, 123, .2); }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2347545e' stroke-width='1.8' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left .9rem center;
  padding-inline-end: 2.4rem;
}
[dir="ltr"] .select { background-position: right .9rem center; }
.field.has-error .input, .field.has-error .select { border-color: var(--danger); }
.field.has-error .input:focus { box-shadow: 0 0 0 3px rgba(179, 38, 30, .18); }
.error-msg { display: none; align-items: center; gap: .35rem; color: var(--danger); font-size: .875rem; font-weight: 500; }
.field.has-error .error-msg { display: flex; }
.field.has-error .hint { display: none; }

/* amount */
.amount-wrap { position: relative; }
.amount-wrap .input {
  min-height: 60px; font-size: 1.6rem; font-weight: 700;
  font-family: var(--font-num); direction: ltr;
  text-align: left; padding-left: .9rem; padding-right: 4.5rem;
}
.amount-wrap__cur {
  position: absolute; top: 50%; transform: translateY(-50%); right: 1rem;
  color: var(--ink-3); font-weight: 700; pointer-events: none;
}
[dir="rtl"] .amount-wrap .input { text-align: right; padding-right: .9rem; padding-left: 4.5rem; }
[dir="rtl"] .amount-wrap__cur { right: auto; left: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  min-height: 40px; padding: 0 .95rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font: inherit; font-family: var(--font-num); font-size: .9rem; font-weight: 600; cursor: pointer;
}
.chip:hover { border-color: var(--brand); color: var(--brand-strong); }
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }

/* phone */
.phone { display: flex; direction: ltr; }
.phone .select { width: 118px; flex: none; border-start-end-radius: 0; border-end-end-radius: 0; border-inline-end: 0; font-family: var(--font-num); font-size: .95rem; background-position: right .6rem center; padding-inline: .7rem 1.8rem; }
.phone .input { flex: 1; min-width: 0; border-start-start-radius: 0; border-end-start-radius: 0; font-family: var(--font-num); letter-spacing: .02em; }

/* ---------- Summary ---------- */
.summary h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 1rem; }
.rows { margin: 0; display: grid; gap: .7rem; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; color: var(--ink-2); }
.row dt { margin: 0; flex: none; max-width: 45%; }
.row dd { margin: 0; font-weight: 600; color: var(--ink); }
.row--total { border-top: 1px dashed #c3ccd2; padding-top: .9rem; margin-top: .2rem; color: var(--ink); }
.row--total dt { font-weight: 700; }
.row--total dd { font-size: 1.35rem; font-weight: 800; color: var(--brand-strong); }
.fee-note { font-size: .8rem; color: var(--ink-3); margin-top: .6rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  width: 100%; min-height: 54px; padding: 0 1.25rem;
  border: 0; border-radius: var(--radius-sm);
  font: inherit; font-size: 1.05rem; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: background-color .15s, transform .05s;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-strong); }
.btn--primary:active { transform: translateY(1px); }
.btn--secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn--secondary:hover { background: var(--bg); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .7; cursor: progress; }
.btn svg { width: 20px; height: 20px; flex: none; }
[dir="rtl"] .btn .flip { transform: scaleX(-1); }
.spinner { width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: none; }
.btn.is-loading .spinner { display: block; }
.btn.is-loading .btn__icon { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.secure {
  display: flex; gap: .6rem; align-items: flex-start;
  margin-top: 1rem; padding: .8rem .9rem;
  background: var(--bg); border-radius: var(--radius-sm);
  font-size: .85rem; color: var(--ink-2);
}
.secure svg { width: 20px; height: 20px; flex: none; color: var(--success); margin-top: 2px; }

.help { margin-top: 1rem; font-size: .875rem; color: var(--ink-2); text-align: center; }
.help a { font-weight: 700; font-family: var(--font-num); }

/* ---------- Alerts ---------- */
.alert {
  display: flex; gap: .7rem; align-items: flex-start;
  padding: .9rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem;
  border: 1px solid; font-size: .95rem;
}
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.alert--error { background: var(--danger-soft); border-color: #f3c2bd; color: var(--danger); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); }
.site-footer__inner {
  max-width: 1120px; margin-inline: auto; padding: 1rem;
  display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: space-between;
  font-size: .85rem; color: var(--ink-3);
}

/* ---------- Receipt ---------- */
.receipt-page { max-width: 520px; }
.receipt { position: relative; overflow: hidden; padding: 0; }
.receipt__band { height: 6px; background: var(--brand); }
.receipt--failed .receipt__band { background: var(--danger); }
.receipt--pending .receipt__band { background: #d99a00; }
.receipt__head { text-align: center; padding: 1.75rem 1.25rem 1.25rem; }
.status-icon { width: 64px; height: 64px; margin: 0 auto .9rem; border-radius: 50%; display: grid; place-items: center; }
.status-icon svg { width: 34px; height: 34px; }
.receipt--paid .status-icon { background: var(--success-soft); color: var(--success); }
.receipt--failed .status-icon { background: var(--danger-soft); color: var(--danger); }
.receipt--pending .status-icon { background: var(--warning-soft); color: var(--warning); }
.receipt__title { font-size: 1.3rem; font-weight: 800; }
.receipt__sub { color: var(--ink-2); margin-top: .3rem; font-size: .95rem; }
.receipt__amount { margin-top: 1rem; font-size: clamp(1.8rem, 1.5rem + 1.5vw, 2.3rem); font-weight: 800; font-family: var(--font-num); }
.receipt__amount small { font-size: 1rem; color: var(--ink-3); font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .8rem; border-radius: 999px; font-size: .85rem; font-weight: 700; margin-top: .75rem; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.receipt--paid .badge { background: var(--success-soft); color: var(--success); }
.receipt--failed .badge { background: var(--danger-soft); color: var(--danger); }
.receipt--pending .badge { background: var(--warning-soft); color: var(--warning); }
.receipt__body { padding: 0 1.25rem 1.5rem; }
@media (min-width: 640px) { .receipt__body { padding: 0 1.75rem 1.75rem; } }
.receipt__perf { border: 0; border-top: 2px dashed var(--line); margin: 0 0 1.25rem; }
.receipt .rows { gap: .8rem; }
.receipt .row dd { text-align: end; overflow-wrap: anywhere; }
.receipt__qr { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; padding: 1rem; background: var(--bg); border-radius: var(--radius-sm); }
.receipt__qr img { width: 92px; height: 92px; background: #fff; padding: 4px; border-radius: 8px; flex: none; }
.receipt__qr p { font-size: .85rem; color: var(--ink-2); }
.receipt__legal { font-size: .75rem; color: var(--ink-3); text-align: center; margin-top: 1.25rem; }
.actions { display: grid; gap: .75rem; margin-top: 1.25rem; }
@media (min-width: 480px) { .actions { grid-template-columns: 1fr 1fr; } }
.receipt-note { margin-top: 1rem; text-align: center; font-size: .9rem; color: var(--ink-2); }

/* ---------- Motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  @page { margin: 10mm; }
  body { background: #fff; }
  .site-header, .site-footer, .actions, .receipt-note, .skip-link { display: none !important; }
  .page { padding: 0; }
  .card { box-shadow: none; border-color: #bbb; }
  .receipt__band, .status-icon, .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
