/* ===========================
   المتغيرات العامة
   =========================== */
:root {
  --checkout-bg: #f3f4f6;
  --checkout-card-bg: #ffffff;
  --checkout-border: #e5e7eb;
  --checkout-muted: #6b7280;
  --checkout-text: #111827;
  --checkout-radius: 1.1rem;

  /* من ألوان اللوجو / الهيدر */
  --checkout-brand: #0ea5a6;
  --checkout-accent: #f97316; /* برتقالي زر السلة */
}

/* نلغي البادينج حق الهيدر الثابت من header.css في هذه الصفحة */
body {
  background: var(--checkout-bg);
  padding-top: 0;
  font-family: inherit;
  color: var(--checkout-text);
}

/* ===========================
   الحاوية العامة
   =========================== */

.checkout-page {
  max-width: 980px;
  margin: 32px auto;
  padding: 0 1rem 2.5rem;
  /* مساحة إضافية أسفل المحتوى عشان الفوتر الثابت ما يغطيه */
  padding-bottom: 120px;
}

/* ===========================
   Grid Layout
   =========================== */

.checkout-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .checkout-grid {
    flex-direction: row;
    align-items: flex-start;
  }

  .checkout-card:first-of-type {
    flex: 3;
  }

  .checkout-card:last-of-type {
    flex: 2;
  }
}

/* الكروت الرئيسية (بيانات الزبون + ملخص الطلب) */
.checkout-card {
  background: var(--checkout-card-bg);
  border-radius: var(--checkout-radius);
  padding: 1rem 1.1rem 1.2rem;
  border: 1px solid var(--checkout-border);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.06);
}

.checkout-title {
  margin: 0 0 0.9rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--checkout-text);
}

/* ===========================
   Customer Form
   =========================== */

#checkout-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

#checkout-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--checkout-muted);
  margin-bottom: 0.85rem;
}

#checkout-form label > span {
  font-weight: 500;
  color: var(--checkout-text);
}

/* الحقول النصية + textarea + select */
#checkout-form input,
#checkout-form textarea,
#checkout-form select {
  width: 100%;
  box-sizing: border-box;
  border-radius: 0.9rem;
  border: 1px solid var(--checkout-border);
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
  background: #f9fafb;
  color: var(--checkout-text);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease;
}

/* ارتفاع موحد للإنبتات والدروب داون */
#checkout-form input,
#checkout-form select {
  height: 42px;
  line-height: 1.2;
}

#checkout-form input::placeholder,
#checkout-form textarea::placeholder {
  color: #9ca3af;
}

#checkout-form input:focus,
#checkout-form textarea:focus,
#checkout-form select:focus {
  outline: none;
  border-color: var(--checkout-accent);
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.18);
}

#checkout-form textarea {
  resize: vertical;
  min-height: 70px;
  border-radius: 1rem;
}

/* ===========================
   ستايل رقم الهاتف (+968 + 8 أرقام)
   =========================== */

.phone-field .phone-input {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* في RTL نخلي +968 في الجهة الثانية (يسار) والإنبت يكون يمين */
html[dir="rtl"] .phone-field .phone-input {
  flex-direction: row-reverse;
}

.phone-prefix {
  height: 42px;
  padding: 0 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f3f4f6;
  color: #111827;
  font-size: 0.9rem;
  border: 1px solid #e5e7eb;
  white-space: nowrap;
  direction: ltr;
  text-align: left;
  unicode-bidi: bidi-override;
}

.phone-field .phone-input input[type="tel"] {
  flex: 1;
  height: 42px;
  border-radius: 999px;
}

.field-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: #6b7280;
}

/* ===========================
   ستايل الـ select (المحافظة / الولاية)
   =========================== */

