
/* 1. المتغيرات والخطوط */
:root {
  --primary-color: #f7c300;
  --secondary-color: #4a4a4a;
  --bg-light: #f3f6f9; /* لون خلفية أهدأ */
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --shadow-soft: 0 10px 40px -10px rgba(0,0,0,0.08);
}

body {
  font-family: "Cairo", sans-serif;
  background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
  color: var(--secondary-color);
  scroll-behavior: smooth;
  min-height: 100vh;
  position: relative;
}

/* خلفية جمالية خفيفة */
body::before {
    content: '';
    position: fixed;
    top: -10%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.04) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}
body::after {
    content: '';
    position: fixed;
    bottom: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(247, 195, 0, 0.03) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

/* 2. حاوية الكارد (خاصية الـ Flip) */
.product-card-container {
  position: relative;
  perspective: 1000px;
  height: 480px; /* زيادة الارتفاع قليلاً ليناسب التصميم الجديد */
  margin-bottom: 1.5rem;
  user-select: none;
  animation: fadeUp 0.6s ease-out forwards;
  opacity: 0;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.product-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  cursor: pointer;
}

.product-card-inner.is-flipped {
  transform: rotateY(180deg);
}

/* تأكدي أن الأوجه لها نفس الارتفاع تماماً */
.card-front,
.card-back {
  backface-visibility: hidden;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.card-back {
  transform: rotateY(180deg);
}

/* الوجه الأمامي */
.card-front {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
  border-radius: 24px; /* زوايا ناعمة وعصرية */
}
/* تنسيق سطر العنوان والزر */
.card-front h3 {
  display: -webkit-box;

  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.2;
}
/* تنسيق الصور لضمان ظهورها كاملة */
.image-container {
  width: 100%;
  height: 500px;
  overflow: hidden;
  position: relative;
  background-color: #f8fafc;
  z-index: 1;
}
.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.6s cubic-bezier(0.33, 1, 0.68, 1);
}
.product-card-inner:hover .card-front img {
  transform: scale(1.15); /* تكبير بنسبة 15% */
}
.image-container::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, transparent 80%, rgba(0, 0, 0, 0.02));
  pointer-events: none;
}
/* تحسين شكل العداد الصغير عندما يظهر مكان الزر */
.card-front .flex.items-center.gap-1 {
  min-width: 65px; /* ضمان عرض كافٍ للعداد */
}

/* الوجه الخلفي */
.card-back {
  background: #111827; /* لون ليلي فخم */
  color: white;
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
}
/* منع النقرات من الوصول للوجه الأمامي عندما يكون مخفياً */
.product-card-inner.is-flipped .card-front {
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0s 0.3s; /* تأخير الاختفاء حتى تنتهي نصف الحركة */
}

/* التأكد من أن الوجه الخلفي هو الذي يستقبل النقرات عند القلّب */
.product-card-inner.is-flipped .card-back {
  pointer-events: auto;
  visibility: visible;
  z-index: 50;
}
/* 3. حالة نفاد الكمية */
.out-of-stock-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-15deg);
  background-color: rgba(220, 38, 38, 0.95);
  color: white;
  padding: 8px 20px;
  border-radius: 10px;
  font-weight: 900;
  font-size: 1rem;
  z-index: 50; /* تأكدي أنها أعلى قيمة في الكارت */
  border: 3px solid white;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  white-space: nowrap;
}

/* الكلاس الذي سيتم إضافته للصورة عبر الجافاسكربت */
.out-of-stock-mode {
  filter: grayscale(1) brightness(0.7) !important; /* تحويل لرمادي وتعتيم */
  opacity: 0.7;
  transition: all 0.4s ease;
}

/* لمنع أي تأثيرات حركية على كرت المنتج النافذ (اختياري) */
.product-card-inner.is-out-of-stock:hover .card-front img {
  transform: scale(1); /* نمنع التكبير إذا نفدت الكمية */
}
/* 4. السلة الجانبية (Drawer) */
#cartDrawer {
  transition: all 0.3s ease-in-out;
}

#cartItems::-webkit-scrollbar {
  width: 4px;
}

/* 5. المودال (نافذة التأكيد) */
#confirmModal {
  transition: visibility 0.3s;
}

/* تحسين شكل السكرول بار */
#cartItems::-webkit-scrollbar {
  width: 6px;
}
#cartItems::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 20px;
}
#cartItems::-webkit-scrollbar-track {
    background: #f1f5f9; 
    border-radius: 20px;
}

@keyframes pulseIcon {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.bg-red-50 span {
  animation: pulseIcon 2s infinite;
}

/* 6. تأثيرات الأزرار والحركة */
button {
  transition: all 0.2s ease;
}

button:active {
  transform: scale(0.95);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#cartItems > div {
  animation: slideUp 0.3s ease forwards;
}

/* 7. الهيدر (تأثير الزجاج المحسن) */
header {
  background: rgba(255, 255, 255, 0.65) !important; /* شفافية عالية */
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
}
header .flex-col {
  /* التأكد من أن النصوص تبدأ من جهة اليمين تماماً */
  align-items: flex-end;
}

/* تحسين شكل الخط للجملة الوصفية */
header p {
  letter-spacing: -0.2px;
  word-spacing: 1px;
}

/* في الشاشات الصغيرة جداً، نصغر الجملة أكثر */
@media (max-width: 400px) {
  header p {
    font-size: 8px;
  }
}
#categoryBar {
  display: flex;
  overflow-x: auto;
  white-space: nowrap;
  gap: 12px;
  padding: 20px 15px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
  user-select: none;
}

