/* ==========================================================================
   متجر «وصلة — WASLA» للهواتف المحمولة والإكسسوارات
   assets/css/responsive.css — التجاوب مع شاشات الجوال، التابلت، والديسكتوب
   مختبر ومعدل لشاشات: 360px, 390px, 768px, 1024px, 1440px
   ========================================================================== */

/* شاشات اللابتوب والديسكتوب الواسعة (1280px وما فوق) */
@media (min-width: 1280px) {
  .products-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* شاشات اللابتوب المتوسطة (أقل من 1100px) */
@media (max-width: 1100px) {
  .hero-grid {
    gap: 36px;
  }
  .catalog-layout {
    grid-template-columns: 240px 1fr;
    gap: 24px;
  }
  .footer-grid {
    grid-template-columns: 1.5fr repeat(3, 1fr);
    gap: 32px;
  }
}

/* شاشات التابلت (أقل من 992px) */
@media (max-width: 992px) {
  :root {
    --header-height: 68px;
  }

  /* إخفاء روابط الهيدر الأفقية وإظهار زر القائمة المنسدلة */
  .desktop-nav {
    display: none;
  }
  .mobile-menu-toggle {
    display: inline-flex;
  }

  /* هيرو الصفحة الرئيسية */
  .hero-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .hero-content {
    align-items: center;
  }
  .hero-tag {
    margin-inline: auto;
  }
  .hero-description {
    margin-inline: auto;
  }
  .hero-cta-group {
    justify-content: center;
  }
  .budget-quick-access {
    align-items: center;
  }
  .budget-pills {
    justify-content: center;
  }
  .hero-floating-card {
    inset-inline-start: 12px;
    bottom: 12px;
  }

  /* الكتالوج: تحويل الفلاتر الجانبية إلى درج Drawer للجوال */
  .catalog-layout {
    grid-template-columns: 1fr;
  }
  .filters-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: min(320px, 85vw);
    z-index: 1500;
    border-radius: 0;
    border: none;
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform var(--transition-slow);
    display: flex;
  }
  [dir="rtl"] .filters-sidebar {
    transform: translateX(100%);
  }
  .filters-sidebar.is-open {
    transform: translateX(0);
  }
  .filters-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(32, 39, 38, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1400;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
  }
  .filters-sidebar-backdrop.is-open {
    opacity: 1;
    visibility: visible;
  }
  .mobile-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  /* تفاصيل المنتج */
  .product-detail-layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .product-gallery {
    position: static;
    max-width: 520px;
    margin-inline: auto;
    width: 100%;
  }

  /* السلة وإتمام الطلب */
  .cart-layout, .checkout-grid {
    grid-template-columns: 1fr;
  }
  .cart-summary-card {
    position: static;
  }

  /* الفوتر */
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 36px;
  }
  .footer-brand {
    grid-column: span 2;
  }

  /* بانر المقارنة الترويجي */
  .compare-banner {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }
}

/* شاشات الهواتف الكبيرة والمتوسطة (أقل من 768px) */
@media (max-width: 768px) {
  /* تعديل أحجام العناوين والمسافات */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* شبكة المنتجات على الهواتف: عمودان واضحان */
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .product-card-body {
    padding: 12px;
    gap: 8px;
  }
  .product-card-title {
    font-size: 0.94rem;
    min-height: 2.5em;
  }
  .product-price {
    font-size: 1.02rem;
  }
  .spec-chip {
    font-size: 0.72rem;
    padding: 3px 6px;
  }

  /* شريط الشراء العائم السفلي في صفحة تفاصيل المنتج */
  .mobile-sticky-buy-bar {
    display: block;
  }
  .product-detail-layout {
    padding-bottom: 72px; /* منع حجب المحتوى بالشريط السفلي */
  }

  /* جدول المقارنة على الموبايل */
  .compare-table-container {
    margin-inline: -16px;
    border-radius: 0;
    border-inline: none;
  }
  .compare-attr-name {
    width: 140px;
    min-width: 130px;
    font-size: 0.82rem;
    padding: 12px 10px;
  }
  .compare-table th, .compare-table td {
    padding: 12px 10px;
    font-size: 0.84rem;
  }

  /* الفوتر */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .footer-brand {
    grid-column: span 1;
  }
  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 14px;
  }
  .footer-bottom-links {
    justify-content: center;
    flex-wrap: wrap;
  }

  /* أداة اختيار الهاتف */
  .finder-recommendation-card {
    grid-template-columns: 1fr;
    gap: 20px;
    text-align: center;
  }
  .finder-recommendation-card .product-card-media {
    max-width: 220px;
    margin-inline: auto;
  }
}

/* شاشات الهواتف الضيقة (360px - 390px) */
@media (max-width: 480px) {
  .container {
    padding-inline: 14px;
  }

  /* الهيدر على الشاشات الضيقة */
  .header-main {
    gap: 8px;
  }
  .header-search {
    display: none; /* يتم البحث عبر زر مخصص أو في القائمة لتجنب الازدحام */
  }
  .header-actions {
    gap: 6px;
  }
  .action-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  /* شبكة المنتجات */
  .products-grid {
    grid-template-columns: 1fr; /* عمود واحد كامل لتجربة فاخرة غير متزاحمة على الشاشات الصغيرة جداً */
  }

  .hero-cta-group {
    flex-direction: column;
    width: 100%;
  }
  .hero-cta-group .btn {
    width: 100%;
  }

  /* تبسيط سلة المشتريات */
  .cart-items-table th:nth-child(2),
  .cart-items-table td:nth-child(2) {
    display: none; /* إخفاء عمود سعر الوحدة المنفرد والاعتماد على الإجمالي */
  }

  .specs-table th {
    width: 38%;
    padding: 10px 12px;
    font-size: 0.84rem;
  }
  .specs-table td {
    padding: 10px 12px;
    font-size: 0.84rem;
  }
}
