/* ✅ Sticky Bar Base */
#sticky-atc{
  position: fixed;
  left:0; right:0;
  bottom: 0;
  z-index: 2147483647 !important;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid #e0e0e0;
  box-shadow: 0 -5px 20px rgba(0,0,0,0.08);
  padding: 12px 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: block !important;
}

/* الحالات الأساسية */
#sticky-atc.is-visible { transform: translateY(0); }
#sticky-atc.force-hide { display: none !important; }

/* =========================
   Desktop Layout
   ========================= */
#sticky-atc .kpt-sticky-atc__inner{
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* Left: Product Info */
#sticky-atc .kpt-sticky-atc__left{
  display: flex; align-items: center; gap: 16px;
}
#sticky-atc .kpt-sticky-atc__img{
  width: 52px; height: 52px; border-radius: 8px; object-fit: cover; border: 1px solid #eee;
}
#sticky-atc .kpt-sticky-atc__title{
  font-size: 16px; font-weight: 700; color: #111;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 350px;
}
#sticky-atc .kpt-sticky-atc__price{ font-size: 15px; font-weight: 600; color: #0073aa; }

/* Right: Actions */
#sticky-atc .kpt-sticky-atc__right{ display: flex; align-items: center; gap: 12px; }

/* Email Input Style */
.kpt-sticky-atc__field{ display: flex; flex-direction: column; width: 100%; max-width: 280px; }
.kpt-sticky-atc__inputwrap{
  display: flex; height: 42px;
  border: 1px solid #ccc; border-radius: 8px; overflow: hidden; background: #fff;
}
.kpt-sticky-atc__prefix{
  background: #f4f4f4; padding: 0 12px; display: flex; align-items: center; font-weight: 600; font-size: 13px; border-right: 1px solid #ddd; color: #555;
}
.kpt-sticky-atc__email{ border: none; padding: 0 12px; width: 100%; outline: none; font-size: 14px; }

/* Qty Style */
.kpt-sticky-atc__qty{
  display: flex; height: 42px;
  border: 1px solid #ccc; border-radius: 8px; overflow: hidden; background: #fff;
}
.kpt-sticky-atc__qtyinput{
  width: 50px; text-align: center; border: none; border-left: 1px solid #ddd; border-right: 1px solid #ddd; font-weight: 700; font-size: 15px;
}
.kpt-sticky-atc__qtybtn{
  width: 42px; background: #f9f9f9; border: none; cursor: pointer; font-size: 20px; font-weight: bold; color: #333;
}
.kpt-sticky-atc__qtybtn:hover{ background: #eee; }

/* Actions Container */
.kpt-sticky-atc__actions{ display: flex; gap: 10px; }

/* Buttons Base */
#sticky-atc .kpt-sticky-atc__btn{
  height: 42px; padding: 0 24px;
  background: #0073aa; /* ✅ لون أزرق موحد (Add to Cart) */
  color: #fff;
  border: none; border-radius: 8px;
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; text-transform: uppercase;
}
#sticky-atc .kpt-sticky-atc__btn:hover{ background: #005c87; }
#sticky-atc .kpt-sticky-atc__btn.loading{ opacity: 0.7; cursor: wait; }

/* ✅ Buy Now Button: لون أخضر موحد في الديسكتوب والموبايل */
#sticky-atc .kpt-sticky-atc__btn--buynow{ 
  background: #28a745; 
}
#sticky-atc .kpt-sticky-atc__btn--buynow:hover{ 
  background: #218838; 
}

