/* ==========================================================
   Base & Section Header
   ========================================================== */
.section {
    margin-block: 50px;
    padding-inline: 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-block-end: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
    position: relative;
    padding-block-end: 10px;
}

.section-header h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    inset-inline-end: 0; /* RTL/LTR Smart */
    width: 60px;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
}

.section-header a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition, all 0.3s);
    padding: 8px 20px;
    background: var(--primary-light);
    border-radius: var(--radius-full);
}

@media (hover: hover) {
    .section-header a:hover {
        background: var(--primary);
        color: white;
        transform: translateY(-2px);
    }
}

/* ==========================================================
   Category Header & Titles
   ========================================================== */
.category-header-title {
    font-size: 1.4rem;
    font-weight: bold;
    color: #2c3e50;
    background-color: #ffffff;
    padding: 15px 20px;
    margin-block: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
    border-inline-start: 5px solid #3b82f6; /* RTL/LTR Smart */
    line-height: 1.6;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
    transition: var(--transition, all 0.3s);
}

@media (hover: hover) {
    .category-header-title:hover {
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
        transform: translateY(-2px);
    }
}

.custom-section-title {
    font-size: 1.3rem;
    color: #333;
    margin-block: 40px 20px;
    padding-block-end: 10px;
    border-block-end: 2px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==========================================================
   Search Section (Live Search)
   ========================================================== */
.search-section {
    max-width: 720px;
    margin-block: 30px;
    margin-inline: auto;
    padding-inline: 20px;
    position: relative;
}

.search-wrapper {
    position: relative;
}

#liveSearch {
    width: 100%;
    padding-block: 16px;
    padding-inline: 48px 24px; /* فضا برای آیکون */
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
    background: white;
}

#liveSearch:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.search-icon {
    position: absolute;
    inset-inline-start: 20px; /* RTL/LTR Smart */
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    opacity: 0.5;
    pointer-events: none;
}

#results {
    position: absolute;
    width: calc(100% - 40px);
    inset-inline-start: 20px; /* RTL/LTR Smart */
    max-height: 400px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-block-start: 8px;
    z-index: 1000;
    display: none;
}

.result-item {
    padding: 15px 20px;
    cursor: pointer;
    border-block-end: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.result-item:hover {
    background: var(--primary-light);
}

.result-icon {
    font-size: 1.5rem;
}

.result-content {
    flex: 1;
}

.result-title {
    font-weight: 600;
    color: var(--dark);
}

.result-subtitle {
    font-size: 0.85rem;
    color: var(--gray);
}

/* ==========================================================
   Categories (Tabs, Bar & Badge)
   ========================================================== */
.category-tabs {
    position: sticky;
    top: 56px;
    z-index: 900;
    background: white;
    border-block-end: 1px solid var(--border);
    padding-block: 15px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    box-shadow: var(--shadow-sm);
}

.tabs-container {
    max-width: 1400px;
    margin-inline: auto;
    padding-inline: 20px;
}

.category-tabs a {
    display: inline-block;
    padding: 10px 24px;
    margin-inline: 4px;
    background: #f1f5f9;
    border-radius: var(--radius-full);
    color: var(--gray);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.category-tabs a:hover {
    background: var(--primary-light);
    color: var(--primary);
    transform: translateY(-2px);
}

.category-tabs a.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.category-bar {
    background: white;
    border-radius: var(--radius-lg);
    padding: 15px 25px;
    margin-block-end: 30px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.category-icon {
    background: var(--primary-light);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
}

.category-name {
    font-size: 1.1rem;
    color: var(--dark);
    font-weight: 500;
}

.category-badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    margin-block-start: 10px;
}

/* ==========================================================
   Products Scroller & Card
   ========================================================== */
.products-scroller {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-block-end: 20px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.product-card {
    flex: 0 0 280px;
    width: 280px;
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition, all 0.3s);
    cursor: pointer;
    border: 1px solid var(--border);
    position: relative;
    display: flex;
    flex-direction: column;
}

@media (hover: hover) {
    .product-card:hover {
        transform: translateY(-8px);
        box-shadow: var(--shadow-lg);
    }
    .product-card:hover .product-image-wrapper img {
        transform: scale(1.1);
    }
}

.product-image-wrapper {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: #f1f5f9;
}

.product-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.sale-ribbon {
    position: absolute;
    top: 12px;
    inset-inline-end: 12px; /* RTL/LTR Smart */
    background: var(--danger);
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    z-index: 10;
}

/* Product Meta */
.product-meta {
    padding: 15px;
    flex: 1;
}

.title {
    font-weight: 600;
    margin-block-end: 10px;
    line-height: 1.5;
    height: 3em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 1rem;
}

.seller {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-block-end: 10px;
    font-size: 0.9rem;
}

.seller img.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-light);
}

