﻿/* ========================================
   Archive Product Page Styles (Responsive & Fixed Grid)
======================================== */

:root {
    --ap-navy:        #184362;
    --mobile-text-color: #ffffff;
    --grid-cols:      4;
    --mobile-clear-color: #ff6b6b;
    --grid-mobile-cols: 3;
    --ap-orange:      #f2971e;
    --ap-blue:        #14a8e3;
    --ap-text:        #212529;
    --ap-muted:       #56778f;
    --ap-gray:        #5e6972;
    --ap-platin:      #e7e9eb;
    --ap-light:       #f8f9fa;
    --ap-card-bg:     #f9fbfa;
    --ap-border:      #e7e9eb;
    --ap-radius-sm:   10px;
    --ap-radius-md:   15px;
    --ap-radius-lg:   20px;
    --ap-radius-xl:   30px;
    --ap-shadow-1:    0 0 15px 0 rgba(0,0,0,0.05);
    --ap-shadow-2:    0 15px 25px 0 rgba(190,190,190,0.2);
}

.ap-page { direction: rtl; padding: 24px 5% 64px; position: relative; background: #fff; max-width: 1440px; margin: 0 auto; }
.ap-hero-band { position: absolute; top: -200px; left: -39px; width: 1832px; height: 746px; transform: rotate(7.01deg); z-index: 0; pointer-events: none; overflow: hidden; }
.ap-hero-band img { width: 100%; height: 100%; object-fit: cover; }
.ap-top-content { position: relative; z-index: 1; }

/* 🧩 ستون‌بندی صفحه 🧩 */
.ap-main-layout { display: grid; grid-template-columns: 312px 1fr; gap: 24px; margin-top: 24px; align-items: flex-start; }

/* ── سایدبار ── */
.ap-sidebar { display: flex; flex-direction: column; gap: 8px; width: 100%; background: #fff; }
.ap-sidebar-header { display: none; }



/* ── هدر سایدبار: عنوان + باکس سرچ کنار هم ── */
.ap-sidebar-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--ap-orange);
}
.ap-sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--ap-navy);
    white-space: nowrap;
    /* border-bottom حذف شد — الان روی row هست */
}

/* ── باکس سرچ ویژگی‌ها ── */
.ap-attr-search {
    flex: 1;
    border: 1.5px solid var(--ap-border);
    border-radius: 10px;
    padding: 5px 10px;
    font-size: 13px;
    color: var(--ap-text);
    direction: rtl;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
}
.ap-attr-search:focus {
    border-color: var(--ap-orange);
}

/* ── انیمیشن هایلایت متن پیدا شده ── */
@keyframes highlightFade {
    0%   { background: rgba(242,151,30,0.4); }
    100% { background: transparent; }
}
.ap-attr-highlight {
    animation: highlightFade 1.5s ease forwards;
    border-radius: 4px;
}



