:root {
  --blue: #3f72e5;
  --blue-soft: #6f88f6;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #171b24;
  --muted: #8b929e;
  --line: #e5e8ee;
  --shadow: 0 8px 22px rgba(23, 27, 36, 0.06);
  --field-shadow: 0 4px 12px rgba(23, 27, 36, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Tajawal", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.checkout-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 22px 34px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.checkout-header {
  height: 72px;
  display: grid;
  grid-template-columns: 96px 1fr 96px;
  align-items: center;
  margin: 0 -22px;
  padding: 0 22px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.checkout-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
}

.icon-button,
.store-button {
  border: 0;
  background: transparent;
  color: var(--text);
}

.back-button {
  justify-self: start;
  width: 42px;
  height: 42px;
  padding: 8px;
}

.store-button {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  font-size: 18px;
  font-weight: 700;
}

.store-button svg {
  width: 28px;
  height: 28px;
  fill: var(--text);
  stroke-width: 1.8;
}

.secure-strip {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #6f7785;
  font-size: 14px;
  font-weight: 500;
}

.secure-strip svg {
  width: 17px;
  height: 17px;
  color: #16a34a;
  fill: #16a34a;
  stroke: #16a34a;
  stroke-width: 1.6;
}

.summary-card,
.detail-card,
.form-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.summary-card {
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
}

.summary-card h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.summary-price {
  direction: ltr;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
}

.currency {
  font-weight: 800;
}

.chevron {
  width: 24px;
  height: 24px;
  color: #6f7785;
}

.info-section,
.payment-section,
.card-form {
  margin-top: 24px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
}

.section-title svg {
  width: 22px;
  height: 22px;
  color: var(--text);
  fill: currentColor;
  stroke-width: 1.5;
}

.detail-card {
  min-height: 84px;
  display: grid;
  grid-template-columns: 44px 48px 1fr;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.detail-card p {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
}

.detail-card span:not(.free-pill) {
  display: block;
  margin-top: 4px;
  color: #687080;
  font-size: 14px;
  direction: ltr;
}

.edit-button,
.detail-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.edit-button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}

.edit-button svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
  stroke-width: 1.4;
}

.detail-icon {
  background: #f0f2f6;
  color: #1d2430;
}

.detail-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke-width: 1.4;
}

.shipping-method {
  grid-template-columns: 44px auto 1fr;
}

.shipping-logo {
  width: 38px;
  max-width: 42px;
  height: auto;
  object-fit: contain;
  justify-self: center;
  align-self: center;
  display: block;
}

.free-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 34px;
  border-radius: 9px;
  background: #def8e8;
  color: #16824c;
  font-size: 14px;
  font-weight: 700;
}

.top-payment-showcase {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0px;
  margin-top: 12px;
  height: 50px;
  overflow: hidden;
  position: relative;
}

.top-payment-showcase img {
  width: auto;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  display: block;
  transform: scale(1.9);
  transform-origin: center;
}

.payment-options {
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.pay-option {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 4px 14px rgba(23, 27, 36, 0.04);
  direction: rtl;
  font-size: 14px;
  font-weight: 700;
}

.card-option {
  border-color: #20242d;
  box-shadow: 0 0 0 1px #20242d;
}

.brand-row,
.inline-card-logos {
  display: flex;
  align-items: center;
  gap: 5px;
  direction: ltr;
}

.brand-row {
  flex: 1 1 auto;
  justify-content: space-between;
  width: 100%;
}

.payment-brand-row {
  direction: rtl;
  justify-content: space-around;
  gap: clamp(4px, 1.6vw, 8px);
  min-width: 0;
}

.discounted-mada {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  min-width: 48px;
  height: 28px;
  flex: 0 0 auto;
}

.discount-badge {
  position: absolute;
  top: -12px;
  right: 0;
  min-width: 27px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border-radius: 5px;
  background: rgba(33, 186, 106, 0.16);
  color: #179452;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.payment-logo {
  display: block;
  height: auto;
  max-height: 24px;
  object-fit: contain;
  flex: 0 1 auto;
}

.mada-payment-logo {
  width: 48px;
  max-height: 22px;
  margin-top: 8px;
}

.apple-pay-logo {
  width: 50px;
  max-height: 23px;
}

.mastercard-payment-logo {
  width: 32px;
  max-height: 24px;
}

.visa-payment-logo {
  width: 48px;
  max-height: 22px;
}

.payment-selected-dot {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  border: 6px solid #111827;
  border-radius: 50%;
  background: #fff;
}

/* 1. تثبيت الحاوية جهة اليمين بعيداً عن كتابة الأرقام */
.card-number-line .inline-card-logos,
.moyasar-form .inline-card-logos {
  display: flex !important;
  flex-direction: row-reverse !important;
  align-items: center !important;
  gap: 6px !important;
  position: absolute !important;
  right: 12px !important;
  left: auto !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  pointer-events: none;
}

/* 2. الأبعاد والمشهد الافتراضي للأيقونات */
.card-number-line .inline-card-logos span,
.brand-sprite {
  width: 32px !important;
  height: 20px !important;
  display: inline-block !important;
  background-image: url("assets/card-logos.png") !important;
  background-repeat: no-repeat !important;
  background-size: 130px auto !important;
  opacity: 0.35 !important;
  transition: all 0.2s ease !important;
}

/* 3. الإحداثيات المحددة للشريط المجمع */
#logo-mada, .brand-sprite.mada {
  background-position: 0px center !important;
}