.stats {
    display: flex;
    gap: 15px;
    margin-block-end: 10px;
    color: var(--gray);
    font-size: 0.85rem;
}

.stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stats img {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

/* Pricing Section */
.pricing-area {
    margin-block-end: 25px;
    padding-block-start: 20px;
    border-block-start: 1px dashed var(--border);
}

.price {
    font-weight: 700;
    color: var(--danger);
    font-size: 1.1rem;
}

.price del {
    color: var(--gray);
    font-weight: normal;
    margin-inline-end: 8px; /* RTL/LTR Smart */
    font-size: 0.9rem;
}

.old-price {
    display: block;
    font-size: 1.1rem;
    color: var(--gray);
    text-decoration: line-through;
    margin-block-end: 5px;
}

.free-price {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--success);
}

.test-badge {
    margin-inline-end: 5px; /* RTL/LTR Smart */
    font-size: 0.85rem;
    background: #dcfce7;
    color: var(--success-hover);
    padding: 4px 8px;
    border-radius: 6px;
    vertical-align: middle;
}

/* ==========================================================
   Ads System (Banners, Ribbons, Plans)
   ========================================================== */
.ad-banner {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fde68a;
    border-radius: var(--radius-lg);
    padding: 20px 25px;
    margin-block-end: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    flex-wrap: wrap;
}

.ad-badge {
    position: absolute;
    top: 0;
    inset-inline-end: 25px; /* RTL/LTR Smart */
    background: var(--warning);
    color: white;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: bold;
    border-radius: 0 0 8px 8px;
}

.ad-content {
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1;
}

.ad-icon {
    font-size: 2.5rem;
}

.ad-text h4 {
    color: #92400e;
    margin-block-end: 5px;
    font-size: 1.2rem;
    font-weight: 700;
}

.ad-text p {
    color: #b45309;
    font-size: 0.95rem;
    margin: 0;
}

.ad-button {
    background: var(--warning);
    color: white;
    padding: 10px 24px;
    border-radius: var(--radius-full);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    z-index: 1;
    white-space: nowrap;
}

.ad-button:hover {
    background: #d97706;
    transform: translateY(-2px);
    color: white;
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.3);
}

.sponsored-ribbon, .promo-label {
    position: absolute;
    top: 12px;
    inset-inline-start: 12px; /* RTL/LTR Smart */
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    z-index: 10;
}

.ad-ribbon {
    position: absolute;
    top: 15px;
    inset-inline-end: -35px; /* RTL/LTR Smart */
    color: white;
    padding: 5px 40px;
    font-size: 0.8rem;
    font-weight: bold;
    transform: rotate(45deg);
    z-index: 15;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    text-align: center;
}
/* برای RTL باید در صورت نیاز جهت چرخش را تنظیم کنید (بسته به نیاز ظاهری) */
[dir="rtl"] .ad-ribbon {
    transform: rotate(-45deg);
}

