/* ==============================================================
   checkout.css  v3
   التصميم الجديد لصفحة إتمام الطلب — تمتين
   لا inline styles. RTL-first. Responsive.
   ============================================================== */

/* ── متغيرات محلية (تعتمد على متغيرات main.css) ── */
:root {
  --co-primary:     var(--primary-color, #003C77);
  --co-primary-lt:  var(--primary-light, #e8f0fb);
  --co-accent:      var(--accent-color,  #0ea5e9);
  --co-success:     #0a7a3b;
  --co-success-lt:  #ecfdf5;
  --co-error:       #c0392b;
  --co-error-lt:    #fef2f2;
  --co-warning:     #856404;
  --co-warning-lt:  #fffbeb;
  --co-text:        #1e293b;
  --co-text-soft:   #64748b;
  --co-border:      #e2e8f0;
  --co-bg:          #f8fafc;
  --co-card:        #ffffff;
  --co-radius:      14px;
  --co-radius-sm:   8px;
  --co-shadow:      0 2px 16px rgba(0, 60, 119, 0.08);
  --co-shadow-lg:   0 8px 32px rgba(0, 60, 119, 0.14);
  --co-transition:  0.2s ease;
}

/* ── الصفحة الرئيسية ── */
.checkout-main {
  min-height: 70vh;
  background: var(--co-bg);
  padding: 16px 12px 100px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Toast / إشعار
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-toast {
  position: fixed;
  top: 80px;
  right: 50%;
  transform: translateX(50%) translateY(-20px);
  background: var(--co-error);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--co-radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--co-transition), transform var(--co-transition);
  max-width: 90vw;
  text-align: center;
  box-shadow: var(--co-shadow-lg);
}

.checkout-toast--visible {
  opacity: 1;
  transform: translateX(50%) translateY(0);
  pointer-events: auto;
}

.checkout-toast--success { background: var(--co-success); }
.checkout-toast--error   { background: var(--co-error);   }
.checkout-toast--info    { background: var(--co-primary);  }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   حالة السلة الفارغة
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 50vh;
  text-align: center;
}

.checkout-empty-state__icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--co-primary-lt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--co-primary);
}

.checkout-empty-state h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--co-text);
  margin: 0;
}

.checkout-empty-state p {
  color: var(--co-text-soft);
  margin: 0;
  font-size: 0.95rem;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Wrap الرئيسي
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-wrap {
  max-width: 1120px;
  margin: 0 auto;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Header: Breadcrumb + Steps
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-header {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Breadcrumb */
.checkout-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--co-text-soft);
}

.checkout-breadcrumb a {
  color: var(--co-text-soft);
  text-decoration: none;
  transition: color var(--co-transition);
}

.checkout-breadcrumb a:hover { color: var(--co-primary); }

.checkout-breadcrumb span { color: var(--co-primary); font-weight: 600; }

.checkout-breadcrumb__sep {
  font-size: 0.65rem;
  color: var(--co-border);
  transform: scaleX(-1);
  display: inline-block;
}

/* خطوات الطلب */
.checkout-steps {
  display: flex;
  align-items: center;
  gap: 0;
}

.checkout-steps__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--co-text-soft);
  white-space: nowrap;
}
.checkout-steps__item span { display: none; }

.checkout-steps__num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--co-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--co-card);
  transition: all var(--co-transition);
}

.checkout-steps__item--done .checkout-steps__num {
  background: var(--co-success);
  border-color: var(--co-success);
  color: #fff;
}

.checkout-steps__item--active .checkout-steps__num {
  background: var(--co-primary);
  border-color: var(--co-primary);
  color: #fff;
}

.checkout-steps__item--active {
  color: var(--co-primary);
}

.checkout-steps__item--done {
  color: var(--co-success);
}

.checkout-steps__line {
  flex: 1;
  height: 2px;
  background: var(--co-border);
  margin: 0 8px;
  margin-bottom: 22px;
}

.checkout-steps__line--done {
  background: var(--co-success);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   تخطيط عمودين
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}

/* عمود الفورم */
.checkout-form-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* عمود الملخص */
.checkout-summary-col {
  position: static;
  order: -1;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   البطاقة الأساسية
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-card {
  background: var(--co-card);
  border-radius: var(--co-radius);
  box-shadow: var(--co-shadow);
  padding: 18px 14px;
  border: 1px solid var(--co-border);
}

.checkout-card--sticky {
  position: sticky;
  top: 80px;
}

/* رأس البطاقة */
.checkout-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1.5px solid var(--co-border);
}

