:root {
  color-scheme: light dark;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-soft: #efeee9;
  --text: #171817;
  --muted: #60645f;
  --border: #d8d8d1;
  --accent: #0b6f69;
  --accent-strong: #075954;
  --danger: #a52a2a;
  --success: #14764d;
  --shadow: 0 22px 58px rgba(19, 31, 28, 0.09);
  font-family: "SF Arabic", "Geeza Pro", Tahoma, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101211;
    --surface: #181b19;
    --surface-soft: #202421;
    --text: #f5f5f1;
    --muted: #b2b8b3;
    --border: #333934;
    --accent: #65c8bf;
    --accent-strong: #84d8d1;
    --danger: #ff9e9e;
    --success: #73d9a5;
    --shadow: 0 22px 58px rgba(0, 0, 0, 0.34);
  }
}

* { box-sizing: border-box; }

html { background: var(--bg); scroll-behavior: smooth; }

body.payment-page {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% 8%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 34rem),
    var(--bg);
  color: var(--text);
  direction: rtl;
}

button, select, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.payment-header {
  width: min(calc(100% - 32px), 1060px);
  min-height: 82px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--border);
}

.payment-brand img { display: block; width: 104px; height: auto; }
@media (prefers-color-scheme: dark) { .payment-brand img { filter: invert(1); } }
.payment-header nav { display: flex; align-items: center; gap: 14px; }
.payment-header a { color: var(--muted); text-decoration: none; font-size: 0.92rem; }
.payment-header a:hover { color: var(--text); }

.payment-shell {
  width: min(calc(100% - 32px), 980px);
  margin: 0 auto;
  padding: clamp(42px, 8vw, 88px) 0 72px;
}

.payment-shell-narrow { width: min(calc(100% - 32px), 720px); }

.payment-intro { max-width: 720px; margin-bottom: 28px; }
.payment-eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 0.86rem; font-weight: 800; }
.payment-intro h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.7rem); line-height: 1.13; letter-spacing: -0.04em; }
.payment-intro > p:last-child { margin: 15px 0 0; color: var(--muted); line-height: 1.9; }

.payment-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 0.72fr); gap: 22px; align-items: start; }
.payment-card {
  min-width: 0;
  padding: clamp(20px, 4vw, 32px);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow);
}
.payment-card h2, .payment-card h3 { margin-top: 0; }
.payment-card p { line-height: 1.8; }

.auth-actions { display: grid; gap: 10px; }
.auth-actions p { margin: 0 0 5px; color: var(--muted); }
.auth-button, .payment-button {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  color: var(--text);
  background: var(--surface);
  font-weight: 750;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}
.auth-button:hover, .payment-button:hover { transform: translateY(-1px); border-color: var(--accent); }
.payment-button-primary { color: #fff; border-color: var(--accent-strong); background: var(--accent-strong); }
.payment-button-danger { color: var(--danger); }
.payment-button:disabled, .auth-button:disabled { cursor: not-allowed; opacity: 0.48; transform: none; }
.payment-button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.account-strip { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.account-strip p { margin: 0; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.text-button { border: 0; padding: 6px; color: var(--muted); background: transparent; cursor: pointer; }

.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field label { font-weight: 750; }
.field select {
  width: 100%;
  min-height: 50px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: var(--surface);
}

.order-summary { display: grid; gap: 14px; padding: 18px; margin: 0 0 18px; border-radius: 16px; background: var(--surface-soft); }
.order-summary-row { display: flex; justify-content: space-between; gap: 16px; }
.order-summary-row span { color: var(--muted); }
.order-summary-row strong { text-align: left; }
.renewal-copy { margin: 0 0 18px; padding: 13px 15px; border-inline-start: 3px solid var(--accent); color: var(--muted); background: var(--surface-soft); font-size: 0.91rem; }
.legal-soft { margin: 14px 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.8; }
.legal-soft a { color: inherit; }

.payment-notice { margin: 0 0 18px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 12px; color: var(--muted); background: var(--surface-soft); line-height: 1.7; }
.payment-notice[data-kind="danger"] { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 36%, var(--border)); }
.payment-notice[data-kind="success"] { color: var(--success); border-color: color-mix(in srgb, var(--success) 36%, var(--border)); }

.trust-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 15px; }
.trust-list li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; color: var(--muted); line-height: 1.7; }
.trust-list b { display: block; color: var(--text); }
.trust-index { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); font-size: 0.78rem; font-weight: 800; }