#logo-visa, .brand-sprite.visa {
  background-position: -65px center !important;
}

#logo-mastercard, .brand-sprite.mastercard {
  background-position: -98px center !important;
}

/* 4. إضاءة وتكبير الشعار النشط فقط */
.card-number-line .inline-card-logos span.active,
.card-number-line .inline-card-logos span.is-active,
.brand-sprite.active,
.brand-sprite.is-active,
.brand-sprite.visa,
.brand-sprite.mastercard,
.brand-sprite.mada {
  opacity: 1 !important;
  transform: scale(1.2) !important;
}

.form-panel {
  padding: 24px 22px 24px;
}

.field-label {
  display: block;
  margin-bottom: 14px;
  font-size: 28px;
  font-weight: 500;
  text-align: right;
}

.centered-label {
  margin-top: 30px;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
}

input {
  width: 100%;
  border: 1px solid #dfe3ea;
  background: #fff;
  color: var(--text);
  outline: none;
}

input::placeholder {
  color: #cfd4dc;
}

#card-holder {
  height: 58px;
  padding: 0 18px;
  border-radius: 12px;
  box-shadow: var(--field-shadow);
  font-size: 18px;
}

.card-info-field {
  overflow: hidden;
  border: 1px solid #dfe3ea;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--field-shadow);
}

.card-number-line {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid #dfe3ea;
  direction: ltr;
  position: relative;
}

.card-number-line input {
  height: 100%;
  min-width: 0;
  border: 0;
  padding-right: 122px;
  direction: ltr;
  text-align: left;
  font-size: 18px;
}

.inline-card-logos {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  justify-content: flex-end;
  flex: 0 0 auto;
  gap: 5px;
  pointer-events: none;
}

@media (max-width: 360px) {
  .pay-option {
    font-size: 13px;
    padding-inline: 8px;
  }

  .brand-sprite {
    width: 31px;
  }

  .logo-mada {
    height: 13px;
    background-size: 151px 60px;
    background-position: -10px -23px;
  }

  .logo-visa {
    height: 12px;
    background-size: 159px 64px;
    background-position: -65px -25px;
  }

  .logo-mastercard {
    height: 17px;
    background-size: 164px 66px;
    background-position: -124px -21px;
  }

  .card-number-line input {
    padding-right: 112px;
  }

  .payment-brand-row {
    gap: 4px;
  }

  .discounted-mada {
    width: 42px;
    min-width: 42px;
  }

  .discount-badge {
    min-width: 25px;
    height: 14px;
    font-size: 10px;
  }

  .payment-selected-dot {
    width: 17px;
    height: 17px;
    border-width: 5px;
  }

  .payment-logo {
    max-height: 21px;
  }

  .mada-payment-logo {
    width: 42px;
    max-height: 19px;
  }

  .apple-pay-logo {
    width: 44px;
    max-height: 20px;
  }

  .mastercard-payment-logo {
    width: 29px;
    max-height: 21px;
  }

  .visa-payment-logo {
    width: 42px;
    max-height: 19px;
  }
}

.card-meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  direction: ltr;
}

.card-meta-row input {
  height: 58px;
  border: 0;
  padding: 0 20px;
  direction: ltr;
  text-align: left;
  font-size: 18px;
}

.card-meta-row input+input {
  border-left: 1px solid #dfe3ea;
}

