/* =============================================
   تحسينات الجوال - أضف هذا في نهاية style.css
   ============================================= */

/* ── BOTTOM NAV BAR (شريط التنقل السفلي) ── */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(14,15,19,0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 500;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-inner {
  display: flex; align-items: center;
  height: 60px;
}

.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  padding: 8px 4px; border-radius: 12px;
  color: var(--text3); font-size: 0.65rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  position: relative; border: none; background: none;
  font-family: 'Tajawal', sans-serif;
  text-decoration: none;
}
.bottom-nav-item .nav-icon { font-size: 1.3rem; line-height: 1; }
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item:active { transform: scale(0.92); }

.bottom-nav-cart-badge {
  position: absolute; top: 4px; right: calc(50% - 18px);
  background: var(--danger); color: #fff;
  width: 16px; height: 16px; border-radius: 50%;
  font-size: 0.6rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--bg);
}

/* ── MOBILE SEARCH OVERLAY ── */
.mobile-search-overlay {
  position: fixed; inset: 0; background: var(--bg);
  z-index: 600; padding: 16px;
  transform: translateY(-100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column; gap: 12px;
}
.mobile-search-overlay.open { transform: translateY(0); }
.mobile-search-header {
  display: flex; align-items: center; gap: 12px;
}
.mobile-search-input {
  flex: 1; padding: 12px 16px;
  background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: 999px; color: var(--text);
  font-family: 'Tajawal', sans-serif; font-size: 1rem;
}
.mobile-search-input:focus { outline: none; border-color: var(--accent); }
.mobile-search-results {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.mobile-search-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
}
.mobile-search-item img {
  width: 52px; height: 52px; object-fit: cover; border-radius: 8px;
}

/* ── PULL TO REFRESH INDICATOR ── */
.ptr-indicator {
  position: fixed; top: 0; left: 0; right: 0;
  height: 4px; background: var(--border); z-index: 9999;
  transform: scaleX(0); transform-origin: right;
  transition: transform 0.3s ease;
}
.ptr-indicator.loading {
  transform: scaleX(1);
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  animation: loadingBar 1.5s ease infinite;
}
@keyframes loadingBar {
  0% { transform: scaleX(0) translateX(0); transform-origin: right; }
  50% { transform: scaleX(1); }
  100% { transform: scaleX(0); transform-origin: left; }
}

/* ── MOBILE PRODUCT CARD ── */
@media (max-width: 768px) {
  /* Body padding for bottom nav */
  body { padding-bottom: 70px; }

  /* Show bottom nav */
  .bottom-nav { display: block; }

  /* Hide desktop navbar elements on mobile */
  .navbar { height: 56px; padding: 0 16px; }
  .navbar-inner { gap: 12px; }
  .nav-logo { font-size: 1.2rem; }
  .nav-actions .nav-btn:not(.nav-cart-btn) { display: none; }
  .nav-cart-btn { display: none; } /* moved to bottom nav */

  /* Hero */
  .hero { padding: 40px 16px 48px; }
  .hero h1 { font-size: 1.7rem; }
  .hero p { font-size: 0.95rem; }
  .hero-btns { gap: 8px; }
  .hero-btns .btn { padding: 10px 20px; font-size: 0.9rem; }

  /* Section */
  .section { padding: 32px 0; }
  .container { padding: 0 14px; }
  .section-header { margin-bottom: 20px; }
  .section-title { font-size: 1.2rem; }

  /* Categories */
  .categories-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
  .category-card { padding: 14px 8px; border-radius: 12px; }
  .category-icon { font-size: 1.5rem; margin-bottom: 6px; }
  .category-name { font-size: 0.75rem; }

  /* Products grid - 2 columns */
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* Product card mobile */
  .product-card { border-radius: 12px; }
  .product-info { padding: 10px; }
  .product-name { font-size: 0.82rem; }
  .product-price { font-size: 0.95rem; }
  .add-to-cart-btn { padding: 8px; font-size: 0.8rem; border-radius: 8px; }

  /* Cart sidebar full screen on mobile */
  .cart-sidebar {
    width: 100%;
    border-radius: 20px 20px 0 0;
    top: auto;
    height: 85vh;
    bottom: 0;
    left: 0;
    transform: translateY(100%);
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .cart-sidebar.open { transform: translateY(0); }

  /* Products page - hide sidebar on mobile */
  .products-page-grid {
    grid-template-columns: 1fr !important;
  }
  .products-sidebar { display: none; }

  /* Checkout */
  .checkout-grid { grid-template-columns: 1fr !important; }

  /* Product detail */
  .product-detail-grid { grid-template-columns: 1fr !important; gap: 20px !important; }

  /* Footer */
  footer { padding: 32px 16px 16px; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 20px; }

  /* Filters bar scroll */
  .filters-bar {
    overflow-x: auto; flex-wrap: nowrap;
    padding: 12px 14px; gap: 8px;
    scrollbar-width: none;
  }
  .filters-bar::-webkit-scrollbar { display: none; }
  .filter-chip { white-space: nowrap; flex-shrink: 0; }
}

/* ── SMALL PHONES ── */
@media (max-width: 380px) {
  .categories-grid { grid-template-columns: repeat(3, 1fr); }
  .hero h1 { font-size: 1.5rem; }
  .products-grid { gap: 8px; }
  .product-name { font-size: 0.78rem; }
}

/* ── TABLET ── */
@media (min-width: 769px) and (max-width: 1024px) {
  .products-grid { grid-template-columns: repeat(3, 1fr); }
  .categories-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ── TOUCH IMPROVEMENTS ── */
@media (hover: none) {
  /* Remove hover effects on touch - use active instead */
  .product-card:hover { transform: none; box-shadow: none; }
  .product-card:active { transform: scale(0.98); }
  .btn:hover { transform: none; }
  .btn:active { transform: scale(0.96); opacity: 0.9; }
  .add-to-cart-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--border); }
  .add-to-cart-btn:active { background: var(--accent); color: #000; transform: scale(0.97); }
}

/* ── SWIPE GESTURE HINT ── */
.swipe-hint {
  display: none;
  text-align: center;
  color: var(--text3);
  font-size: 0.75rem;
  padding: 6px;
  animation: fadeInOut 3s ease forwards;
}
@keyframes fadeInOut {
  0%,100% { opacity: 0; } 20%,80% { opacity: 1; }
}
@media (max-width: 768px) { .swipe-hint { display: block; } }

/* ── MOBILE SPECIFIC ANIMATIONS ── */
@media (max-width: 768px) {
  .product-card {
    animation: cardFadeIn 0.4s ease backwards;
  }
  @keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
  }
  /* Stagger animation for grid items */
  .products-grid .product-card:nth-child(1) { animation-delay: 0.05s; }
  .products-grid .product-card:nth-child(2) { animation-delay: 0.1s; }
  .products-grid .product-card:nth-child(3) { animation-delay: 0.15s; }
  .products-grid .product-card:nth-child(4) { animation-delay: 0.2s; }
  .products-grid .product-card:nth-child(5) { animation-delay: 0.25s; }
  .products-grid .product-card:nth-child(6) { animation-delay: 0.3s; }
}

/* ── SAFE AREA (iPhone notch) ── */
@supports (padding: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: calc(env(safe-area-inset-bottom) + 4px);
  }
  .cart-sidebar {
    padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
  }
}