#checkout-form select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #9ca3af 50%),
    linear-gradient(135deg, #9ca3af 50%, transparent 50%);
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

/* RTL: السهم في اليسار، والنص يبدأ من اليمين */
html[dir="rtl"] #checkout-form select {
  background-position:
    0.9rem center,
    1.4rem center;      /* السهمين الصغار */
  padding-left: 2rem;   /* مساحة للسهم في اليسار */
  padding-right: 0.9rem;
  text-align: right;
}

#checkout-form select:disabled {
  background-color: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
}

/* ===========================
   Order Summary
   =========================== */

.checkout-items {
  border-radius: 0.9rem;
  background: #f9fafb;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.75rem;
  max-height: 260px;
  overflow-y: auto;
}

/* كل سطر منتج في الملخص (js يضيف .checkout-item) */
.checkout-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.86rem;
  padding: 0.35rem 0;
  border-bottom: 1px dashed #e5e7eb;
}

.checkout-item:last-child {
  border-bottom: none;
}

.checkout-item span:first-child {
  color: var(--checkout-text);
}

.checkout-item span:last-child {
  font-weight: 600;
  color: #111827;
}

/* صندوق الإجماليات */
.checkout-totals {
  border-radius: 0.9rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  padding: 0.7rem 0.9rem;
  font-size: 0.86rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.checkout-totals > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.checkout-totals span:first-child {
  color: var(--checkout-muted);
}

.checkout-totals span:last-child {
  color: #111827;
  font-weight: 600;
}

/* ✅ NEW: Pickup office row (within totals) */
.checkout-pickup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.checkout-pickup-row span:first-child {
  color: var(--checkout-muted);
}

/* اسم المكتب */
.checkout-pickup-row span:last-child {
  color: #0f766e;
  font-weight: 800;
}

/* صف الإجمالي النهائي */
.checkout-total-row span:last-child {
  color: var(--checkout-accent);
  font-size: 0.95rem;
}

/* ===========================
   الأزرار (مودرن)
   =========================== */

/* ممكن ما تُستخدم داخل الكارد بعد ما صارت الأزرار في الفوتر الثابت،
   لكن نخليها لو احتجناها لاحقًا */
.checkout-actions {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: row;
  gap: 0.6rem;
}

@media (max-width: 480px) {
  .checkout-actions {
    flex-direction: column-reverse;
  }
}

/* زر أساسي (إتمام الشراء) */
.btn-primary {
  flex: 1;
  border: none;
  border-radius: 0.9rem;
  padding: 0.65rem 0.9rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--checkout-accent), #fb923c);
  color: #fff;
  box-shadow: 0 8px 18px rgba(249, 115, 22, 0.45);
  text-align: center;
  transition:
    transform 0.08s ease,
    box-shadow 0.16s ease,
    filter 0.12s ease;
}

.btn-primary:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(249, 115, 22, 0.55);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 5px 12px rgba(249, 115, 22, 0.45);
}

/* تعطيل زر الإتمام أثناء الإرسال */
.btn-primary:disabled {
  opacity: 0.7;
  cursor: default;
  transform: none;
  box-shadow: 0 5px 12px rgba(249, 115, 22, 0.35);
}

/* زر ثانوي (رجوع) */
.btn-secondary {
  flex: 0 0 auto;
  min-width: 120px;
  border-radius: 0.9rem;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: var(--checkout-muted);
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.06);
  transition:
    background 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.08s ease,
    color 0.12s ease;
}

.btn-secondary:hover {
  background: #f3f4f6;
  color: #374151;
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(15, 23, 42, 0.08);
}

/* ===========================
   الفوتر الثابت أسفل الشاشة
   =========================== */

.checkout-footer-fixed {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.06);
}

.checkout-footer-inner {
  max-width: 980px; /* نفس عرض الصفحة */
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 480px) {
  .checkout-footer-inner {
    flex-direction: column;
  }

  .checkout-page {
    padding-inline: 0.75rem;
  }

  .checkout-card {
    padding-inline: 0.9rem;
  }
}