.pay-button {
  width: 100%;
  height: 64px;
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 9px;
  background: linear-gradient(180deg, #7188fa 0%, var(--blue) 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(63, 114, 229, 0.25);
  font-size: 28px;
  font-weight: 700;
}

.pay-button strong {
  direction: ltr;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 800;
}

.pay-button.is-error {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18), 0 12px 24px rgba(63, 114, 229, 0.22);
}

.pay-button.is-success {
  background: linear-gradient(180deg, #4dd98b 0%, #20b96e 100%);
  box-shadow: 0 12px 24px rgba(32, 185, 110, 0.25);
}

.powered {
  margin: 28px 0 0;
  color: #9ba0aa;
  text-align: center;
  font-size: 18px;
  letter-spacing: 0;
  direction: ltr;
}

.powered strong {
  margin-left: 8px;
  color: #9a9fa8;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 3px;
}

/* قسم الخصم الرئيسي */
.coupon-section {
  background-color: #f3f4f6;
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
  border: 1px solid #e5e7eb;
}

/* العنوان والأيقونة جهة اليمين */
.coupon-title {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-direction: row-reverse; /* يضمن وجود الأيقونة على يسار أو يمين النص حسب التصميم */
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: #111827;
  margin-bottom: 12px;
  text-align: right;
}

/* مجموعة الإدخال والزر */
.coupon-input-group {
  display: flex;
  flex-direction: row-reverse; /* حقل الإدخال على اليمين والزر على اليسار */
  gap: 10px;
  align-items: center;
}

/* حقل إدخال الكود خلفية بيضاء والنص يمين */
.coupon-input-group input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background-color: #ffffff !important; /* خلفية بيضاء ناصعة */
  font-size: 14px;
  outline: none;
  text-align: right !important; /* النص والأدوات جهة اليمين */
  color: #111827;
}

.coupon-input-group input::placeholder {
  color: #9ca3af;
  text-align: right !important;
}