/* 1. Ladder Plan */
.ad-ladder { border: 2px solid #3b82f6 !important; box-shadow: 0 0 15px rgba(59, 130, 246, 0.15) !important; }
.ad-ladder .sponsored-ribbon, .ad-ladder-label { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4); }
.ad-ladder .ad-ribbon { background: #3b82f6; }

/* 2. Clicks Plan */
.ad-clicks { border: 2px solid #10b981 !important; box-shadow: 0 0 15px rgba(16, 185, 129, 0.15) !important; }
.ad-clicks .sponsored-ribbon, .ad-clicks-label { background: var(--secondary); color: white; box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4); }
.ad-clicks .ad-ribbon { background: #10b981; }

/* 3. VIP Plan */
.ad-vip { border: 2px solid #f59e0b !important; box-shadow: 0 0 20px rgba(245, 158, 11, 0.25) !important; position: relative; }
.ad-vip::before { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 20px rgba(245, 158, 11, 0.1); pointer-events: none; z-index: 1; }
.ad-vip .sponsored-ribbon, .ad-vip-label { background: var(--warning); color: white; box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4); }
.ad-vip .ad-ribbon { background: #f59e0b; }

/* ==========================================================
   Promo Banner Wrapper
   ========================================================== */
.promo-banner-wrapper {
    margin-block: 40px 20px;
    overflow-x: auto;
    padding-block-end: 15px;
}

.promo-banner-container {
    display: flex;
    gap: 25px;
}

.promo-banner {
    flex: 0 0 320px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    position: relative;
    background: #fff;
    transition: all 0.3s;
}

@media (hover: hover) {
    .promo-banner:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow-lg);
    }
}

.promo-banner img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

/* ==========================================================
   Empty State
   ========================================================== */
.empty-info {
    color: var(--gray);
    font-style: italic;
}

.empty-state {
    text-align: center;
    padding-block: 60px;
    padding-inline: 20px;
    color: var(--gray);
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
}

/* =========================================
   استایل‌های پایه کارت "مشاهده بیشتر" (اسکرولر)
========================================= */
.view-more-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 120px; /* عرض کارت */
    background-color: #f8f9fa; /* رنگ روشن پس‌زمینه */
    border: 1px dashed #ced4da; /* حاشیه خط‌چین برای تمایز */
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.view-more-card:hover {
    background-color: #e9ecef;
}

.view-more-card .arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease;
}

.view-more-card:hover .arrow {
    transform: translateX(-5px); /* حرکت ملایم به سمت چپ هنگام هاور */
}

.view-more-card .arrow img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* هوشمندسازی برای حالت LTR (انگلیسی) */
[dir="ltr"] .view-more-card:hover .arrow {
    transform: translateX(5px); /* در انگلیسی به سمت راست حرکت کند */
}
[dir="ltr"] .view-more-card .arrow img {
    transform: scaleX(-1); /* برعکس شدن آیکون فلش */
}


