/* ===== إصلاح الخلفية على الهاتف فقط ===== */
@media (max-width: 768px) {

  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  body::before {
    /* نستخدم وحدات شاشة مخصصة للهواتف */
    width: 100svw;
    height: 100svh;

    /* نكبر الطبقة قليلاً لإلغاء أي فراغ */
    transform: scale(1.02);
    transform-origin: center;
  }
}


/* =========================================
   📱 FORCE MOBILE LAYOUT – FULL CONTROL
========================================= */
@media (max-width: 768px) {

  /* ===============================
     🎛️ متغيرات التحكم العامة
  =============================== */
  :root {
    --gap-between-items: -40px;
    /* الفراغ بين كل عنصر */
    --topbar-padding: -10px;
    /* سماكة الشريط */
  }

  * {
    box-sizing: border-box;
  }

  /* ===============================
     🔹 الشريط العلوي (نحيف)
  =============================== */
  .top-bar {
    position: relative !important;

    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;

    padding: 6px 8px !important;
    gap: 4px !important;

    font-size: 10px !important;
  }

  /* ==================================================
     🔥 زر السوق – تحكم كامل
  ================================================== */
  .market-button {
    position: relative !important;

    /* 🔧 تحريك */
    transform: translate(45px,
        /* ⬅️➡️ يمين / يسار */
        -5px
        /* ⬆️⬇️ فوق / تحت */
      ) !important;

    font-size: 9.5px !important;
    padding: 10px 19px !important;
    border-radius: 8px !important;

    animation: none !important;


  }

  /* ==================================================
     🛒 السلة + زر القائمة
  ================================================== */
  .cart-menu-wrapper {
    position: relative !important;

    display: flex !important;
    justify-content: center !important;
    align-items: center !important;

    gap: 6px !important;

    /* 🔧 تحريك المجموعة */
    transform: translate(0px,
        /* يمين / يسار */
        -2px
        /* فوق / تحت */
      ) !important;
  }

  /* ----- زر السلة ----- */
  .cart-button {
    position: relative !important;

    transform: translate(10px,
        /* يمين / يسار */
        -5px
        /* فوق / تحت */
      ) !important;

    font-size: 9.5px !important;
    padding: 6.9px 16px !important;
    border-radius: 8px !important;
  }

  .cart-count {
    font-size: 9px !important;
    padding: 1px 4px !important;

    top: -5px !important;
    left: -5px !important;
  }

  /* ===============================
   📱 دائرة عدّاد السلة (الهاتف فقط)
=============================== */
  @media (max-width: 768px) {

    .cart-button {
      position: relative;
    }

    .cart-count {
      position: absolute;
      top: -6px;
      left: -6px;

      min-width: 16px;
      height: 16px;
      padding: 0 4px;

      background: #ff0000;
      color: #fff;

      border-radius: 50%;
      font-size: 9px;
      font-weight: bold;
      line-height: 16px;
      text-align: center;
    }

  }


  /* ----- زر القائمة (☰) ----- */
  .menu-btn {
    position: relative !important;

    transform: translate(-39px,
        /* يمين / يسار */
        -5px
        /* فوق / تحت */
      ) !important;

    font-size: 14px !important;
    padding: 4.7px 21px !important;
    border-radius: 8px !important;
  }

  /* ==================================================
     📂 القائمة المنسدلة
  ================================================== */
  .dropdown-menu {
    position: absolute !important;

    width: 50.5% !important;
    left: 1% !important;

    /* 🔧 تحريك القائمة */
    transform: translate(-1.1px,
        /* يمين / يسار */
        -2px
        /* فوق / تحت */
      ) !important;

    padding: 10px !important;
    font-size: 12px !important;
  }

  .dropdown-menu h2 {
    font-size: 13px !important;
  }

  /* ==================================================
     ✨ عبارة الترحيب
  ================================================== */
  /* ❌ إخفاء عبارة الترحيب */
  #welcome-banner {
    display: none !important;
  }

  /* ==================================================
     🔍 محرك البحث
  ================================================== */
  .search-container {
    position: relative !important;

    display: flex !important;
    justify-content: center !important;
    align-items: center !important;

    gap: 4px !important;
    width: 100% !important;

    transform: translate(92.5px,
        /* يمين / يسار */
        -5px
        /* فوق / تحت */
      ) !important;
  }

  #searchInput {
    width: 43% !important;
    height: 29px !important;
    font-size: 12px !important;
  }

  #searchBtn {
    width: 30px !important;
    height: 25px !important;
  }


  /* ===============================
     🔐 شريط الدخول (خارج الشريط)
  =============================== */
  .auth-bar {
    position: relative !important;

    text-align: center !important;
    font-size: 11px !important;

    margin: 4px auto 6px !important;
    padding: 4px 6px !important;

    background: rgba(0, 0, 0, 0.35);
    border-radius: 8px;
  }

  .auth-bar a {
    color: #fff !important;
    text-decoration: none !important;
    font-weight: bold !important;
    margin: 0 4px !important;
  }
}


