/* 
 * تحسينات نسخة الجوال - واجهة تطبيق 
 * BSTM Store Mobile App-Like Experience
 */

/* متغيرات إضافية */
:root {
  --header-height-mobile: 60px;
  --bottom-nav-height: 60px;
  --app-transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --safe-area-inset-top: env(safe-area-inset-top, 0px);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
  --app-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* التعديلات الأساسية للجوال */
@media (max-width: 768px) {
  body {
    padding-top: var(--header-height-mobile);
    padding-bottom: var(--bottom-nav-height);
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    overscroll-behavior-y: none; /* منع تأثير الارتداد */
    touch-action: pan-y;
  }
  
  /* شريط الحالة (للتطبيقات المثبتة على الشاشة الرئيسية) */
  @supports (padding-top: env(safe-area-inset-top)) {
    body {
      padding-top: calc(var(--header-height-mobile) + var(--safe-area-inset-top));
      padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-inset-bottom));
    }
  }
  
  /* الهيدر */
  .site-header {
    position: fixed;
    height: var(--header-height-mobile);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    background: rgba(10, 10, 10, 0.85);
    box-shadow: var(--app-shadow);
    z-index: 1000;
  }
  
  .site-header .container {
    height: var(--header-height-mobile);
    padding: 0 15px;
  }
  
  .logo {
    height: 40px;
  }
  
  /* إخفاء قائمة التنقل العادية */
  .site-header .nav {
    display: none;
  }
  
  /* إعادة تعيين margin-top للسلايدر */
  .hero-slider {
    margin-top: 0;
    height: 50vh;
    min-height: 300px;
  }
  
  /* شريط البحث والتصنيفات */
  .search-filter-container {
    top: var(--header-height-mobile);
    padding: 10px 0;
    background: rgba(5, 5, 5, 0.9);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    z-index: 90;
  }
  
  .search-filter-flex {
    gap: 15px;
  }
  
  .search-bar {
    border-radius: 30px;
  }
  
  /* تحسينات قائمة التصنيفات */
  .categories-list {
    gap: 8px;
    padding: 5px;
    margin-bottom: 0;
    -webkit-overflow-scrolling: touch; /* تمرير سلس على iOS */
    scroll-snap-type: x mandatory;
  }
  
  .category-item {
    scroll-snap-align: start;
    min-width: 80px;
    padding: 8px 12px;
    border-radius: 20px;
  }
  
  /* تحسينات شبكة المنتجات */
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 5px;
  }
  
  .product-card {
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  }
  
  .product-card .content {
    padding: 12px;
  }
  
  .product-card h3 {
    font-size: 15px;
    margin-bottom: 5px;
  }
  
  .product-card p {
    font-size: 13px;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .product-card .price {
    font-size: 16px;
  }
  
  .shop-btn {
    padding: 10px 15px;
    font-size: 14px;
    border-radius: 40px;
  }
  
  /* زر "العودة للأعلى" */
  .back-to-top {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 20px);
    right: 20px;
    width: 40px;
    height: 40px;
    background: var(--red);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    z-index: 80;
    opacity: 0;
    visibility: hidden;
    transition: var(--app-transition);
    transform: scale(0.8);
  }
  
  .back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
  }
  
  .back-to-top:active {
    transform: scale(0.9);
  }
  
  /* قائمة التنقل السفلية */
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--bottom-nav-height);
    background: rgba(10, 10, 10, 0.9);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-bottom: var(--safe-area-inset-bottom);
  }
  
  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    transition: var(--app-transition);
  }
  
  .mobile-nav-item.active {
    color: var(--red);
  }
  
  .mobile-nav-item:active {
    transform: scale(0.9);
  }
  
  .mobile-nav-icon {
    font-size: 22px;
    margin-bottom: 4px;
  }
  
  .mobile-nav-text {
    font-size: 10px;
  }
  
  /* قائمة المزيد / القائمة الجانبية */
  .mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 80%;
    max-width: 320px;
    background: rgba(15, 15, 15, 0.95);
    z-index: 2000;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    box-shadow: -5px 0 25px rgba(0,0,0,0.5);
    overflow-y: auto;
    padding-top: calc(var(--header-height-mobile) + var(--safe-area-inset-top));
    padding-bottom: var(--safe-area-inset-bottom);
  }
  
  .mobile-drawer.open {
    transform: translateX(0);
  }
  
  .drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1900;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }
  
  .drawer-overlay.active {
    opacity: 1;
    visibility: visible;
  }
  
  .drawer-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
  }
  
  .drawer-content {
    padding: 20px;
  }
  
  .drawer-menu {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  
  .drawer-menu-item {
    padding: 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: block;
  }
  
  .drawer-menu-link {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    width: 100%;
    transition: all 0.3s ease;
    border-radius: 10px;
    margin: 5px 0;
  }
  
  .drawer-menu-link:active {
    background: rgba(255,255,255,0.05);
    transform: scale(0.98);
    color: var(--red);
  }
  
  /* تحسين تفاعلات الروابط */
  .drawer-menu-item:first-child .drawer-menu-link {
    margin-top: 10px;
  }
  
  .drawer-close {
    width: 40px;
    height: 40px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 12px;
    right: 12px;
    opacity: 0.7;
    border-radius: 50%;
  }
  
  .drawer-close:active {
    background: rgba(255,255,255,0.1);
    opacity: 1;
  }
  
  .drawer-menu-icon {
    margin-left: 15px;
    font-size: 20px;
    opacity: 0.8;
  }
  
  /* تحسينات بطاقات المنتجات للأجهزة اللمسية */
  .product-card:active {
    transform: scale(0.98);
  }
  
  .product-card.touch-active {
    transform: scale(0.98);
    border-color: rgba(209, 0, 0, 0.3);
  }
  
  /* تحسينات عناصر الكمية للجوال */
  @media (max-width: 768px) {
    .product-card .quantity-controls {
      margin-top: 10px;
    }
    
    .product-card .quantity-btn {
      width: 32px;
      height: 32px;
      font-size: 20px;
    }
    
    .product-card .quantity-input {
      width: 45px;
      font-size: 18px;
    }
    
    /* تجربة اللمس */
    .product-card .quantity-btn:active {
      background: rgba(209, 0, 0, 0.5);
      transform: scale(0.9);
    }
  }
  
  /* إخفاء التذييل في وضع الجوال */
  .site-footer {
    padding-bottom: calc(var(--bottom-nav-height) + 20px);
  }
  
  /* تخصيص pull-to-refresh */
  body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 10px;
    background: linear-gradient(180deg, var(--red), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
  }
  
  body.refreshing::before {
    opacity: 1;
  }
  
  /* تنسيقات الإضافة إلى السلة */
  .add-to-cart {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: var(--red);
    color: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    z-index: 9999;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  
  .add-to-cart.animate {
    animation: cartPop 1s forwards;
  }
  
  @keyframes cartPop {
    0% {
      transform: translate(-50%, -50%) scale(0);
      opacity: 0;
    }
    20% {
      transform: translate(-50%, -50%) scale(1.2);
      opacity: 1;
    }
    40% {
      transform: translate(-50%, -50%) scale(1);
      opacity: 1;
    }
    80% {
      transform: translate(-50%, -250%) scale(0.8);
      opacity: 0.8;
    }
    100% {
      transform: translate(-50%, -250%) scale(0);
      opacity: 0;
    }
  }
}

/* إضافة تأثير اللمس - يظهر فقط على الأجهزة التي تدعم اللمس */
@media (hover: none) {
  .category-item:active, .shop-btn:active, .btn-primary:active, .btn-secondary:active {
    transform: scale(0.95);
    opacity: 0.9;
  }
  
  /* تأثير عند الضغط */
  .product-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.1);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    border-radius: 12px;
  }
  
  .product-card:active::after {
    opacity: 1;
  }
}
