/* static/css/store.css */

/* ─── متغیرها ─────────────────────────────────────────── */
:root {
    --clr-bg:        #0A192F;
    --clr-surface:   #112240;
    --clr-primary:   #1D4ED8;
    --clr-accent:    #F59E0B;
    --clr-accent-dark: #D97706;
    --clr-text:      #F8FAFC;
    --clr-text-muted: #CBD5E1;
    --clr-text-on-light: #0F172A;
    --clr-border:    rgba(29, 78, 216, 0.2);
    --clr-danger:    #EF4444;

    --radius-sm:  6px;
    --radius-md:  12px;
    --radius-lg:  18px;

    --shadow-sm:  0 2px 8px rgba(10, 25, 47, 0.3);
    --shadow-md:  0 4px 16px rgba(10, 25, 47, 0.4);
    --shadow-lg:  0 8px 32px rgba(10, 25, 47, 0.5);

    --transition: .2s ease;
}

/* ─── لایه‌بندی صفحه ──────────────────────────────────── */
.store-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 28px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 20px;
    align-items: start;
}

/* ─── نوار بالای لیست ─────────────────────────────────── */
.store-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--clr-border);
}

.store-topbar__title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--clr-text);
    margin: 0;
}

.store-topbar__count {
    font-size: .85rem;
    color: var(--clr-text-muted);
    margin-right: 8px;
}

.store-topbar__controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ─── جستجو ───────────────────────────────────────────── */
.store-search {
    display: flex;
    align-items: center;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.store-search:focus-within {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.2);
}

.store-search input {
    border: none;
    outline: none;
    padding: 8px 14px;
    font-size: .9rem;
    background: transparent;
    width: 220px;
    font-family: inherit;
    direction: rtl;
    color: var(--clr-text);
}

.store-search input::placeholder {
    color: var(--clr-text-muted);
}

.store-search button {
    background: var(--clr-accent);
    border: none;
    color: var(--clr-text-on-light);
    padding: 8px 14px;
    cursor: pointer;
    transition: background var(--transition);
}

.store-search button:hover {
    background: var(--clr-accent-dark);
}

/* ─── مرتب‌سازی ───────────────────────────────────────── */
.store-sort select {
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: .88rem;
    font-family: inherit;
    background: var(--clr-surface);
    color: var(--clr-text);
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition);
}

.store-sort select:focus {
    border-color: var(--clr-primary);
}

/* ─── سایدبار فیلتر ───────────────────────────────────── */
.store-sidebar {
    background: var(--clr-surface);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 20px;
    border: 1px solid var(--clr-border);
}

.filter-section {
    margin-bottom: 28px;
}

.filter-section:last-child {
    margin-bottom: 0;
}

.filter-section__title {
    font-size: .9rem;
    font-weight: 700;
    color: var(--clr-text);
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--clr-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-section__title i {
    color: var(--clr-primary);
    font-size: .85rem;
}

/* دسته‌بندی درختی */
.category-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-tree li {
    margin-bottom: 4px;
}

.category-tree a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: var(--clr-text);
    text-decoration: none;
    font-size: .88rem;
    transition: background var(--transition), color var(--transition);
}

.category-tree a:hover,
.category-tree a.active {
    background: rgba(29, 78, 216, 0.15);
    color: var(--clr-primary);
}

.category-tree a.active {
    font-weight: 600;
}

.category-tree__children {
    list-style: none;
    padding-right: 16px;
    margin: 4px 0 0;
}

.category-tree__children a {
    font-size: .83rem;
    color: var(--clr-text-muted);
}

/* چک‌باکس فیلتر */
.filter-checkbox-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-checkbox-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .88rem;
    color: var(--clr-text);
    cursor: pointer;
    padding: 4px 0;
}

.filter-checkbox-list input[type="radio"],
.filter-checkbox-list input[type="checkbox"] {
    accent-color: var(--clr-primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* دکمه اعمال فیلتر */
.filter-apply-btn {
    width: 100%;
    padding: 10px;
    background: var(--clr-accent);
    color: var(--clr-text-on-light);
    border: none;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    margin-top: 20px;
}

.filter-apply-btn:hover {
    background: var(--clr-accent-dark);
    transform: translateY(-1px);
}

.filter-reset-link {
    display: block;
    text-align: center;
    margin-top: 10px;
    font-size: .82rem;
    color: var(--clr-text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

.filter-reset-link:hover {
    color: var(--clr-danger);
}

/* ─── گرید محصولات ────────────────────────────────────── */
.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    max-width: 100%;
    box-sizing: border-box;
}

/* ریسپانسیو */
@media (max-width: 1100px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 560px) {
    .products-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
}

/* ─── کارت محصول ──────────────────────────────────────── */
.product-card {
    background: var(--clr-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid var(--clr-border);
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

/* بج‌ها */
.product-card__badges {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 2;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.4;
}

.badge--discount {
    background: var(--clr-danger);
    color: var(--clr-text);
}

.badge--new {
    background: var(--clr-primary);
    color: var(--clr-text);
}

.badge--used {
    background: var(--clr-accent);
    color: var(--clr-text-on-light);
}

.badge--type {
    background: rgba(29, 78, 216, 0.3);
    color: var(--clr-text);
    border: 1px solid var(--clr-border);
}

/* تصویر */
.product-card__image-wrap {
    position: relative;
    width: 100%;
    padding-top: 72%;
    background: var(--clr-bg);
    overflow: hidden;
}

.product-card__image-wrap img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease;
}

.product-card:hover .product-card__image-wrap img {
    transform: scale(1.04);
}

.product-card__no-image {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--clr-text-muted);
    font-size: 2.5rem;
}

/* محتوا */
.product-card__body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
}

.product-card__category {
    font-size: .75rem;
    color: var(--clr-primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.product-card__title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--clr-text);
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card__title a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition);
}

.product-card__title a:hover {
    color: var(--clr-accent);
}

/* رنگ‌ها */
.product-card__colors {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--clr-surface);
    box-shadow: 0 0 0 1px var(--clr-border);
    display: inline-block;
    cursor: default;
    title: attr(title);
}

