/* ===== تصميم احترافي لصفحة Checkout ===== */

.woocommerce-checkout {
  --khaddar-checkout-primary: var(--ast-global-color-0, var(--e-global-color-primary, var(--wp--preset--color--primary, #096017)));
  --khaddar-checkout-secondary: var(--ast-global-color-1, var(--e-global-color-secondary, var(--wp--preset--color--secondary, var(--wp--preset--color--accent, #ef9a1f))));
  --khaddar-checkout-background: var(--wp--preset--color--base, var(--wp--preset--color--background, #fafafa));
  --khaddar-checkout-surface: var(--wp--preset--color--white, #fff);
  --khaddar-checkout-surface-soft: color-mix(in srgb, var(--khaddar-checkout-secondary) 8%, var(--khaddar-checkout-surface));
  --khaddar-checkout-surface-selected: color-mix(in srgb, var(--khaddar-checkout-secondary) 28%, var(--khaddar-checkout-surface));
  --khaddar-checkout-text: var(--wp--preset--color--contrast, var(--ast-global-color-3, #333));
  --khaddar-checkout-muted-text: var(--ast-global-color-2, #222);
  --khaddar-checkout-border: color-mix(in srgb, var(--khaddar-checkout-text) 12%, var(--khaddar-checkout-surface));
  --khaddar-checkout-shadow: rgba(0,0,0,0.05);
}

/* تنسيق عام للصفحة */
.checkout.woocommerce-checkout {
  background: var(--khaddar-checkout-background);
  border-radius: 15px;
  padding: 15px;
  max-width: 800px;
  margin: 0 auto;
  font-family: "Cairo", "Tajawal", sans-serif;
  direction: rtl;
}

/* عناوين الأقسام */
.woocommerce-checkout h3,
.woocommerce-checkout h2 {
  color: var(--khaddar-checkout-primary);
  font-weight: 700;
  font-size: 18px;
  border-right: 4px solid var(--khaddar-checkout-primary);
  padding-right: 8px;
  margin-bottom: 15px;
}

/* صندوق معلومات العميل */
.woocommerce-billing-fields,
.woocommerce-shipping-fields {
  background: var(--khaddar-checkout-surface);
  padding: 15px;
  border-radius: 12px;
  border: 1.5px solid var(--khaddar-checkout-border);
  box-shadow: 0 2px 6px var(--khaddar-checkout-shadow);
}

/* الحقول */
.woocommerce-checkout input.input-text,
.woocommerce-checkout select,
.woocommerce-checkout textarea {
  width: 100%;
  background: var(--khaddar-checkout-surface);
  border: 1.5px solid var(--khaddar-checkout-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  transition: 0.3s;
}

.woocommerce-checkout input.input-text:focus,
.woocommerce-checkout select:focus,
.woocommerce-checkout textarea:focus {
  border-color: var(--khaddar-checkout-primary);
  box-shadow: 0 0 5px color-mix(in srgb, var(--khaddar-checkout-secondary) 40%, transparent);
  outline: none;
}

/* ===== قسم ملخص الطلب ===== */
.woocommerce-checkout-review-order-table {
  background: var(--khaddar-checkout-surface);
  border-radius: 12px;
  border: 1.5px solid var(--khaddar-checkout-border);
  box-shaow: 0 2px 6px var(--khaddar-checkout-shadow);
  padding: 10px !important;
  margin-bottom: 20px;
  width: 100%;
}

/* رؤوس الجدول */
.woocommerce-checkout-review-order-table th {
  color: var(--khaddar-checkout-text);
  font-weight: 600;
  border-bottom: 2px solid var(--khaddar-checkout-primary);
  padding-bottom: 5px;
}

/* الصفوف */
.woocommerce-checkout-review-order-table td {
  padding: 8px 0;
  border-bottom: 1px dashed var(--khaddar-checkout-border);
}

/* الإجمالي */
tr.order-total th,
tr.order-total td {
  font-size: 19px;
}

/* ===== قسم الشحن (استلام الطلب) ===== */
.woocommerce-shipping-totals.shipping {
  display: block !important;
  width: 100% !important;
  max-width: 100%;
  background: var(--khaddar-checkout-surface);
  border: none !important;
  border-radius: 12px;
  padding: 1px 0;
  margin: 0 !important;
  box-sizing: border-box;
  overflow: hidden;
}

.woocommerce-shipping-totals.shipping td {
  display: block !important;
  width: 100% !important;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.woocommerce-shipping-totals.shipping th {
  display: block;
  text-align: right;
  font-size: 17px;
  font-weight: 700;
  color: var(--khaddar-checkout-muted-text);
  margin: 0 0 10px;
  border-bottom: 2px solid var(--khaddar-checkout-primary);
  padding-bottom: 4px;
}

.woocommerce-shipping-methods {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
  width: 100%;
  max-width: 100%;
  display: grid;
  gap: 10px;
}

.woocommerce-shipping-methods li {
  position: relative;
  display: block !important;
  direction: rtl;
  padding: 0 32px 0 0 !important;
  margin: 0 !important;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.woocommerce-shipping-totals.shipping label {
  position: relative;
  display: block !important;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 11px 14px;
  background: var(--khaddar-checkout-surface-soft);
  border: 1.5px solid var(--khaddar-checkout-secondary);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  white-space: normal;
  overflow: hidden;
  overflow-wrap: break-word;
  word-break: normal;
  box-sizing: border-box;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--khaddar-checkout-text) 6%, transparent);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.woocommerce-shipping-totals.shipping label:hover {
  background: var(--khaddar-checkout-secondary);
  color: var(--khaddar-checkout-surface);
}

.woocommerce-shipping-totals.shipping label:hover .amount {
  color: var(--khaddar-checkout-surface);
}

.woocommerce-shipping-totals.shipping input[type="radio"]:checked + label {
  background: var(--khaddar-checkout-secondary);
  color: var(--khaddar-checkout-surface);
}

.woocommerce-shipping-totals.shipping input[type="radio"]:checked + label .amount {
  color: var(--khaddar-checkout-surface);
}

.woocommerce-shipping-totals.shipping input[type="radio"] {
  position: absolute;
  top: 50%;
  right: 0;
  left: auto;
  opacity: 1;
  pointer-events: auto;
  accent-color: var(--khaddar-checkout-secondary);
  transform: translateY(-50%) scale(1.15);
  margin: 0 !important;
}

/* ===== زر تأكيد الطلب ===== */
#place_order {
  color: var(--khaddar-checkout-surface) !important;
  border: none !important;
  border-radius: 12px !important;
  width: 100% !important;
  padding: 14px !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  transition: 0.3s;
  text-align: center;
}

#place_order:hover {
}

/* رسالة الدفع */
.woocommerce-checkout #payment {
  background: var(--khaddar-checkout-surface);
  border-radius: 12px;
  padding: 1px 1px;
  border: 1.5px solid var(--khaddar-checkout-border);
}

/* ===== تحسين الموبايل ===== */
@media (max-width: 768px) {
  .checkout.woocommerce-checkout {
    padding: 1px;
  }

  .woocommerce-checkout h3 {
    font-size: 16px;
  }
}

.woocommerce-js ul#shipping_method li input[type="radio"] {
  margin: 0 !important;
  transform: translateY(-50%) scale(1.15);
}

/* قلب الترتيب بين الاسم والسعر في خيارات الشحن */
.woocommerce ul#shipping_method li label {
  display: block !important;
  text-align: center;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow: hidden;
  overflow-wrap: break-word;
  word-break: normal;
  box-sizing: border-box;
}

/* تحسين شكل السعر */
.woocommerce ul#shipping_method li label .amount {
  display: block;
  font-weight: bold;
  color: inherit;
  margin: 4px 0 0;
  white-space: nowrap;
}

/* ✅ تنسيق الإطار الخارجي في صفحة الـ Checkout */
.woocommerce-checkout-review-order,
.woocommerce-checkout-review-order table,
.woocommerce-checkout-review-order table th,
.woocommerce-checkout-review-order table td {
  border: none !important;
}

/* ✅ الإطار العام حول قسم الطلب */
#order_review {
  border: 2px solid var(--khaddar-checkout-secondary) !important; /* الإطار البرتقالي */
  border-radius: 20px !important;       /* الحواف الدائرية */
  padding: 15px !important;
  background: var(--khaddar-checkout-surface-soft); /* خلفية فاتحة متناسقة مع لون الموقع */
  box-shadow: 0 4px 10px var(--khaddar-checkout-shadow); /* ظل خفيف وأنيق */
  margin: 10px auto;
  width: 95%;
}

/* ✅ العنوان "طلبك" بلون برتقالي */
#order_review_heading {
  color: var(--khaddar-checkout-secondary) !important;
  font-weight: bold;
  font-size: 18px;
  text-align: right;
  border-bottom: 2px solid var(--khaddar-checkout-secondary);
  padding-bottom: 5px;
  margin-bottom: 10px;
}

/* ✅ جعل الجداول داخل الطلب أكثر جمالاً */
#order_review table {
  width: 100%;
  border-collapse: separate !important;
  border-spacing: 0 5px;
}

#order_review td,
#order_review th {
  border: none !important;
}

/* ✅ ضبط الزوايا الداخلية */
#order_review .shop_table {
  border-radius: 15px !important;
  overflow: hidden;
}

/* 🚚 إضافة عنوان واضح داخل قسم الشحن */
.woocommerce-shipping-totals.shipping th::before {
  content: "🚚 اختر طريقة الشحن:";
  display: block;
  color: var(--khaddar-checkout-secondary);
  font-weight: bold;
  font-size: 17px;
  margin-bottom: 10px;
}

/* 🚫 إخفاء كلمة "الشحن" الأصلية */
.woocommerce-shipping-totals.shipping th {
  display: none !important;
}

/* 🧾 إزالة الهامش السفلي من جدول مراجعة الطلب */
.shop_table.woocommerce-checkout-review-order-table {
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
}

/* 🧾 إزالة الهامش السفلي من جدول مراجعة الطلب */
.form-row.place-order {
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
}

.woocommerce-billing-fields .form-row-first,
.woocommerce-billing-fields .form-row-last {
  width: 100% !important;
  max-width: 100% !important;
  float: none !important;
  clear: both !important;
}

.woocommerce-additional-fields__field-wrapper #order_comments_field {
  display: none;
}

.woocommerce-checkout [class*="whatsapp"],
.woocommerce-checkout [class*="WhatsApp"],
.woocommerce-checkout [href*="wa.me"],
.woocommerce-checkout [href*="api.whatsapp.com"] {
  visibility: visible !important;
  opacity: 1 !important;
  z-index: 999999 !important;
}

/* ===== WooCommerce Delivery Day Selection (Excluding Friday) ===== */
.delivery-days-container {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.day-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 74px;
  padding: 14px 10px;
  border: 1.5px solid var(--khaddar-checkout-border);
  border-radius: 14px;
  background: var(--khaddar-checkout-surface);
  cursor: pointer;
  text-align: center;
  min-width: 0;
  color: var(--khaddar-checkout-text);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--khaddar-checkout-text) 7%, transparent);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.day-card strong {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.4;
}

.day-card:hover {
  border-color: var(--khaddar-checkout-secondary);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--khaddar-checkout-text) 10%, transparent);
}