.checkout-card__icon {
  width: 38px;
  height: 38px;
  border-radius: var(--co-radius-sm);
  background: var(--co-primary-lt);
  color: var(--co-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.checkout-card__title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--co-text);
  margin: 0;
}

.checkout-card__title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Grid الحقول
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-grid {
  display: grid;
  gap: 16px;
}

.checkout-grid--2 {
  grid-template-columns: 1fr;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   حقل الإدخال
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* بين الشبكة والحقل التالي */
.checkout-grid + .checkout-field,
.checkout-field + .checkout-field {
  margin-top: 16px;
}

.checkout-grid { margin-bottom: 0; }

.checkout-card__head + .checkout-grid,
.checkout-card__head + .checkout-field {
  margin-top: 0;
}

.checkout-field__label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--co-text);
}

.checkout-field__required {
  color: var(--co-error);
  margin-right: 2px;
}

.checkout-field__optional {
  color: var(--co-text-soft);
  font-weight: 400;
  font-size: 0.82rem;
}

/* غلاف الإدخال */
.checkout-field__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.checkout-field__input-wrap--area {
  align-items: flex-start;
}

.checkout-field__icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--co-text-soft);
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 1;
}

.checkout-field__icon--top {
  top: 14px;
  transform: none;
}

.checkout-field__input {
  width: 100%;
  padding: 11px 38px 11px 14px;
  border: 1.5px solid var(--co-border);
  border-radius: var(--co-radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--co-text);
  background: var(--co-bg);
  transition: border-color var(--co-transition), box-shadow var(--co-transition);
  outline: none;
}

.checkout-field__input:focus {
  border-color: var(--co-primary);
  box-shadow: 0 0 0 3px rgba(0, 60, 119, 0.1);
  background: var(--co-card);
}

.checkout-field__textarea {
  width: 100%;
  padding: 11px 38px 11px 14px;
  border: 1.5px solid var(--co-border);
  border-radius: var(--co-radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--co-text);
  background: var(--co-bg);
  resize: vertical;
  min-height: 76px;
  transition: border-color var(--co-transition), box-shadow var(--co-transition);
  outline: none;
  line-height: 1.6;
}

.checkout-field__textarea:focus {
  border-color: var(--co-primary);
  box-shadow: 0 0 0 3px rgba(0, 60, 119, 0.1);
  background: var(--co-card);
}

/* حالة الخطأ */
.checkout-field--error .checkout-field__input,
.checkout-field--error .checkout-field__textarea {
  border-color: var(--co-error);
}

.checkout-field--error .checkout-field__input:focus,
.checkout-field--error .checkout-field__textarea:focus {
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1);
}

.checkout-field__error {
  font-size: 0.8rem;
  color: var(--co-error);
  display: none;
}

.checkout-field__error--visible {
  display: block;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   note عروض الأسعار
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-quote-note {
  background: var(--co-warning-lt);
  border: 1.5px solid #fcd34d;
  border-radius: var(--co-radius-sm);
  padding: 14px 16px;
  font-size: 0.88rem;
  color: var(--co-warning);
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
}

.checkout-quote-note i { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   ملخص الطلب
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-summary__count {
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--co-primary-lt);
  color: var(--co-primary);
  padding: 2px 9px;
  border-radius: 20px;
}

/* قائمة المنتجات */
.checkout-summary__items {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 220px;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

.checkout-summary__items::-webkit-scrollbar {
  width: 4px;
}
.checkout-summary__items::-webkit-scrollbar-track { background: transparent; }
.checkout-summary__items::-webkit-scrollbar-thumb {
  background: var(--co-border);
  border-radius: 10px;
}

/* صف منتج */
.checkout-summary__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--co-border);
}

.checkout-summary__item:last-child { border-bottom: none; }

.checkout-summary__img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: var(--co-radius-sm);
  border: 1px solid var(--co-border);
  background: var(--co-bg);
  flex-shrink: 0;
}

.checkout-summary__info {
  flex: 1;
  min-width: 0;
}

.checkout-summary__name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--co-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.checkout-summary__sku {
  font-size: 0.75rem;
  color: var(--co-text-soft);
  font-family: monospace;
  margin-top: 2px;
}

