/* ========================================
   Reset & Variables
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #00b4d8;
    --primary-dark: #0077b6;
    --primary-light: #90e0ef;
    --secondary: #2ec4b6;
    --danger: #ff3366;
    --warning: #ffb703;
    --success: #20bf55;
    
    --gray-50: #f8f9fa;
    --gray-100: #e9ecef;
    --gray-200: #dee2e6;
    --gray-300: #ced4da;
    --gray-400: #adb5bd;
    --gray-500: #6c757d;
    --gray-600: #495057;
    --gray-700: #343a40;
    --gray-800: #212529;
    --gray-900: #111418;
    
    --shadow: 0 4px 12px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.7;
    direction: rtl;
    overflow-x: hidden;
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========================================
   Header
   ======================================== */
.site-header {
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--gray-100);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
}
.logo {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary-dark);
}
.main-nav {
    display: flex;
    gap: 24px;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cart-icon {
    position: relative;
    padding: 8px 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    font-size: 18px;
}
.cart-count {
    position: absolute;
    top: -5px;
    left: -5px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   Search Hero Section
   ======================================== */
.search-hero {
    background: linear-gradient(135deg, #0077b6 0%, #0096c7 100%);
    padding: 60px 0;
    color: white;
    text-align: center;
}
.search-hero h1 { font-size: 36px; font-weight: 800; margin-bottom: 8px; }
.hero-subtitle { font-size: 16px; opacity: 0.9; margin-bottom: 24px; }

.main-search-box {
    max-width: 600px;
    margin: 0 auto 28px;
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    padding: 6px;
    box-shadow: var(--shadow-md);
}
.main-search-box form { display: flex; }
.main-search-box input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    outline: none;
    font-size: 15px;
}
.main-search-box button {
    background: var(--secondary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 700;
}

.quick-features { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; }
.quick-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 14px;
    border-radius: 30px;
}

/* ========================================
   Categories (سبک دایره‌ای شیک)
   ======================================== */
.main-categories { padding: 40px 0; background: white; }
.categories-grid { display: flex; justify-content: center; gap: 24px; flex-wrap: wrap; }
.category-card { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 110px; text-align: center; cursor: pointer;}
.category-icon-wrapper-circle {
    width: 80px;
    height: 80px;
    background: var(--gray-50);
    border: 1px solid var(--gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    transition: var(--transition);
}
.category-card:hover .category-icon-wrapper-circle {
    transform: translateY(-4px);
    background: var(--primary-light);
    border-color: var(--primary);
}
.category-card h3 { font-size: 13px; font-weight: 700; color: var(--gray-700); }

/* ========================================
   Products Slider Structure (اصلاح لایه‌بندی کامپوننت‌ها)
   ======================================== */
.products-section { padding: 40px 0; position: relative; }
.discount-section { background: linear-gradient(to bottom, #fff0f3 0%, white 100%); }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.section-title-wrapper h2 { font-size: 22px; font-weight: 800; }
.view-all-link { color: var(--primary-dark); font-weight: 700; font-size: 14px; }

.products-slider-outer { 
    position: relative; 
    width: 100%;
}
.products-slider-container {
    width: 100%;
    overflow: hidden; /* جلوگیری از بیرون زدن در دسکتاپ */
}
.products-slider { 
    display: flex; 
    gap: 16px; 
    padding: 10px 4px; 
    transition: transform 0.4s ease;
}

/* ========================================
   Product Card
   ======================================== */
.product-card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-100);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    width: 230px;
    flex-shrink: 0;
    position: relative;
    z-index: 1; /* ایجاد کانتکست لایه‌ای مستقل */
}
.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}
.product-link {
    display: block; /* تبدیل به بلاک کامل برای پوشش کل فضای بالایی کارت */
    position: relative;
    z-index: 2; /* بالاتر از بدنه کارت */
    width: 100%;
    height: 100%;
}
.product-image-wrapper {
    position: relative;
    width: 100%;
    height: 180px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.product-image { width: 100%; height: 100%; object-fit: contain; pointer-events: none; } /* جلوگیری از بلاک کردن کلیک توسط عکس */

.discount-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    z-index: 3;
}

.product-details { padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.product-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    height: 40px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-category-name { font-size: 12px; color: var(--gray-500); }
.product-pricing { display: flex; flex-direction: column; align-items: flex-end; margin-top: auto; }
.price-original { font-size: 11px; color: var(--gray-400); text-decoration: line-through; }
.price-current { font-size: 15px; font-weight: 800; color: var(--gray-900); }

.product-footer { 
    padding: 10px 12px; 
    background: var(--gray-50);
    position: relative;
    z-index: 5; /* دکمه خرید باید بالاترین لایه باشد تا کلیک خودش را بگیرد */
}
.btn-add-cart {
    width: 100%;
    background: white;
    border: 1px solid var(--primary);
    color: var(--primary-dark);
    padding: 8px;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* دکمه‌های ناوبری اسلایدر فقط برای دسکتاپ */
.slider-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10; /* تنظیم دقیق ایندکس برای عدم تداخل */
    border: 1px solid var(--gray-100);
}
.prev-btn { right: -20px; }
.next-btn { left: -20px; }

/* ========================================
   Mobile Media Queries (فیکس سخت‌گیرانه برای گوشی)
   ======================================== */
@media (max-width: 992px) {
    .main-nav { display: none; }
}

@media (max-width: 768px) {
    .container { padding: 0 12px; }
    .search-hero { padding: 35px 0; }
    .search-hero h1 { font-size: 22px; }
    
    /* سیستم اسکرول لمسی نیتیو بدون تداخل کدهای دسکتاپ */
    .products-slider-container {
        overflow-x: auto !important; /* فعال‌سازی اسکرول افقی روی گوشی */
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    
    .products-slider {
        display: flex !important;
        transform: none !important; /* غیرفعال کردن افکت دسکتاپ جی‌اس */
        padding: 8px 0;
        gap: 12px;
        width: max-content; /* حیاتی برای عدم مچاله شدن کارت‌ها */
    }
    
    .product-card {
        scroll-snap-align: start;
        width: 160px; /* ابعاد استاندارد گوشی‌های دیجی‌کالا و مثبت‌سبز */
    }
    
    .product-image-wrapper { height: 130px; padding: 8px; }
    .product-title { font-size: 12px; height: 36px; }
    .price-current { font-size: 13px; }
    
    /* حذف المان‌های مزاحم لمسی */
    .slider-nav-btn { display: none !important; } 
    
    /* منوی دسته‌بندی خطی موبایل */
    .categories-grid {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 8px;
        gap: 16px;
        -webkit-overflow-scrolling: touch;
    }
    .category-card { width: 75px; flex-shrink: 0; }
    .category-icon-wrapper-circle { width: 64px; height: 64px; font-size: 26px; }
}