.day-card.selected {
  border-color: var(--khaddar-checkout-secondary);
  background: var(--khaddar-checkout-surface-selected);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--khaddar-checkout-secondary) 24%, transparent);
}

.day-card.selected::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 10px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--khaddar-checkout-secondary);
}

@media (max-width: 480px) {
  .delivery-days-container {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 16px;
  }

  .day-card {
    min-height: 58px;
    padding: 10px 6px;
    border-radius: 12px;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--khaddar-checkout-text) 6%, transparent);
  }

  .day-card strong {
    font-size: 12px;
    line-height: 1.35;
  }

  .day-card.selected::after {
    top: 7px;
    left: 7px;
    width: 7px;
    height: 7px;
  }

  .woocommerce-shipping-methods li {
    padding: 0 28px 0 0 !important;
    margin: 0 !important;
  }

  .woocommerce-shipping-totals.shipping label {
    padding: 10px 8px;
    font-size: 12.5px;
    line-height: 1.4;
    border-radius: 10px;
  }

  .woocommerce ul#shipping_method li label .amount {
    margin-top: 3px;
  }

  .woocommerce-shipping-totals.shipping input[type="radio"],
  .woocommerce-js ul#shipping_method li input[type="radio"] {
    transform: translateY(-50%) scale(1.05);
  }
}