.checkout-summary__qty {
  font-size: 0.78rem;
  color: var(--co-text-soft);
  margin-top: 4px;
}

.checkout-summary__price {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--co-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Loading placeholder */
.checkout-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px;
  color: var(--co-text-soft);
  font-size: 0.9rem;
}

.checkout-loading i { font-size: 1.4rem; color: var(--co-primary); }

/* فارغة */
.checkout-empty {
  text-align: center;
  padding: 24px;
  color: var(--co-text-soft);
  font-size: 0.9rem;
}

.checkout-empty i { font-size: 2rem; display: block; margin-bottom: 8px; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   إجماليات
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-totals {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1.5px solid var(--co-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkout-totals__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: var(--co-text-soft);
}

.checkout-totals__row span:last-child { font-weight: 600; color: var(--co-text); }

.checkout-totals__row--grand {
  font-size: 1rem;
  font-weight: 700;
  color: var(--co-text);
  padding-top: 8px;
  border-top: 1.5px dashed var(--co-border);
  margin-top: 4px;
}

.checkout-totals__row--grand span:last-child {
  color: var(--co-primary);
  font-size: 1.1rem;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   الأزرار
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--co-radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all var(--co-transition);
  text-decoration: none;
}

.checkout-btn--primary {
  background: var(--co-primary);
  color: #fff;
}

.checkout-btn--primary:hover:not(:disabled) {
  background: #002856;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 60, 119, 0.3);
}

.checkout-btn--primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.checkout-btn--ghost {
  background: transparent;
  color: var(--co-primary);
  border: 1.5px solid var(--co-primary);
}

.checkout-btn--ghost:hover:not(:disabled) {
  background: var(--co-primary-lt);
}

.checkout-btn--full { width: 100%; }

/* wrap زر الإرسال */
.checkout-submit-wrap {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* زر الإرسال — موبايل أولاً */
.checkout-submit-wrap--mobile { display: flex; }
.checkout-summary-col .checkout-submit-wrap { display: none; }

.checkout-secure {
  text-align: center;
  font-size: 0.78rem;
  color: var(--co-text-soft);
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.checkout-secure i { color: var(--co-success); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   ضمانات
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.checkout-trust {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--co-border);
}

.checkout-trust__item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--co-text-soft);
}

.checkout-trust__item i {
  color: var(--co-success);
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   نافذة تسجيل الدخول
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--co-transition);
}

.auth-modal--visible {
  opacity: 1;
  pointer-events: auto;
}

.auth-modal__box {
  background: var(--co-card);
  border-radius: var(--co-radius);
  padding: 32px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--co-shadow-lg);
  transform: translateY(20px);
  transition: transform var(--co-transition);
}

.auth-modal--visible .auth-modal__box {
  transform: translateY(0);
}

.auth-modal__icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--co-primary-lt);
  color: var(--co-primary);
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.auth-modal__title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--co-text);
  margin: 0 0 10px;
}

.auth-modal__desc {
  font-size: 0.88rem;
  color: var(--co-text-soft);
  margin: 0 0 22px;
  line-height: 1.6;
}

.auth-modal__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-modal__cancel {
  background: none;
  border: none;
  color: var(--co-text-soft);
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 12px;
  font-family: inherit;
  transition: color var(--co-transition);
}

.auth-modal__cancel:hover { color: var(--co-text); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Responsive (mobile-first)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
@media (min-width: 601px) {
  .checkout-main { padding: 20px 16px 90px; }
  .checkout-header { gap: 20px; margin-bottom: 24px; }
  .checkout-steps__item { gap: 6px; }
  .checkout-steps__item span { display: inline; }
  .checkout-card { padding: 24px; }
  .checkout-card__title { font-size: 1.05rem; }
  .checkout-grid--2 { grid-template-columns: 1fr 1fr; }
  .checkout-btn { font-size: 0.95rem; padding: 13px 24px; }
}

@media (min-width: 901px) {
  .checkout-main { padding: 24px 16px 80px; }
  .checkout-layout { grid-template-columns: 1fr 380px; }
  .checkout-summary-col {
    position: sticky;
    top: 80px;
    order: 0;
  }
  .checkout-summary__items { max-height: 320px; }
  .checkout-submit-wrap--mobile { display: none; }
  .checkout-summary-col .checkout-submit-wrap { display: flex; }
}