/* =========================================
📱 PRODUCTS – MOBILE GRID (2 × 2)
========================================= */
@media (max-width: 768px) {

  /* ===============================
     🎛️ متغيرات تحكم عامة
  =============================== */
  :root {
    --left-column-shift: -200px;
    /* تحريك العمود الأيسر */
    --right-column-shift: 0px;
    /* تحريك العمود الأيمن */
  }

  .products {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 24px !important;

    padding: 14px 28px 10px 7px !important;
    /* ↑↑ عالجنا الميلان يمين/يسار */

    margin-top: 10px !important;
    /* ↑↑ عالجنا الالتصاق مع البحث */

    transform: translate(5px,
        /* يمين / يسار */
        -5px
        /* فوق / تحت */
      ) !important;

  }

  .product {
    width: 100% !important;
    height: auto !important;
    padding: 6px !important;
    border-radius: 14px;
  }

  .product img {
    width: 100% !important;
    height: 160px !important;
    object-fit: contain;
    margin-bottom: 6px;
  }

  .product h3 {
    font-size: 14px;
    margin: 6px 0;
    line-height: 1.2;
  }

  .product p.price {
    font-size: 14px;
    margin: 4px 0;
  }

  .add-to-cart-form button {
    font-size: 13px;
    padding: 8px 10px;
    width: 100%;
  }

  #welcome-banner {
    display: none !important;
  }
}



/* ===============================
   📱 تصفية السعر - مظهر الهاتف
=============================== */
@media (max-width: 768px) {

  .price-filter {
    padding: 14px 12px 16px;
    margin-bottom: 14px;
  }

  .price-filter h4 {
    font-size: 15px;
    margin-bottom: 12px;
    text-align: center;
  }

  /* أزرار التحكم */
  .price-controls {
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
  }

  /* زر + و - */
  .price-controls button {
    width: 22px;
    height: 22px;
    font-size: 14px;
    border-radius: 8px;

  }

  /* خانة السعر */
  #priceValue {
    width: 40px;
    height: 22px;
    font-size: 13px;
    border-radius: 8px;
  }

  /* زر التحديث */
  #priceApply {
    height: 24px;
    font-size: 15px;
    border-radius: 10px;
  }
}



/* =========================================
   📱 TOP BAR - الهاتف فقط
========================================= */
@media (max-width: 768px) {

  .top-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 6px 8px;
    gap: 6px;

    background: linear-gradient(135deg,
        #272525,
        #6c00af,
        #c40000,
        #0705b5);
  }

  /* ===============================
     السطر العلوي (تسجيل الدخول)
  =============================== */
  /* إخفاء أزرار الدخول داخل الشريط */
  .top-bar>div:first-child {
    display: none !important;
  }

  /* إظهار شريط الدخول أسفل الشريط */
  .auth-bar {
    display: block !important;
    text-align: center;
    font-size: 12px;
    margin: 6px auto 8px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 10px;
  }

  .auth-bar a {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    margin: 0 6px;
  }
}

/* =========================================
📱 TOP BAR – FIX BUTTONS ALIGNMENT
========================================= */
@media (max-width: 768px) {

  /* الشريط العلوي */
  .top-bar {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px;
    padding: 8px;
  }

  /* إخفاء سطر الدخول داخل الشريط */
  .top-bar>div:first-child {
    display: none !important;
  }

  /* إخفاء عبارة الترحيب */
  #welcome-banner {
    display: none !important;
  }

  /* ===== مجموعة الأزرار ===== */
  .cart-menu-wrapper {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 60px !important;
    width: 100%;
  }

  /* ===== توحيد شكل كل الأزرار ===== */
  .market-button,
  .cart-button,
  .menu-btn {
    flex: 1;
    height: 31px;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 13px !important;
    padding: 0 !important;
    border-radius: 10px !important;

    transform: none !important;
    /* ❌ إلغاء التحريك */
  }

  /* زر القائمة ☰ */
  .menu-btn {
    max-width: 80px;
    font-size: -18px !important;
  }

  /* عداد السلة */
  .cart-count {
    top: -6px !important;
    right: -6px !important;
    left: auto !important;
  }

}



/* كروت ثابتة بدون backdrop-filter على الهاتف */
@media (max-width: 768px) {
  .product {
    background: #ffffffb3;
    /* بدل rgba */
    backdrop-filter: none;
  }

  .product img {
    background: #ffffff92;
    /* إزالة الشفافية */
  }
}