/* قیمت */
.product-card__footer {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.product-card__price {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.price--original {
    font-size: .75rem;
    color: var(--clr-text-muted);
    text-decoration: line-through;
}

.price--final {
    font-size: 1rem;
    font-weight: 700;
    color: var(--clr-accent);
}

.price--final span {
    font-size: .75rem;
    font-weight: 400;
    color: var(--clr-text-muted);
    margin-right: 2px;
}

.price--unavailable {
    font-size: .85rem;
    color: var(--clr-danger);
    font-weight: 600;
}

.product-card__btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    background: var(--clr-accent);
    color: var(--clr-text-on-light);
    border-radius: var(--radius-sm);
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    transition: background var(--transition), transform var(--transition);
    white-space: nowrap;
}

.product-card__btn:hover {
    background: var(--clr-accent-dark);
    transform: translateY(-1px);
}

/* ─── حالت خالی ───────────────────────────────────────── */
.store-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
    color: var(--clr-text-muted);
}

.store-empty i {
    font-size: 3.5rem;
    margin-bottom: 16px;
    display: block;
    color: var(--clr-text-muted);
    opacity: 0.5;
}

.store-empty p {
    font-size: 1rem;
    margin: 0 0 20px;
}

.store-empty a {
    color: var(--clr-primary);
    text-decoration: none;
    font-weight: 600;
}

/* ─── ریسپانسیو ───────────────────────────────────────── */
@media (max-width: 900px) {
    .store-layout {
        grid-template-columns: 1fr;
    }

    .store-sidebar {
        position: static;
    }

    .store-sidebar-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 9px 16px;
        background: var(--clr-surface);
        border: 1px solid var(--clr-border);
        border-radius: var(--radius-sm);
        font-size: .88rem;
        font-family: inherit;
        cursor: pointer;
        color: var(--clr-text);
    }

    .store-sidebar {
        display: none;
    }

    .store-sidebar.open {
        display: block;
    }
}

@media (max-width: 560px) {
    .store-topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .store-search input {
        width: 160px;
    }
}

/* ─── تگ‌های فیلتر فعال ───────────────────────────────── */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: rgba(29, 78, 216, 0.2);
    color: var(--clr-text);
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
    border: 1px solid var(--clr-border);
}

.active-filter-tag a {
    color: var(--clr-text-muted);
    text-decoration: none;
    font-weight: 700;
    font-size: .9rem;
    line-height: 1;
    transition: color var(--transition);
}

.active-filter-tag a:hover {
    color: var(--clr-danger);
}

/* ==================== محصولات مشابه و مکمل ==================== */
.pd-related {
    margin-top: 48px;
    padding: 0 20px;
}

.pd-related__inner {
    max-width: 1280px;
    margin: 0 auto;
}

.pd-related__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--clr-text);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pd-related__title i {
    color: var(--clr-accent);
    font-size: 1.3rem;
}

.pd-related--complementary {
    margin-top: 32px;
    margin-bottom: 20px;
}

/* گرید محصولات */
.products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* ==================== کارت محصول در بخش مشابه/مکمل (ارتفاع کمتر) ==================== */
.pd-related .product-card {
    border-radius: 12px;
}

.pd-related .product-card__image-wrap {
    padding-bottom: 75% !important;
}

.pd-related .product-card__body {
    padding: 12px 10px 6px !important;
}

.pd-related .product-card__title {
    font-size: 0.85rem !important;
    -webkit-line-clamp: 1 !important;
    line-height: 1.4 !important;
}

.pd-related .product-card__footer {
    padding: 6px 10px 10px !important;
}

.pd-related .price--final {
    font-size: 0.9rem !important;
}

.pd-related .price--final span {
    font-size: 0.65rem !important;
}

.pd-related .price--original {
    font-size: 0.7rem !important;
}

.pd-related .price--unavailable {
    font-size: 0.8rem !important;
}

.pd-related .product-card__btn {
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
    font-size: 0.85rem !important;
}

.pd-related .badge--discount {
    padding: 3px 8px !important;
    font-size: 10px !important;
    top: 8px !important;
    right: 8px !important;
}