#categoryBar::-webkit-scrollbar {
  display: none;
}

.category-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 20px; /* شكل عصري أكثر */
  font-weight: 700;
  font-size: 14px;
  border: 1px solid transparent;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background-color: #FFFCE9; /* لون أبيض نظيف */
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* التنسيق عند اختيار القسم (اللون الأخضر مثل الصورة) */
.category-btn.active {
  background-color: #f7c300 !important; /* لون أخضر داكن مثل الصورة */
  color: white !important;
  box-shadow: 0 8px 20px rgba(61, 126, 82, 0.3);
  transform: translateY(-2px); /* رفعة بسيطة للزر المختار */
}

/* تحسين الحاوية العلوية لتندمج مع الهيدر */
.sticky-container {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: transparent; /* إزالة الخلفية لتوحيدها مع الهيدر */
  border-bottom: none;
  transition: background-color 0.3s ease;
}

/* تأكدي من إزالة أي خلفيات صلبة من الهيدر وشريط التصنيفات بالداخل */
header,
.category-wrapper {
  background-color: transparent !important;
}
.category-wrapper {
  border-top: 0px solid #f3f4f6;
  width: 100%;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(10px);
}

@keyframes gentle-grow {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
}

.animate-gentle-grow {
  animation: gentle-grow 2s ease-in-out infinite;
  display: flex; /* لضمان بقاء العناصر على سطر واحد */
}


/* Chrome, Safari, Edge, Opera */
#userSellPrice::-webkit-outer-spin-button,
#userSellPrice::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
#userSellPrice[type="number"] {
  -moz-appearance: textfield;
}
/* حل مشكلة حركة الدائرة */
#noShameToggle:checked + label div {
  transform: translateX(1.5rem); /* تحريك الدائرة لليسار بمقدار 24 بكسل */
}

/* في حال كنت تستخدم RTL (الاتجاه من اليمين لليسار) */
[dir="rtl"] #noShameToggle:checked + label div {
  transform: translateX(
    1.3rem
  ); /* التحريك للجهة المقابلة إذا كان التصميم معكوساً */
}
.profit-after-offer-row {
    display: flex !important;
}

/* 2. السطر يختفي "فقط" عندما يكون وضع عدم الإحراج مفعلاً */
body.no-shame-active .profit-after-offer-row {
    display: none !important;
}
/* إخفاء الأسعار عند التفعيل */
body.no-shame-active .sale,
body.no-shame-active .animate-gentle-grow {
  display: none !important;
}

/* تحسين شكل النتائج لتكون ملفتة للمندوب */
#profitResult .result-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-radius: 1rem;
    margin-bottom: 0.75rem;
}

#profitBeforeOffer, #profitAfterOffer {
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: 0.5px;
}

/* تحريك بسيط عند ظهور النتائج */
.animate-slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
/* ستايل الليبل العام */
/* الليبل الأساسي */
.product-badge {
    position: absolute;
    right: 0;
    padding: 5px 14px;
    font-size: 11px;
    font-weight: 800;
    color: white;
    z-index: 30;
    border-radius: 10px 0 0 30px;
    box-shadow: -2px 2px 5px rgba(0,0,0,0.15);
    white-space: nowrap;
}
.badge-green { background-color: #27ae60; color: white; }
.badge-yellow { background-color: #f1c40f; color: #000; } /* الأصفر عادة يفضل نص أسود لوضوحه */
.badge-red { background-color: #e74c3c; color: white; }
.badge-orange { background-color: #e67e22; color: white; }

/* لجعل الكارت "نسبياً" ليظهر الليبل فوقه */
.image-container {
    position: relative;
}
/* التعديلات تعمل فقط على الشاشات الصغيرة (الجوال) */
@media (max-width: 768px) {
    /* الحاوية التي تجمع البحث والسلة والتبديل */
    header, .header-container { 
        display: flex !important;
        flex-direction: row-reverse !important; /* لترتيب العناصر بشكل صحيح */
        align-items: center !important;
        justify-content: space-between !important;
        padding: 10px 8px !important;
        gap: 8px !important;
    }

    /* تصغير شريط البحث لإعطاء مساحة */
    #searchInputContainer, .search-box {
        flex: 0 0 50% !important; /* يأخذ نصف الشاشة فقط */
        max-width: 50% !important;
    }

    /* حاوية الأيقونات (السلة + التوغل) */
    .cart-toggle-container, .nav-icons {
        flex: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 15px !important; /* مسافة مريحة للنقر بين السلة والزر */
    }

    /* تكبير زر السلة لتسهيل الاستخدام */
    #cartBtn {
        padding: 10px !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }
    
    /* تكبير زر الوضع الليلي/الإخفاء قليلًا */
    #noShameToggle + div {
        transform: scale(1.2); /* تكبير الزر بنسبة 20% للنقر الأسهل */
        margin-left: 5px;
    }
}
#paginationButtons {
    display: none !important;
}
#backToTop {
    /* تجنب الظلال الثقيلة ليبقى شفافاً وهادئاً */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* في وضع الزبون، قد تود إبقاء الزر شفافاً أيضاً أو تغيير لونه قليلاً */
.no-shame-active #backToTop {
    border-color: rgba(0, 0, 0, 0.1);
}