.ap-cat-active, .ap-cat-item { border: 1px solid var(--ap-border); border-radius: var(--ap-radius-lg); padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; }
.ap-cat-active { background: var(--ap-card-bg); }
.ap-cat-active .cat-name { font-size: 14px; font-weight: 700; color: var(--ap-orange); }
.ap-cat-item .cat-name { font-size: 14px; font-weight: 700; color: #222; }
.cat-count-wrap { background: var(--ap-light); border-radius: var(--ap-radius-sm); padding: 8px 10px; display: flex; align-items: center; gap: 6px; }
.cat-count-wrap img { width: 16px; height: 16px; }
.cat-count { font-size: 12.25px; color: var(--ap-text); }
.ap-cat-sub { font-size: 12.25px; font-weight: 500; color: #000; text-align: right; padding: 2px 16px; }


.ap-filter-overlay {
    display: none;
}


@media (max-width: 992px) {
    .ap-filter-widget-inner {
        background: transparent !important;
    }
    .ap-filter-widget-inner * {
        color: var(--mobile-text-color, #fff) !important;
    }
    .ap-filter-widget-inner .ap-cat-active .cat-name {
        color: var(--ap-orange) !important;
    }
    .ap-filter-widget-inner .ap-attr-label input[type="checkbox"]:checked {
        background: var(--ap-orange) !important;
        border-color: var(--ap-orange) !important;
    }
}



.ap-promo-card { width: 100%; height: 297px; border-radius: var(--ap-radius-xl); overflow: hidden; position: relative; margin-top: 8px; }
.ap-promo-card > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ap-promo-card-text { position: absolute; right: 16px; top: 24px; text-align: right; z-index: 2; display: flex; flex-direction: column; gap: 16px; }
.ap-promo-card-text .disc { font-size: 14px; font-weight: 300; color: rgba(24,67,98,0.7); }
.ap-promo-card-text h3 { font-size: 24px; font-weight: 900; color: var(--ap-navy); margin: 0; }

/* ── Promo Slider ── */
.ap-slider-wrap { position: relative; width: 100%; height: 331px; border-radius: var(--ap-radius-xl); overflow: hidden; }
.ap-slider-wrap > img.ap-slider-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ap-slider-product-1 { position: absolute; bottom: 0; left: 55px; width: 233px; transform: scaleY(-1) rotate(180deg); }
.ap-slider-product-2 { position: absolute; bottom: 0; left: 0; width: 154px; transform: scaleY(-1) rotate(180deg); }

.ap-slider-text { position: absolute; right: 50px; top: 50px; text-align: right; }
.ap-slider-text .disc { font-size: 14px; font-weight: 300; margin-bottom: 16px; }
.ap-slider-text h2 { font-size: 32px; font-weight: 900; color: var(--ap-navy); margin-bottom: 4px; }
.ap-slider-text .sub { font-size: 16px; margin-bottom: 24px; color: var(--ap-navy); }
.ap-slider-text .ap-cta { background: #fff; border: none; border-radius: 16px; padding: 8px 16px; font-weight: 600; color: var(--ap-navy); cursor: pointer; }

.ap-slider-dots { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.ap-slider-dots .dot { width: 8px; height: 8px; border-radius: 15px; background: var(--ap-light); }
.ap-slider-dots .dot.active { width: 32px; }

.ap-slider-arrows { position: absolute; top: 50%; transform: translateY(-50%); left: 0; right: 0; display: flex; justify-content: space-between; padding: 0 16px; pointer-events: none; z-index: 5; }
.ap-slider-arrows .arr-btn { background: #fff; border: none; border-radius: var(--ap-radius-md); width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; box-shadow: var(--ap-shadow-2); cursor: pointer; pointer-events: all; }

/* ── Instrument filter strip ── */
.ap-instrument-strip { position: relative; margin-top: 40px; width: 100%; display: flex; align-items: center; overflow: hidden; }
.ap-instrument-list { display: flex; gap: 32px; overflow-x: auto; scrollbar-width: none; padding: 10px 0; width: 100%; scroll-behavior: smooth; }
.ap-instrument-list::-webkit-scrollbar { display: none; }
.ap-instrument-item { display: flex; align-items: center; gap: 14px; cursor: pointer; white-space: nowrap; }
.ap-instrument-item img { width: 36px; height: 36px; object-fit: contain; }
.ap-instrument-item span { font-size: 16px; font-weight: 600; color: var(--ap-navy); }

.ap-inst-arrow { background: #fff; border: none; border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(0,0,0,0.1); cursor: pointer; flex-shrink: 0; z-index: 2; }
.ap-inst-arrow.right-arrow { margin-left: 10px; }
.ap-inst-arrow.left-arrow { margin-right: 10px; }

/* ── Sort & Filter Mobile Bar ── */
.ap-controls-header { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 30px; border-bottom: 2px solid var(--ap-orange); padding-bottom: 6px; }
.ap-sort-bar-title { font-size: 21px; font-weight: 700; color: var(--ap-text); margin: 0; }



.ap-mobile-filter-btn { display: none; }

.ap-float-filter-btn {
    display: none;
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 9997;
    background: var(--ap-navy);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 64px;
    height: 64px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 8px 24px rgba(24,67,98,0.4);
}

@media (max-width: 992px) {
    .ap-float-filter-btn { display: flex; }
}





.ap-sort-tabs { display: flex; gap: 16px; align-items: center; margin-top: 12px; overflow-x: auto; white-space: nowrap; padding-bottom: 8px; scrollbar-width: none; }
.ap-sort-tabs::-webkit-scrollbar { display: none; }
.ap-sort-tab { font-size: 14px; font-weight: 700; color: rgba(33,37,41,0.7); cursor: pointer; padding-bottom: 4px; border-bottom: 2px solid transparent; transition: all .2s; }
.ap-sort-tab.active { color: var(--ap-orange); border-bottom-color: var(--ap-orange); }

/* ── Product Grid (اصلاح شده برای هماهنگی ارتفاع و ستون ها) ── */
.ap-products-grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-cols, 4), 1fr);
    gap: 16px;
    margin-top: 24px;
    align-items: stretch; /* کشش تمام کارت‌ها به یک اندازه */
}

.ap-product-card {
    display: flex;
    flex-direction: column;
    height: 100%; /* اشغال تمام ارتفاع ردیف */
    cursor: pointer;
}
.ap-product-card-img { width: 100%; aspect-ratio: 1 / 1; border-radius: var(--ap-radius-md); overflow: hidden; background: #f0f0f0; display: flex; align-items: center; justify-content: center; }
.ap-product-card-img img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }

.ap-product-card-body {
    padding: 8px 4px 0;
    text-align: right;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* این باعث میشه دکمه همیشه بره ته کارت */
}
.ap-product-card-body .p-name { font-size: 14px; font-weight: 700; color: var(--ap-text); margin-bottom: 4px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ap-stars { display: flex; gap: 2px; margin-bottom: auto; /* فاصله بین ستاره و قیمت تنظیم میشود */ }
.ap-stars span { color: var(--ap-orange); font-size: 12px; }

.ap-price-row { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 10px; margin-bottom: 8px; }
.ap-price-main { font-size: 15px; font-weight: 700; color: var(--ap-navy); }
.ap-price-unit { font-size: 11px; color: var(--ap-muted); }
.ap-add-btn { width: 100%; background: var(--ap-navy); color: #fff; border: none; border-radius: 10px; padding: 8px; font-size: 13px; font-weight: 500; cursor: pointer; text-align: center; text-decoration: none; display: block; margin-top: auto; /* چسبیدن دکمه به پایین */ }

/* ── Pagination (اصلاح شده طبق فیگما) ── */
.ap-pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; margin-top: 40px; width: 100%;
}
.ap-page-btn {
    width: 40px; height: 40px; border: 1px solid var(--ap-border); border-radius: var(--ap-radius-md);
    display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700;
    color: #30373e; cursor: pointer; background: #fff; transition: all .2s; text-decoration: none;
}
.ap-page-btn.active { background: var(--ap-blue); border-color: var(--ap-blue); color: #fff; }
.ap-page-next {
    padding: 0 16px; height: 40px; border: 1px solid var(--ap-border); border-radius: var(--ap-radius-md);
    display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
    color: #30373e; cursor: pointer; text-decoration: none; background: #fff;
}

.ap-seo-box { background: var(--ap-light); border-radius: var(--ap-radius-xl); padding: 32px; margin-top: 48px; text-align: justify; width: 100%; }
.ap-seo-box h2 { font-size: 20px; font-weight: 700; color: #222; margin-bottom: 18px; }
.ap-seo-box p { font-size: 14px; line-height: 1.8; margin-bottom: 12px; }

/* ==========================================
   🌟 مدیا کوئری‌ها 🌟
========================================== */
@media (max-width: 1200px) {
    .ap-main-layout { grid-template-columns: 260px 1fr; }
    .ap-products-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 992px) {
    .ap-hero-band { display: none; }
    .ap-main-layout { display: block; }

    .ap-sidebar {
        position: fixed;
        top: -100%;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 50vh;
        overflow-y: auto;
        z-index: 9999;
        padding: 20px 24px 32px;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border-radius: 0 0 24px 24px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.2);
        transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: auto;
    }
    .ap-sidebar.active { top: 0; }

    .ap-sidebar * { color: var(--mobile-text-color, #fff) !important; }
    .ap-sidebar .ap-cat-active .cat-name { color: var(--ap-orange) !important; }
    .ap-sidebar .ap-attr-label input[type="checkbox"] { border-color: var(--mobile-text-color, #fff) !important; background: transparent !important; }
    .ap-sidebar .ap-attr-label input[type="checkbox"]:checked { background: var(--ap-orange) !important; border-color: var(--ap-orange) !important; }
    .ap-sidebar .ap-clear-top { border-color: var(--mobile-clear-color, #ff6b6b) !important; color: var(--mobile-clear-color, #ff6b6b) !important; background: transparent !important; }
    .ap-sidebar .ap-cat-item { border-color: var(--mobile-text-color, #fff); background: transparent; }
    .ap-sidebar .ap-cat-active { background: transparent; }
    .ap-sidebar .ap-sidebar-title-row { border-bottom-color: var(--mobile-text-color, #fff); }
    .ap-sidebar .ap-attr-label { background: transparent !important; border-color: var(--mobile-text-color, #fff) !important; }
    .ap-sidebar .ap-attr-search { background: transparent !important; border-color: var(--mobile-text-color, #fff) !important; color: var(--mobile-text-color, #fff) !important; }
    .ap-sidebar .ap-attr-search::placeholder { color: var(--mobile-text-color, #fff) !important; opacity: 0.6; }
    .ap-sidebar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; border-bottom: 1px solid var(--mobile-text-color, #fff); padding-bottom: 12px; }
    .ap-close-btn { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--mobile-clear-color, #ff6b6b) !important; }
    .ap-filter-widget-inner { background: transparent !important; }

    .ap-slider-wrap { height: 180px; }
    .ap-slider-product-1, .ap-slider-product-2 { display: none; }
    .ap-slider-text { right: 20px; top: 20px; }
    .ap-slider-text h2 { font-size: 20px; }
    .ap-slider-text .sub { font-size: 12px; margin-bottom: 10px; }
    .ap-slider-text .ap-cta { padding: 6px 12px; font-size: 12px; }
    .ap-slider-arrows .arr-btn { width: 30px; height: 30px; }
    .ap-slider-arrows .arr-btn svg { width: 14px; height: 14px; }
    .ap-products-grid { display: grid !important; grid-template-columns: repeat(var(--grid-mobile-cols, 3), 1fr) !important; gap: 12px; }
}

@media (max-width: 576px) {
    .ap-page { padding: 16px 4% 40px; overflow-x: hidden; }
    .ap-controls-header { flex-direction: column; align-items: flex-start; gap: 12px; border: none; margin-top: 20px; }
    .ap-sort-bar-title { border-bottom: 2px solid var(--ap-orange); padding-bottom: 6px; width: auto; }
    .ap-mobile-filter-btn { width: 100%; justify-content: center; padding: 10px; }
    .ap-instrument-list, .ap-sort-tabs { margin-right: -4vw; margin-left: -4vw; padding-right: 4vw; padding-left: 4vw; }
    .ap-inst-arrow { width: 30px; height: 30px; }
    .ap-inst-arrow svg { width: 14px; height: 14px; }
    .ap-inst-arrow.right-arrow { margin-left: 5px; position: absolute; right: 0; z-index: 5; }
    .ap-inst-arrow.left-arrow { margin-right: 5px; position: absolute; left: 0; z-index: 5; }

    /* 🚨 نمایش 3 ستونه دقیقاً در موبایل طبق درخواست شما 🚨 */
    .ap-products-grid { grid-template-columns: repeat(var(--grid-mobile-cols, 3), 1fr) !important; gap: 8px; }

    /* کوچک کردن فونت کارت‌ها در حالت 3 ستونه موبایل برای جا شدن متن */
    .ap-product-card-body .p-name { font-size: 11px; }
    .ap-price-main { font-size: 12px; }
    .ap-price-unit { font-size: 9px; }
    .ap-add-btn { font-size: 11px; padding: 6px; }
    .ap-stars span { font-size: 9px; }
    /* حالت ۴ ستونه موبایل */
    .ap-products-grid[style*="--grid-mobile-cols:4"] .ap-product-card-body .p-name { font-size: 9px; }
    .ap-products-grid[style*="--grid-mobile-cols:4"] .ap-price-main { font-size: 10px; }
    .ap-products-grid[style*="--grid-mobile-cols:4"] .ap-price-unit { display: none; }
    .ap-products-grid[style*="--grid-mobile-cols:4"] .ap-add-btn { font-size: 9px; padding: 4px; }
    .ap-products-grid[style*="--grid-mobile-cols:4"] .ap-stars { display: none; }
}


/* ── زیرمنوی ویژگی‌های دسته‌بندی ── */
.ap-cat-attrs {
    display: none;           /* پیش‌فرض بسته */
    padding: 6px 0 10px;
    border-right: 2px solid var(--ap-orange);
    margin-right: 16px;
    margin-bottom: 6px;
}

@media (max-width: 992px) {
    .ap-cat-attrs {
        display: none;
        flex-wrap: wrap;
        flex-direction: row;
        gap: 6px;
        padding: 8px 0;
        border-right: none;
        border-top: 1px solid rgba(255,255,255,0.15);
        margin-right: 0;
    }
    .ap-cat-attrs.open-attrs {
        display: flex !important;
    }
    .ap-attr-label {
        padding: 6px 12px;
        background: rgba(255,255,255,0.1);
        border-radius: 20px;
        font-size: 12px;
        gap: 6px;
    }
}




/* ── زیرمنو: چیدمان افقی ── */
.ap-cat-attrs {
    display: none;
    flex-wrap: wrap;
    flex-direction: row;
    gap: 6px;
    padding: 8px 0;
    border-right: 2px solid var(--ap-orange);
    margin-right: 16px;
    margin-bottom: 6px;
}
.ap-cat-attrs[style*="block"] {
    display: flex !important;
}

/* ── هر ردیف چک‌باکس ── */
.ap-attr-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    border-radius: 20px;
    border: 1.5px solid var(--ap-border);
    background: #fff;
    transition: all 0.15s;
    direction: rtl;
    white-space: nowrap;
}
.ap-attr-label:hover {
    border-color: var(--ap-orange);
    color: var(--ap-orange);
}
.ap-attr-label:has(input:checked) {
    background: var(--ap-orange);
    border-color: var(--ap-orange);
    color: #fff;
}



/* ── استایل چک‌باکس ── */
.ap-attr-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--ap-border);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    background: #fff;
}
.ap-attr-label input[type="checkbox"]:checked {
    background: var(--ap-orange);
    border-color: var(--ap-orange);
}
/* تیک داخل چک‌باکس */
.ap-attr-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 1px;
    left: 4px;
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

/* ── دکمه حذف فیلتر ── */
/* دکمه حذف فیلتر */
.ap-clear-filter-btn {
    display: none;
    width: 100%;
    padding: 10px;
    background: #fff;
    border: 1.5px solid #e74c3c;
    border-radius: var(--ap-radius-md);
    color: #e74c3c;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    direction: rtl;
    margin-top: 16px;
}
.ap-clear-filter-btn:hover {
    background: #e74c3c;
    color: #fff;
}

/* موبایل: بالای سایدبار - فقط در موبایل */
.ap-clear-top {
    display: none;
    position: sticky;
    top: 0;
    z-index: 10;
    margin-top: 0;
    margin-bottom: 12px;
    background: rgba(231, 76, 60, 0.85) !important;
    color: #fff !important;
    border-color: transparent !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* دسکتاپ: پایین سایدبار - فقط در دسکتاپ */
.ap-clear-desktop {
    display: none;
    margin-top: 16px;
}

@media (min-width: 993px) {
    .ap-filter-widget-inner {
        display: flex;
        flex-direction: column;
    }
    .ap-clear-desktop {
        order: -1;
        margin-top: 0;
        margin-bottom: 12px;
        position: sticky;
        top: 0;
        z-index: 10;
    }
}