.kpt-sticky-atc__error{ color: #d63638; font-size: 12px; margin-top: 2px; display: none; }

/* =========================
   ✅ Mobile Layout (Professional & Spacing Fix)
   ========================= */
@media (max-width: 767px){
  #sticky-atc{ 
    /* ✅ تعديل: رفع الشريط بمسافة 60 بيكسل ليظهر فوق القوائم السفلية */
    bottom: calc(60px + env(safe-area-inset-bottom)) !important; 
    padding: 10px 15px;
    z-index: 1 !important;
  }

  /* تنسيق الشريط */
  #sticky-atc .kpt-sticky-atc__inner{
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  /* السطر الأول: المنتج والسعر */
  #sticky-atc .kpt-sticky-atc__left{
    width: 100%;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 4px;
  }
  #sticky-atc .kpt-sticky-atc__img{
    width: 40px; height: 40px; border-radius: 50%;
  }
  #sticky-atc .kpt-sticky-atc__title{
    font-size: 14px; font-weight: 700; max-width: 100%;
  }
  #sticky-atc .kpt-sticky-atc__price{
    font-size: 14px; font-weight: 800; color: #d63638;
  }

  /* السطر الثاني: التنسيق المرن */
  #sticky-atc .kpt-sticky-atc__right{
    width: 100%;
    display: flex;
    flex-direction: row; /* صف أفقي */
    align-items: stretch; /* نفس الارتفاع */
    gap: 6px; /* مسافة صغيرة جداً لتوفير المكان */
    justify-content: space-between;
  }

  /* تنسيق جميع العناصر لتكون بنفس الارتفاع ومناسبة للمس */
  #sticky-atc .kpt-sticky-atc__field, 
  #sticky-atc .kpt-sticky-atc__qty, 
  #sticky-atc .kpt-sticky-atc__actions,
  #sticky-atc .kpt-sticky-atc__btn {
    height: 48px; /* ارتفاع مريح للإصبع */
    border-radius: 8px;
    flex-shrink: 0; /* منع الانضغاط غير المرغوب */
  }

  /* --- حالة المنتجات التي تحتاج إيميل --- */
  .has-email .kpt-sticky-atc__field {
    flex: 2; /* الإيميل يأخذ المساحة الأكبر */
    min-width: 0; /* يسمح للإيميل بالانضغاط قليلاً عند الضرورة */
  }
  
  .has-email .kpt-sticky-atc__btn,
  .has-email .kpt-sticky-atc__btn--full {
    flex: 1; /* الزر يأخذ باقي المساحة */
    font-size: 15px;
  }

  /* --- حالة المنتجات العادية (عداد + زرين) --- */
  .no-email .kpt-sticky-atc__qty {
    /* عرض ثابت للعداد لضمان عدم تشوه الأرقام */
    width: 100px; 
    flex: 0 0 100px;
    background: #f4f4f4;
    border-color: transparent;
    
    /* تصميم احترافي للعداد: إزالة الحدود الداخلية */
  }
  .no-email .kpt-sticky-atc__qtyinput {
    width: 100%;
    border: none; /* إزالة الحدود */
    background: #f4f4f4;
    font-size: 16px;
    color: #111;
  }
  .no-email .kpt-sticky-atc__qtybtn {
    background: transparent; /* أزرار شفافة على خلفية رمادية */
    border: none;
    color: #000;
    font-size: 22px;
  }

  .no-email .kpt-sticky-atc__actions {
    /* الأزرار تشغل باقي المساحة بالكامل */
    flex: 1;
    display: flex;
    flex-direction: row; /* متجاورة */
    gap: 6px;
    width: 100%;
  }

  .no-email .kpt-sticky-atc__btn {
    flex: 1; /* تقسيم المساحة بالتساوي بين زر الإضافة وزر الشراء */
    font-size: 13px; /* خط أصغر لتتناسب مع 3 عناصر */
    font-weight: 700;
    padding: 0 5px; /* حشوة صغيرة جداً للسماح للنص بالمكان */
  }

  /* تنسيق الإيميل */
  .kpt-sticky-atc__qtyinput{ font-size: 15px; }
  .kpt-sticky-atc__qtybtn{ font-size: 18px; }
  #sticky-atc .kpt-sticky-atc__prefix{ display: none; }
  #sticky-atc .kpt-sticky-atc__email{ font-size: 14px; }

  /* ✅ تأكيد لون Buy Now في الموبايل ليطابق الديسكتوب (أخضر) */
  #sticky-atc .kpt-sticky-atc__btn--buynow{
    background: #28a745;
  }
}