@media (hover: hover) {
    .view-more-card:hover {
        background: rgba(30, 30, 30, 0.6);
        transform: translateY(-4px) scale(1.03);
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    .view-more-card:hover .arrow {
        transform: translateX(6px); /* LTR */
    }
    [dir="rtl"] .view-more-card:hover .arrow {
        transform: translateX(-6px); /* RTL */
    }
}

/* ==========================================================
   Responsive Breakpoints
   ========================================================== */
@media (max-width: 768px) {
    .product-card { flex: 0 0 240px; width: 240px; }
    .title { font-size: 0.9rem; }
    .price { font-size: 0.95rem; }
    .price del { font-size: 0.8rem; }
    .promo-banner { flex: 0 0 260px; }
    .category-header-title { font-size: 1.2rem; padding: 12px 15px; }
    
    .view-more-card {
        flex: 0 0 110px;
        padding: 9px 14px;
        font-size: 0.95rem;
        backdrop-filter: blur(10px) saturate(150%);
        -webkit-backdrop-filter: blur(10px) saturate(150%);
    }
    .view-more-card .arrow { font-size: 1.1rem; }
}

@media (max-width: 480px) {
    .product-card { flex: 0 0 200px; width: 200px; }
    .product-image-wrapper { height: 150px; }
    .title { font-size: 0.82rem; }
    .price { font-size: 0.88rem; }
    .price del { font-size: 0.75rem; }
    .stats { font-size: 0.75rem; gap: 8px; }
    .seller { font-size: 0.8rem; }
    
    .view-more-card {
        flex: 0 0 100px;
        padding: 8px 12px;
        font-size: 0.9rem;
        gap: 6px;
    }
    .view-more-card .arrow { font-size: 1rem; }
}

/* ==========================================================
   Dark Mode Base 
   ========================================================== */
[data-theme="dark"] .section-header h2 { color: #f1f5f9; }
[data-theme="dark"] .section-header a {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}
[data-theme="dark"] .section-header a:hover {
    background: var(--primary, #3b82f6);
    color: #ffffff;
}

[data-theme="dark"] .category-header-title {
    background-color: #1e1e1e;
    color: #f1f5f9;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .custom-section-title {
    color: #f1f5f9;
    border-block-end-color: #333333;
}

/* Dark Mode: Search */
[data-theme="dark"] #liveSearch {
    background: #1e1e1e;
    border-color: #333;
    color: #f1f5f9;
}
[data-theme="dark"] #results {
    background: #1e1e1e;
    border-color: #333;
}
[data-theme="dark"] .result-item { border-block-end-color: #333; }
[data-theme="dark"] .result-item:hover { background: rgba(255, 255, 255, 0.05); }
[data-theme="dark"] .result-title { color: #e2e8f0; }

/* Dark Mode: Categories */
[data-theme="dark"] .category-tabs {
    background: #121212;
    border-block-end-color: #333;
}
[data-theme="dark"] .category-tabs a {
    background: #1e1e1e;
    color: #cbd5e1;
}
[data-theme="dark"] .category-tabs a.active {
    background: var(--primary);
    color: white;
}
[data-theme="dark"] .category-bar {
    background: #1e1e1e;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Dark Mode: Products & Banners */
[data-theme="dark"] .product-card,
[data-theme="dark"] .promo-banner {
    background-color: #1e1e1e;
    border-color: #333333;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .product-image-wrapper { background-color: #2d3748; }
[data-theme="dark"] .product-meta .title { color: #e2e8f0; }
[data-theme="dark"] .product-meta .seller { color: #cbd5e1; }
[data-theme="dark"] .product-meta .seller img.avatar { border-color: #475569; }
[data-theme="dark"] .product-meta .stats,
[data-theme="dark"] .product-meta .price del { color: #94a3b8; }
[data-theme="dark"] .product-meta .stats img { filter: brightness(0) invert(1) opacity(0.8); }
[data-theme="dark"] .pricing-area { border-block-start-color: #333; }

/* Dark Mode: Ads System */
[data-theme="dark"] .ad-banner {
    background: linear-gradient(135deg, rgba(146, 64, 14, 0.15) 0%, rgba(180, 83, 9, 0.2) 100%);
    border-color: rgba(245, 158, 11, 0.3);
}
[data-theme="dark"] .ad-text h4 { color: #fcd34d; }
[data-theme="dark"] .ad-text p { color: #fde68a; }
[data-theme="dark"] .ad-button {
    background: #d97706;
}

/* Dark Mode: Empty State */
[data-theme="dark"] .empty-state {
    background: #1e1e1e;
    color: #cbd5e1;
}
/* =========================================
   استایل‌های دارک‌مود برای کارت "مشاهده بیشتر"
========================================= */
[data-theme="dark"] .view-more-card {
    background-color: #1e293b; /* رنگ تیره کارت */
    border-color: #334155;
}

[data-theme="dark"] .view-more-card:hover {
    background-color: #334155;
}

[data-theme="dark"] .view-more-card .arrow {
    background-color: #0f172a; /* دایره تیره‌تر دور فلش */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .view-more-card .arrow img {
    filter: brightness(0) invert(1); /* سفید کردن آیکون فلش */
}
/* رفع مشکل افتادن نوار محصولات (دسته‌بندی‌ها) روی باکس جستجو */

.search-section {
    margin-top: 40px !important; /* ایجاد فاصله اجباری از بالا */
    margin-bottom: 30px !important;
    position: relative;
    z-index: 10; /* قرارگیری در لایه مناسب */
}

.category-tabs {
    position: sticky;
    top: 0px; /* مطمئن شوید این عدد با ارتفاع هدر اصلی سایت شما برابر است */
    z-index: 900;
    margin-bottom: 20px; /* ایجاد فاصله از پایین برای جلوگیری از چسبیدن به المان‌های بعدی */
}

/* در حالت موبایل ممکن است نیاز به فاصله متفاوتی باشد */
@media (max-width: 768px) {
    .search-section {
        margin-top: 30px !important;
    }
}
