/* ==========================================================================
   ۱. بدنه اصلی صفحه (Page Container) - تراز کننده اصلی کل لایوت
   ========================================================================== */

.page-container {
    width: 100%;
    max-width: 1280px; /* حداکثر عرض مجاز برای کل محتوا */
    margin: 0 auto; /* وسط‌چین کردن کل صفحه روی PC */
    padding: 20px 24px 0 24px; /* پدینگ ثابت چپ و راست برای تمام رزولوشن‌ها */
    box-sizing: border-box;
}

/* ==========================================================================
   ۲. بخش هدر دسته‌بندی و مسیر راهنما (Category Header & Breadcrumb)
   ========================================================================== */

/* مسیر راهنما (Breadcrumb) کاملاً تراز با لبه راست */
.breadcrumb {
    margin: 0 0 15px 0; /* حذف مارجین auto و اعمال مارجین پایین */
    font-size: 0.8rem;
    opacity: 0.8;
    box-sizing: border-box;
    padding: 0;
}

/* ظرف کلی هدر - کاملاً تراز با لبه چپ و راست گرید */
.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 15px 25px;
    margin: 0 0 20px 0; /* حذف margin: auto برای تراز ماندن با لبه‌ها */
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--medium-purple);
    width: 100%; /* استفاده از تمام عرض کانتینر والد */
    box-sizing: border-box;
}

.header-right h1 {
    font-size: 1.1rem;
    color: var(--text-purple);
    font-weight: 800;
    margin: 0;
}

/* استایل اختصاصی مرتب‌سازی */
.sort-wrapper {
    display: flex;
    align-items: center;
    background: var(--light-purple);
    padding: 5px 15px;
    border-radius: 10px;
    transition: 0.3s;
}

    .sort-wrapper:hover {
        background: var(--medium-purple);
    }

.sort-icon {
    color: var(--dark-purple);
    margin-left: 8px;
    font-size: 0.9rem;
}

.sort-label {
    font-size: 0.85rem;
    color: var(--text-purple);
    margin-left: 10px;
    font-weight: 600;
}

.custom-sort {
    border: none;
    background: transparent;
    color: var(--text-purple);
    font-family: inherit;
    font-weight: 700;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    padding: 5px 0;
}

/* ==========================================================================
   ۳. گرید محصولات (Product Grid)
   ========================================================================== */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 15px;
    padding: 0; /* پدینگ به page-container منتقل شد تا تراز کامل برقرار شود */
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

    /* فرزندان مستقیم grid برای جلوگیری از خرابی المان‌ها */
    .product-grid > .grid-item {
        min-width: 0;
    }

/* رسپانسیو و کنترل ستون‌ها در تبلت */
@media (min-width: 769px) and (max-width: 1023px) {
    .product-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* رسپانسیو و قفل روی ۴ ستون در دسکتاپ بزرگ */
@media (min-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ==========================================================================
   ۴. بخش صفحه‌بندی (Pagination)
   ========================================================================== */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 30px 0;
    flex-wrap: wrap;
    direction: rtl;
}

    .pagination span {
        width: 38px;
        height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--main-purple);
        border-radius: 10px;
        cursor: pointer;
        transition: all 0.2s;
        font-weight: bold;
        background: white;
        user-select: none;
    }

        .pagination span.dots {
            border: none;
            cursor: default;
        }

            .pagination span.dots:hover {
                background: transparent;
                transform: none;
            }

        .pagination span:hover {
            background: var(--light-purple);
            transform: translateY(-3px);
        }

        .pagination span.active {
            background: var(--main-purple);
            color: white;
        }

/* استایل کلی پجینیشن و فلش‌ها */
#pagination-controls span {
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
}

.pagination-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
}

    .pagination-arrow.disabled {
        opacity: 0.4;
        cursor: not-allowed;
        pointer-events: none;
    }

/* ==========================================================================
   ۵. مدیا کوئری‌های تبلت و موبایل (Responsive Styles)
   ========================================================================== */

@media (max-width: 768px) {
    .page-container {
        padding: 15px 10px 0 10px; /* کاهش پدینگ اطراف صفحه در موبایل */
    }

    .category-header {
        margin: 0 0 15px 0;
        width: 100%;
        padding: 15px;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .header-right h1 {
        font-size: 1rem;
        text-align: center;
    }

    .sort-wrapper {
        width: 100%;
        justify-content: space-between;
        box-sizing: border-box;
    }

    .sort-label {
        font-size: 0.75rem;
        margin-left: 5px;
    }

    .custom-sort {
        font-size: 0.8rem;
    }

    /* گرید ۲ ستونه در موبایل */
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
        padding: 0;
    }

    .product-card {
        padding: 8px;
    }

    .breadcrumb {
        margin: 0 5px 10px 5px;
        font-size: 0.75rem;
    }

    .pagination span {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }

    .top-bar {
        left: 0;
        right: 0;
        width: 100%;
        padding: 10px 15px;
        box-sizing: border-box;
    }

  
}
