/* ==========================================================================
   ساختار اصلی صفحه محصولات
   ========================================================================== */

.products-page {
    padding: 3rem 0;
    background-color: #f9fafb;
    direction: rtl;
}

.products-page .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

input,
select,
textarea,
button {
    font-family: 'Vazirmatn', sans-serif;
}

/* ==========================================================================
   بخش Hero
   ========================================================================== */

.hero-section {
    position: relative;
    background: linear-gradient(135deg, #1a1a1a 0%, #333333 100%);
    width: 100vw;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    border-radius: 0;
    margin-top: -100px;
    padding: 180px 20px 140px;
    text-align: center;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    box-shadow: var(--shadow);
    min-height: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hero-content h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    font-weight: 800;
}

.hero-content p {
    font-size: 1.1rem;
    color: #cccccc;
    max-width: 600px;
    margin: 0 auto;
}

/* ==========================================================================
   لایه‌بندی سایدبار فیلتر و محصولات
   ========================================================================== */

.products-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1.5rem;
}

/* سایدبار سمت راست */
.products-sidebar {
    flex: 0 0 250px;
    width: 250px;
}

/* بخش اصلی محصولات سمت چپ */
.products-main {
    flex: 1;
    min-width: 0;
}

/* ==========================================================================
   سایدبار فیلترها
   ========================================================================== */

.filters-box {
    position: sticky;
    top: 110px;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

.filters-header {
    padding: 1.25rem 1.25rem 0.75rem;
}

.filters-header h3 {
    margin: 0;
    color: #1f2937;
    font-size: 1.15rem;
    font-weight: 800;
}

/* هر آیتم فیلتر */
.filter-item {
    border-bottom: 1px solid #edf0f2;
}

.filter-item:last-of-type {
    border-bottom: none;
}

/* مخفی کردن فلش پیش‌فرض details */
.filter-item summary::-webkit-details-marker {
    display: none;
}

.filter-item summary::marker {
    display: none;
}

/* عنوان هر فیلتر */
.filter-summary {
    list-style: none;
    cursor: pointer;
    min-height: 56px;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #374151;
    transition: background-color 0.2s ease;
}

.filter-summary:hover {
    background-color: #f9fafb;
}

.filter-label {
    font-size: 0.92rem;
    color: #374151;
    font-weight: 600;
}

/* ارسال سریع */
.filter-fast-delivery {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: #1d4ed8;
}

.filter-fast-delivery svg {
    color: #1d4ed8;
}

/* آیکن فلش */
.filter-arrow {
    color: #9ca3af;
    transition: transform 0.25s ease;
}

/* وقتی فیلتر باز است، فلش بچرخد */
.filter-item[open] .filter-arrow {
    transform: rotate(180deg);
}

/* محتوای بازشونده */
.filter-content {
    padding: 0 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

/* چک‌باکس‌های فیلتر */
.filter-check-label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    color: #6b7280;
    font-size: 0.82rem;
    user-select: none;
}

.filter-check-label input {
    display: none;
}

.custom-checkbox {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    background-color: #ffffff;
    position: relative;
    transition: all 0.2s ease;
}

.filter-check-label input:checked + .custom-checkbox {
    background-color: #2563eb;
    border-color: #2563eb;
}

.filter-check-label input:checked + .custom-checkbox::after {
    content: "";
    position: absolute;
    width: 4px;
    height: 8px;
    top: 1px;
    right: 5px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* محدوده قیمت */
.price-filter-content {
    padding-top: 0.15rem;
}

.price-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.price-inputs input {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    padding: 0.55rem 0.65rem;
    box-sizing: border-box;
    outline: none;
    color: #374151;
    font-size: 0.8rem;
}

.price-inputs input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* بخش فقط کالاهای موجود */
.availability-filter {
    padding: 1.15rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.availability-text {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    line-height: 1.7;
}

.availability-text strong {
    font-size: 0.85rem;
    font-weight: 700;
    color: #374151;
}

.availability-text span {
    font-size: 0.7rem;
    color: #9ca3af;
}

/* دکمه روشن/خاموش */
.switch {
    display: inline-block;
    position: relative;
    width: 34px;
    height: 20px;
    flex: 0 0 34px;
    cursor: pointer;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background-color: #d1d5db;
    transition: background-color 0.25s ease;
}

.switch-slider::before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    right: 3px;
    bottom: 3px;
    border-radius: 50%;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.25s ease;
}

.switch input:checked + .switch-slider {
    background-color: #2563eb;
}

.switch input:checked + .switch-slider::before {
    transform: translateX(-14px);
}

/* ==========================================================================
   تولبار بالای صفحه
   ========================================================================== */

.products-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 1.5rem;
}

.products-toolbar-title .section-subtitle {
    display: block;
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.products-toolbar-title h2 {
    font-size: 1.5rem;
    color: #111827;
    margin: 0;
    font-weight: 700;
}

.products-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* جعبه جستجو */
.products-search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0 0.75rem;
    min-width: 280px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.products-search-box:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.products-search-box input {
    width: 100%;
    border: none;
    outline: none;
    padding: 0.625rem 0.5rem;
    font-size: 0.9rem;
    background: transparent;
}

.products-search-box .search-btn {
    border: none;
    background: none;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0.25rem;
}

.products-search-box .search-btn:hover {
    color: #111827;
}

/* مرتب‌سازی */
.products-sort-box select {
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0.625rem 2rem 0.625rem 1rem;
    font-size: 0.9rem;
    color: #374151;
    outline: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.75rem center;
    background-size: 1rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    min-width: 160px;
}

.products-sort-box select:focus {
    border-color: #3b82f6;
}

/* ==========================================================================
   گرید و کارت محصولات
   ========================================================================== */

.products-page-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.product-card {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 6px 6px rgba(0, 0, 0, 0.05);
}

.product-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

/* باکس رنگی بالای کارت */
.product-swatch-box {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 11;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 0.75rem;
    box-sizing: border-box;
    overflow: hidden;
}

.swatch-code {
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    color: #1f2937;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 2;
    direction: ltr;
}

.swatch-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 1;
}

.swatch-overlay .view-text {
    background-color: rgba(255, 255, 255, 0.95);
    color: #111827;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: bold;
    transform: translateY(10px);
    transition: transform 0.25s ease;
}

.product-card:hover .swatch-overlay {
    opacity: 1;
}

.product-card:hover .swatch-overlay .view-text {
    transform: translateY(0);
}

/* بدنه کارت محصول */
.product-card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-category {
    font-size: 0.75rem;
    color: #3b82f6;
    font-weight: 600;
    text-transform: uppercase;
}

.product-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.5rem;
    line-height: 1.4;
}