.payment-form-wrap { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.mysr-form { direction: rtl; }

.status-card { text-align: center; padding: clamp(28px, 7vw, 54px); }
.status-mark { width: 76px; height: 76px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 50%; color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); font-size: 2rem; font-weight: 900; }
.status-mark-success { color: var(--success); }
.status-mark-danger { color: var(--danger); }
.status-card h1 { margin: 0; font-size: clamp(1.8rem, 5vw, 3rem); }
.status-card > p { color: var(--muted); }
.status-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }
.order-reference { direction: ltr; unicode-bidi: isolate; font-family: ui-monospace, monospace; color: var(--muted); }
.status-spinner { width: 34px; height: 34px; margin: 22px auto; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 850ms linear infinite; }

.subscription-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
.subscription-stat { padding: 15px; border-radius: 14px; background: var(--surface-soft); }
.subscription-stat span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 0.82rem; }
.subscription-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.upgrade-box { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.upgrade-row { display: flex; gap: 10px; }
.upgrade-row select { flex: 1; min-width: 0; }

dialog.payment-dialog { width: min(calc(100% - 32px), 520px); padding: 0; border: 1px solid var(--border); border-radius: 20px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
dialog.payment-dialog::backdrop { background: rgba(0, 0, 0, 0.54); }
.dialog-body { padding: 26px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.policy-content { max-width: 760px; }
.policy-section { padding: 25px 0; border-bottom: 1px solid var(--border); }
.policy-section h2 { margin: 0 0 10px; }
.policy-section p, .policy-section li { color: var(--muted); line-height: 1.9; }

.payment-footer { width: min(calc(100% - 32px), 980px); margin: 0 auto; padding: 24px 0 42px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.82rem; }
.payment-footer a { color: inherit; }

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

@media (max-width: 760px) {
  .payment-header { min-height: 70px; }
  .payment-header nav a:first-child { display: none; }
  .payment-layout { grid-template-columns: 1fr; }
  .subscription-grid { grid-template-columns: 1fr; }
  .upgrade-row { flex-direction: column; }
}

@media (max-width: 420px) {
  .payment-shell, .payment-header, .payment-footer { width: min(calc(100% - 22px), 980px); }
  .payment-card { border-radius: 17px; padding: 18px; }
  .payment-header nav { gap: 8px; }
  .status-actions, .subscription-actions { flex-direction: column; }
  .status-actions > *, .subscription-actions > * { width: 100%; }
}

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

/* Official Apple Pay button (Apple Pay on the Web). Rendered only on
   capable devices for recurring purchases where the renewal token must be
   captured — the hosted form's applepay method stays for top-ups. */
.apple-pay-button {
  /* WebKit's native Apple Pay paint per Apple Pay on the Web docs. Earlier
     revisions overrode appearance/background/border — those overrides
     SUPPRESS the native paint, leaving an empty clickable box (no  mark).
     The button only mounts where Apple Pay works (Safari/WebKit), so the
     native render is the only paint that matters: no fallback styling. */
  -webkit-appearance: -apple-pay-button;
  -apple-pay-button-type: buy;
  -apple-pay-button-style: white-outline;
  display: block;
  width: 100%;
  height: 52px;
  margin: 0 0 12px;
  cursor: pointer;
}

.apple-pay-button:disabled {
  opacity: 0.6;
  cursor: default;
}


/* The payment form's save-card notice is provider-internal wording; the
   renewal method keeps working unchanged. Hidden from the user surface. */
.mysr-form .mysr-form-warn-icon {
  display: none;
}


/* Secondary management sections on the subscription page. */
.subscription-manage {
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  padding: 10px 14px;
  margin-top: 12px;
}

.subscription-manage summary {
  cursor: pointer;
  font-weight: 600;
  color: inherit;
}

.subscription-manage[open] summary {
  margin-bottom: 8px;
}

.subscription-manage-note {
  font-size: 0.85rem;
  opacity: 0.75;
  margin: 0 0 10px;
}

.subscription-manage .payment-button-danger {
  background: none;
  border: 1px solid rgba(0, 0, 0, 0.15);
  color: inherit;
}