/* ===== Khaddar Feedback ===== */
.khaddar-feedback-widget,
.khaddar-feedback-form {
  --khaddar-feedback-primary: #096017;
  --khaddar-feedback-secondary: #f56601;
  --khaddar-feedback-surface: var(--wp--preset--color--white, #fff);
  --khaddar-feedback-text: var(--wp--preset--color--contrast, #222);
  --khaddar-feedback-border: color-mix(in srgb, var(--khaddar-feedback-text) 13%, var(--khaddar-feedback-surface));
  font-family: "Cairo", "Tajawal", sans-serif;
}

.khaddar-feedback-widget {
  position: fixed;
  right: 18px;
  bottom: 88px;
  z-index: 999998;
  direction: rtl;
}

.khaddar-feedback-toggle {
  border: none;
  border-radius: 999px;
  background: var(--khaddar-feedback-secondary);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  padding: 12px 18px;
  box-shadow: 0 10px 26px rgba(0,0,0,0.18);
}

.khaddar-feedback-panel {
  position: absolute;
  right: 0;
  bottom: 56px;
  width: min(340px, calc(100vw - 28px));
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.khaddar-feedback-panel.is-closing {
  opacity: 0;
  transform: translateY(10px);
}

.khaddar-feedback-form {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--khaddar-feedback-border);
  border-radius: 16px;
  background: var(--khaddar-feedback-surface);
  color: var(--khaddar-feedback-text);
  box-shadow: 0 14px 34px rgba(0,0,0,0.18);
  direction: rtl;
}

.khaddar-feedback-head {
  display: grid;
  gap: 2px;
  text-align: right;
}

.khaddar-feedback-head strong {
  color: var(--khaddar-feedback-primary);
  font-size: 17px;
}

.khaddar-feedback-head span {
  color: color-mix(in srgb, var(--khaddar-feedback-text) 70%, transparent);
  font-size: 13px;
}

.khaddar-feedback-stars {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  gap: 4px;
}

.khaddar-feedback-star {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 999px;
  background: color-mix(in srgb, var(--khaddar-feedback-secondary) 10%, var(--khaddar-feedback-surface));
  color: color-mix(in srgb, var(--khaddar-feedback-text) 35%, var(--khaddar-feedback-surface));
  cursor: pointer;
  font-size: 23px;
  line-height: 1;
  transition: transform 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.khaddar-feedback-star:hover,
.khaddar-feedback-star.is-active {
  background: color-mix(in srgb, var(--khaddar-feedback-secondary) 18%, var(--khaddar-feedback-surface));
  color: var(--khaddar-feedback-secondary);
  transform: translateY(-1px);
}

.khaddar-feedback-form input,
.khaddar-feedback-form textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--khaddar-feedback-border);
  border-radius: 10px;
  background: var(--khaddar-feedback-surface);
  color: var(--khaddar-feedback-text);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
}

.khaddar-feedback-form textarea {
  resize: vertical;
  min-height: 96px;
}

.khaddar-feedback-form input:focus,
.khaddar-feedback-form textarea:focus {
  border-color: var(--khaddar-feedback-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--khaddar-feedback-primary) 14%, transparent);
}

.khaddar-feedback-submit {
  border: none;
  border-radius: 12px;
  background: var(--khaddar-feedback-secondary);
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 800;
  padding: 12px;
}

.khaddar-feedback-submit:disabled {
  cursor: wait;
  opacity: 0.7;
}

.khaddar-feedback-response {
  min-height: 18px;
  margin: 0;
  font-size: 13px;
  text-align: center;
}

.khaddar-feedback-response.is-success {
  color: var(--khaddar-feedback-primary);
}

.khaddar-feedback-response.is-error {
  color: #b42318;
}

.khaddar-feedback-trap {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

@media (max-width: 480px) {
  .khaddar-feedback-widget {
    right: 12px;
    bottom: 78px;
  }

  .khaddar-feedback-panel {
    width: min(320px, calc(100vw - 24px));
  }
}