.product-short-desc {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0 0 1.25rem;
    line-height: 1.6;
    flex-grow: 1;
}

.product-card-footer {
    border-top: 1px solid #f3f4f6;
    padding-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.more-info-link {
    font-size: 0.8rem;
    color: #4b5563;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.2s, transform 0.2s;
}

.more-info-link a {
    color: inherit;
    text-decoration: none;
}

.product-card:hover .more-info-link {
    color: #3b82f6;
}

.product-card:hover .more-info-link svg {
    transform: translateX(-4px);
}

.more-info-link svg {
    transition: transform 0.2s;
}

/* ==========================================================================
   صفحه‌بندی
   ========================================================================== */

.pagination-container {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.pagination-list {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 0.5rem;
}

.pagination-number,
.pagination-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    color: #4b5563;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.pagination-number:hover,
.pagination-arrow:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.05);
}

.pagination-number.active {
    background-color: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

/* ==========================================================================
   زمانی که محصولی یافت نشود
   ========================================================================== */

.no-products-found {
    text-align: center;
    padding: 5rem 1rem;
    background: #ffffff;
    border: 1px dashed #d1d5db;
    border-radius: 12px;
    max-width: 600px;
    margin: 2rem auto;
}

.no-products-found svg {
    color: #9ca3af;
    margin-bottom: 1.5rem;
}

.no-products-found h3 {
    font-size: 1.5rem;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.no-products-found p {
    color: #6b7280;
    margin-bottom: 2rem;
}

.reset-search-btn {
    display: inline-block;
    background-color: #3b82f6;
    color: #ffffff;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s;
}

.reset-search-btn:hover {
    background-color: #2563eb;
}

/* ==========================================================================
   واکنش‌گرایی / Responsive
   ========================================================================== */

/* دسکتاپ بزرگ */
@media (min-width: 1025px) {
    .products-page-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* تبلت افقی */
@media (max-width: 1024px) and (min-width: 769px) {
    .products-sidebar {
        flex-basis: 220px;
        width: 220px;
    }

    .products-page-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .products-search-box {
        min-width: 230px;
    }
}

/* تبلت و موبایل */
@media (max-width: 768px) {
    .products-layout {
        flex-direction: column;
    }

    .products-sidebar {
        width: 100%;
        flex: unset;
    }

    .filters-box {
        position: static;
    }

    .products-main {
        width: 100%;
    }

    .products-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .products-toolbar-actions {
        width: 100%;
    }

    .products-search-box {
        flex: 1;
        min-width: 0;
    }

    .products-page-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* موبایل کوچک */
@media (max-width: 480px) {
    .products-page {
        padding: 2rem 0;
    }

    .products-page .container {
        padding: 0 1rem;
    }

    .products-toolbar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .products-search-box,
    .products-sort-box select {
        width: 100%;
        box-sizing: border-box;
    }

    .products-page-grid {
        grid-template-columns: 1fr;
    }

    .filters-header {
        padding: 1rem;
    }

    .filter-summary {
        padding: 0 1rem;
    }

    .filter-content {
        padding-right: 1rem;
        padding-left: 1rem;
    }

    .availability-filter {
        padding: 1rem;
    }
}