/* زر تطبيق أسود جهة اليسار */
.btn-apply-coupon {
  background-color: #000000;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 12px 22px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}

.btn-apply-coupon:hover {
  background-color: #1f2937;
}

/* تنسيق قسم الشحن المعدل بالمحاذاة الصريحة لليمين */
.shipping-section {
  background-color: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 12px !important;
  padding: 16px !important;
  margin: 16px 0 !important;
  direction: rtl !important;
  text-align: right !important;
}

.shipping-title {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  font-weight: 700 !important;
  font-size: 15px !important;
  color: #111827 !important;
  margin-bottom: 14px !important;
  text-align: right !important;
}

.shipping-inputs {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
}

.input-field {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  text-align: right !important;
}

.input-field label {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #374151 !important;
  text-align: right !important;
}

.input-field input {
  width: 100% !important;
  padding: 11px 14px !important;
  border: 1px solid #d1d5db !important;
  border-radius: 8px !important;
  background-color: #ffffff !important;
  font-size: 14px !important;
  outline: none !important;
  box-sizing: border-box !important;
  text-align: right !important;
  direction: rtl !important;
  transition: border-color 0.2s, box-shadow 0.2s !important;
}

.input-field input::placeholder {
  text-align: right !important;
  color: #9ca3af !important;
}

.input-field input:focus {
  border-color: #000000 !important;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05) !important;
}

@media (min-width: 520px) {
  .checkout-shell {
    box-shadow: 0 20px 70px rgba(23, 27, 36, 0.08);
  }
}

.whatsapp-address-note {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  background-color: #f0fdf4 !important; /* خلفية خضراء هادئة جداً */
  border: 1px solid #bbf7d0 !important;
  border-radius: 8px !important;
  padding: 10px 14px !important;
  margin: 14px 0 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: #15803d !important;
  text-align: center !important;
}

/* ===== النافذة المنبثقة (Modal Overlay) - متجاوبة للموبايل ===== */
.status-overlay {
  position: fixed !important;
  top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
  width: 100% !important; height: 100% !important;
  background-color: rgba(0, 0, 0, 0.55) !important;
  backdrop-filter: blur(5px) !important;
  -webkit-backdrop-filter: blur(5px) !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 999999 !important;
  padding: 20px !important;
  box-sizing: border-box !important;
  display: none;
}

.status-overlay.is-visible {
  display: flex !important;
}

.modal-card {
  background: #ffffff !important;
  border-radius: 24px !important;
  padding: 32px 24px !important;
  width: 100% !important;
  max-width: 360px !important;
  text-align: center !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
  animation: popIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
  margin: 0 auto !important;
  height: auto !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.spinner-ring {
  width: 52px !important; height: 52px !important;
  border: 4px solid #f3f4f6 !important; border-top-color: #2563eb !important;
  border-radius: 50% !important; margin: 0 auto 16px auto !important;
  animation: spin 1s linear infinite !important;
}

.modal-title { font-size: 20px !important; font-weight: 700 !important; color: #111827 !important; margin-bottom: 8px !important; }
.modal-text { font-size: 14px !important; color: #6b7280 !important; }

.success-icon-wrap { margin-bottom: 16px !important; }
.success-checkmark { width: 64px !important; height: 64px !important; background: #dcfce7 !important; color: #16a34a !important; border-radius: 50% !important; display: flex !important; align-items: center !important; justify-content: center !important; font-size: 32px !important; font-weight: 700 !important; margin: 0 auto !important; box-shadow: 0 4px 14px rgba(22, 163, 74, 0.2) !important; }
.receipt-title { font-size: 22px !important; font-weight: 800 !important; color: #111827 !important; margin-bottom: 4px !important; }
.receipt-date { font-size: 13px !important; color: #6b7280 !important; margin-bottom: 20px !important; }
.receipt-details-box { background: #f8fafc !important; border: 1px solid #e2e8f0 !important; border-radius: 12px !important; padding: 16px !important; margin-bottom: 24px !important; text-align: right !important; }
.receipt-row { display: flex !important; justify-content: space-between !important; padding: 8px 0 !important; border-bottom: 1px dashed #cbd5e1 !important; font-size: 14px !important; color: #334155 !important; }
.receipt-row:last-child { border-bottom: none !important; padding-bottom: 0 !important; }
.text-success { color: #16a34a !important; font-weight: 800 !important; }
.font-mono { font-family: monospace; font-size: 14px !important; letter-spacing: 0.5px !important; }
.btn-receipt-action { width: 100% !important; background: #2563eb !important; color: #fff !important; border: none !important; padding: 16px !important; border-radius: 12px !important; font-weight: 700 !important; font-size: 16px !important; cursor: pointer !important; transition: background 0.3s !important; }
.btn-receipt-action:hover { background: #1d4ed8 !important; }

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes popIn { 0% { opacity: 0; transform: scale(0.9) translateY(10px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }

/* ===== Trust Signals - أيقونات الثقة والأمان ===== */
.secure-badges-container {
  margin-top: 20px !important;
  text-align: center !important;
}

.secure-text {
  font-size: 12px !important;
  color: #16a34a !important;
  font-weight: 600 !important;
  margin-bottom: 10px !important;
  margin-top: 0 !important;
}

.secure-logos {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 8px !important;
  flex-wrap: wrap !important;
}

.trust-badge {
  font-size: 10px !important;
  font-weight: 700 !important;
  color: #64748b !important;
  background: #f1f5f9 !important;
  padding: 4px 10px !important;
  border-radius: 4px !important;
  border: 1px solid #e2e8f0 !important;
  letter-spacing: 0.3px !important;
  white-space: nowrap !important;
}

.mada-badge  { color: #059669 !important; border-color: #059669 !important; background: #f0fdf4 !important; }
.visa-badge  { color: #1d4ed8 !important; border-color: #1d4ed8 !important; background: #eff6ff !important; }
.mc-badge    { color: #ea580c !important; border-color: #ea580c !important; background: #fff7ed !important; }

/* ===== 3D Secure - شعار شبكة البطاقة الديناميكي ===== */
.secure-3ds-header {
  display: flex !important;
  justify-content: flex-end !important;
  align-items: center !important;
  padding-bottom: 14px !important;
  border-bottom: 1px solid #e2e8f0 !important;
  margin-bottom: 18px !important;
  min-height: 36px !important;
}

.network-logo {
  font-size: 22px !important;
  font-weight: 900 !important;
  letter-spacing: 1.5px !important;
  line-height: 1 !important;
  padding: 4px 8px !important;
  border-radius: 4px !important;
  transition: opacity 0.2s !important;
}

.visa-logo {
  color: #1a1f71 !important;
  font-style: italic !important;
  font-family: "Times New Roman", serif !important;
  font-size: 26px !important;
}

.mc-logo {
  color: #eb001b !important;
  font-family: "Tajawal", Arial, sans-serif !important;
}

.mada-logo {
  color: #059669 !important;
  font-family: "Tajawal", Arial, sans-serif !important;
}

/* صف رقم البطاقة المشفر */
.font-mono {
  font-family: "Courier New", Courier, monospace !important;
  letter-spacing: 2px !important;
  direction: ltr !important;
  unicode-bidi: bidi-override !important;
}