/* ==================== رسپانسیو ==================== */
@media (max-width: 1100px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .pd-related {
        padding: 0 16px;
        margin-top: 32px;
    }
    
    .pd-related__title {
        font-size: 1.3rem;
        margin-bottom: 20px;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .pd-related .product-card__image-wrap {
        padding-bottom: 70% !important;
    }
    
    .pd-related .product-card__body {
        padding: 10px 8px 4px !important;
    }
    
    .pd-related .product-card__title {
        font-size: 0.8rem !important;
    }
    
    .pd-related .product-card__footer {
        padding: 4px 8px 8px !important;
    }
    
    .pd-related .price--final {
        font-size: 0.85rem !important;
    }
}

@media (max-width: 480px) {
    .pd-related .product-card__image-wrap {
        padding-bottom: 75% !important;
    }
}

/* اگر می‌خواهید اسلایدری شود (اختیاری) */
@media (max-width: 640px) {
    .pd-related .products-grid {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 12px;
        padding-bottom: 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .pd-related .products-grid::-webkit-scrollbar {
        display: none;
    }
    
    .pd-related .products-grid .product-card {
        flex: 0 0 65%;
        max-width: 250px;
        scroll-snap-align: start;
    }
}

/* برای حالت اسلایدری اختیاری در تبلت */
@media (min-width: 641px) and (max-width: 768px) {
    .pd-related .products-grid .product-card {
        min-width: 0;
    }
}

/* بهبود فیت تصویر در کارت محصول */
.pd-related .product-card__image-wrap img {
    object-fit: contain !important;
    background: var(--clr-bg);
    padding: 8px;
}



/* ==================== لایت مود ==================== */
[data-theme="light"] {
    --clr-bg: #F8FAFC;
    --clr-surface: #FFFFFF;
    --clr-primary: #1E40AF;
    --clr-accent: #1E40AF;
    --clr-accent-dark: #1E3A8A;
    --clr-text: #0F172A;
    --clr-text-muted: #475569;
    --clr-text-on-light: #FFFFFF;
    --clr-border: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .store-topbar__title,
[data-theme="light"] .product-card__title a,
[data-theme="light"] .product-card__title,
[data-theme="light"] .filter-section__title,
[data-theme="light"] .pd-related__title {
    color: #0F172A !important;
}

[data-theme="light"] .store-topbar__count,
[data-theme="light"] .product-card__no-image,
[data-theme="light"] .category-tree__children a,
[data-theme="light"] .store-empty,
[data-theme="light"] .store-empty i {
    color: #64748B !important;
}

[data-theme="light"] .store-search button,
[data-theme="light"] .filter-apply-btn,
[data-theme="light"] .product-card__btn {
    background: #1E40AF !important;
    color: #FFFFFF !important;
}

[data-theme="light"] .store-search button:hover,
[data-theme="light"] .filter-apply-btn:hover,
[data-theme="light"] .product-card__btn:hover {
    background: #1E3A8A !important;
}

[data-theme="light"] .badge--used {
    background: #1E40AF !important;
    color: #FFFFFF !important;
}

[data-theme="light"] .pd-related .product-card__image-wrap img {
    background: #F1F5F9 !important;
}


/* ⭐ NEW: Quick Tabs */
.store-quick-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--clr-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--clr-border);
    margin-bottom: 16px;
    overflow-x: auto;
}

.store-quick-tab {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--clr-border);
    background: transparent;
    color: var(--clr-text-muted);
    transition: all 0.15s;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.store-quick-tab:hover,
.store-quick-tab.active {
    background: var(--clr-primary);
    color: white;
    border-color: var(--clr-primary);
}

/* ⭐ NEW: Quick Links in Sidebar */
.filter-quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-quick-link {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s;
    border: 1px solid var(--clr-border);
    color: var(--clr-text-muted);
}

.filter-quick-link:hover {
    border-color: var(--clr-primary);
    color: var(--clr-primary);
    background: rgba(29, 78, 216, 0.15);
}

.filter-quick-link.active {
    background: var(--clr-primary);
    color: white;
    border-color: var(--clr-primary);
}

/* ⭐ FIX: Sidebar sticky scroll */
.store-sidebar {
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.store-sidebar::-webkit-scrollbar {
    width: 4px;
}

.store-sidebar::-webkit-scrollbar-thumb {
    background: var(--clr-border);
    border-radius: 4px;
}

/* ⭐ FIX: Mobile sidebar overlay */
@media (max-width: 900px) {
    .store-sidebar {
        display: block !important;
        position: fixed;
        right: 0;
        top: 0;
        height: 100vh;
        width: 280px;
        z-index: 1100;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        border-radius: 0;
    }
    
    .store-sidebar.open {
        transform: translateX(0);
    }
    
    .store-sidebar-toggle {
        display: flex !important;
        align-items: center;
        gap: 8px;
        padding: 9px 16px;
        background: var(--clr-surface);
        border: 1px solid var(--clr-border);
        border-radius: var(--radius-sm);
        font-size: .88rem;
        font-family: inherit;
        cursor: pointer;
        color: var(--clr-text);
    }
}