/* ==================== 
   Shop Filters & Pagination
   Responsive Design for AR/EN
   Enhanced RTL Support
   ====================== */

/* Base Filter Styles */
.product-filter {
    background: #fff;
    padding: 1.75rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 80px;
    z-index: 1;
    border: 1px solid #f0f0f0;
}

.filter-title {
    color: #333;
    font-size: 1.25rem;
    border-bottom: 2px solid #1055a3;
    padding-bottom: 0.75rem;
    margin-bottom: 1.5rem !important;
    display: flex;
    align-items: center;
}

.filter-title i {
    color: #1055a3;
}

.filter-section {
    margin-bottom: 1.5rem;
}

.filter-section .section-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    padding-bottom: 0.5rem;
}

.filter-section .section-title::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 30px;
    height: 2px;
    background: #1055a3;
}

/* RTL section title underline */
[dir="rtl"] .filter-section .section-title::after {
    left: auto;
    right: 0;
}

/* Category List with Show All Links */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.category-item {
    margin-bottom: 0;
}

.category-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 5px !important;
    color: #555;
    text-decoration: none;
    font-size: 0.95rem;
    border-radius: 0.5rem;
    transition: all 0.25s ease;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
}

.category-link i {
    font-size: 0.85rem;
    opacity: 0.7;
    transition: all 0.25s ease;
}

.category-link:hover {
    color: #1055a3;
    background: #1055a305;
    border-color: #1055a310;
}

.category-link:hover i {
    opacity: 1;
}

.category-link.active {
    color: #fff;
    font-weight: 600;
    background: #1055a3;
    border-color: #1055a3;
}

.category-link.active i {
    opacity: 1;
    color: #fff;
}

/* Sort List Styles (like categories) */
.sort-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sort-item {
    margin-bottom: 0;
}

.sort-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 0.6rem 0.85rem;
    color: #555;
    text-decoration: none;
    font-size: 0.95rem;
    border-radius: 0.5rem;
    transition: all 0.25s ease;
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
}

.sort-link i {
    font-size: 0.85rem;
    opacity: 0.7;
    transition: all 0.25s ease;
}

.sort-link:hover {
    color: #1055a3;
    background: #1055a305;
    border-color: #1055a310;
}

.sort-link:hover i {
    opacity: 1;
}

.sort-link.active {
    color: #fff;
    font-weight: 600;
    background: #1055a3;
    border-color: #1055a3;
}

.sort-link.active i {
    opacity: 1;
    color: #fff;
}

.filter-section .form-check {
    margin-bottom: 0.75rem;
}

.filter-section .form-check-input {
    width: 18px;
    height: 18px;
    margin-top: 0.3rem;
    cursor: pointer;
    border: 2px solid #ddd;
    transition: all 0.3s ease;
}

.filter-section .form-check-input:checked {
    background-color: #1055a3;
    border-color: #1055a3;
}

.filter-section .form-check-input:hover {
    border-color: #1055a3;
}

.filter-section .form-check-label {
    cursor: pointer;
    margin-left: 0.5rem;
    font-size: 0.95rem;
    color: #555;
    transition: color 0.3s ease;
}

/* RTL Support for checkbox labels */
[dir="rtl"] .filter-section .form-check-label {
    margin-left: 0;
    margin-right: 0.5rem;
}

.filter-section .form-check-input:checked + .form-check-label {
    color: #1055a3;
    font-weight: 500;
}

/* Category sidebar accordion: one border per row (top/right/bottom), white background */
.category-accordion.accordion-flush .accordion-item {
    border: 1px solid #e6e6e6 !important;
    margin-bottom: -1px !important;
    background: #fff;
    padding: 0.5rem !important;
}

.category-accordion.accordion-flush .accordion-item:first-child {
    border-top-left-radius: 0.35rem;
    border-top-right-radius: 0.35rem;
}

.category-accordion.accordion-flush .accordion-item:last-child {
    border-bottom-left-radius: 0.35rem;
    border-bottom-right-radius: 0.35rem;
}

.category-accordion .accordion-button {
    padding: 0.75rem 1rem;
    background: #fff !important;
    border: none;
    color: #333;
    font-weight: 500;
    font-size: 0.95rem;
}

.category-accordion .accordion-button:not(.collapsed) {
    background: #fff !important;
    color: #1055a3;
}

.category-accordion .accordion-collapse,
.category-accordion .accordion-body {
    margin-top: 0.5rem !important;
}

.accordion-item {
    border: 1px solid #e9ecef !important;
    margin-bottom: 0.5rem;
}

.accordion-button {
    padding: 0.75rem 0;
    background: transparent;
    border: none;
    color: #333;
    font-weight: 500;
    font-size: 0.95rem;
}

.accordion-button:not(.collapsed) {
    background: transparent;
    color: #1055a3;
}

.accordion-button:focus {
    border-color: transparent;
    box-shadow: none;
}

/* Pagination Styles - Modern Design */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.35rem;
    margin-top: 2.5rem;
    flex-wrap: wrap;
}

[dir="rtl"] .pagination {
    flex-direction: row-reverse;
}

.pagination .page-item {
    margin: 0;
}

.pagination .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 42px;
    height: 42px;
    border: 2px solid #e0e0e0;
    border-radius: 0.5rem !important;
    color: #555;
    background: #fff;
    font-size: 0.95rem;
    transition: all 0.25s ease;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.pagination .page-link:hover {
    border-color: #1055a3;
    color: #1055a3;
    background: #1055a305;
    transform: translateY(-2px);
}

.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, #1055a3 0%, #002753 100%);
    border-color: #1055a3;
    color: #fff;
    box-shadow: 0 4px 12px #1055a350;
    transform: translateY(-2px);
}

.pagination .page-item.disabled .page-link {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    background: #f8f9fa;
}

/* Arrow buttons */
.pagination .page-link i {
    font-size: 0.85rem;
}

/* Sorting Styles */
.sorting-header {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sorting-header:hover {
    background: #e9ecef;
}

.sorting-title {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.active-sorting {
    color: #1055a3;
    font-weight: 600;
}

.sorting-lists {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    display: none;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.sorting-header.active ~ .sorting-lists {
    display: block;
}

.sorting-lists li {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
}

.sorting-lists li:last-child {
    border-bottom: none;
}

.sorting-lists li a {
    color: #555;
    text-decoration: none;
    display: block;
    transition: color 0.3s ease;
}

.sorting-lists li a:hover {
    color: #1055a3;
    font-weight: 500;
}

/* Mobile Filter Drawer */
.filter-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
}

.filter-drawer.active {
    display: block;
}

.filter-drawer-content {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    width: 80%;
    height: 100vh;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1001;
}

.filter-drawer.active .filter-drawer-content {
    transform: translateX(0);
}

/* RTL Support - Filter Drawer */
[dir="rtl"] .filter-drawer-content {
    left: auto;
    right: 0;
    transform: translateX(100%);
    width: 80%;
}

[dir="rtl"] .filter-drawer.active .filter-drawer-content {
    transform: translateX(0);
}

[dir="rtl"] .sorting-lists {
    left: 0;
    right: auto;
}

/* Product Counter & Filter Header */
.collection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.collection-counter {
    font-size: 1rem;
    color: #666;
    font-weight: 500;
}

.filter-sorting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* Mobile Responsive Styles */
@media (max-width: 991px) {
    .product-filter {
        position: relative;
        top: auto;
        margin-bottom: 2rem;
    }

    .filter-drawer-trigger {
        cursor: pointer;
        padding: 0.75rem 1rem;
        background: #f8f9fa;
        border-radius: 0.5rem;
        gap: 0.5rem;
        transition: all 0.3s ease;
    }

    .filter-drawer-trigger:hover {
        background: #e9ecef;
    }

    .mobile-filter-heading {
        font-weight: 600;
        color: #333;
    }

    .collection-sorting.d-none.d-lg-block {
        display: none !important;
    }

    .sorting-header {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .product-filter {
        padding: 1.25rem;
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.08);
    }

    .filter-section h6 {
        font-size: 0.95rem;
        margin-bottom: 0.75rem;
    }

    .filter-section .form-check-label {
        font-size: 0.9rem;
    }

    .pagination {
        gap: 0.25rem;
        margin-top: 1.5rem;
    }

    .pagination .page-link {
        padding: 0.5rem;
        min-width: 36px;
        font-size: 0.9rem;
    }

    .collection-header {
        margin-bottom: 1rem;
    }

    .filter-sorting {
        margin-bottom: 1rem;
        flex-direction: column;
        align-items: stretch;
    }

    .collection-counter {
        font-size: 0.95rem;
    }

    .sorting-header {
        padding: 0.75rem;
    }

    .collection-product-container {
        gap: 1rem;
    }

    /* Adjust filter drawer for smaller screens */
    .filter-drawer-content {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .product-filter {
        padding: 1rem;
    }

    .filter-section {
        margin-bottom: 1.25rem;
    }

    .filter-section h6 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .filter-section .form-check {
        margin-bottom: 0.5rem;
    }

    .pagination {
        gap: 0.15rem;
    }

    .pagination .page-link {
        padding: 0.4rem;
        min-width: 32px;
        font-size: 0.8rem;
    }

    .accordion-button {
        padding: 0.5rem 0;
        font-size: 0.9rem;
    }

    .collection-counter {
        font-size: 0.9rem;
    }

    .filter-drawer-trigger {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .mobile-filter-heading {
        font-size: 0.95rem;
    }
}

/* Loading State */
.products-loading {
    opacity: 0.5;
    pointer-events: none;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1055a3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state-icon {
    font-size: 3rem;
    color: #ddd;
    margin-bottom: 1rem;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
}

.empty-state-text {
    color: #999;
    font-size: 0.95rem;
}

/* ==================== 
   Enhanced RTL Support
   ====================== */

/* RTL: Filter container text alignment */
[dir="rtl"] .product-filter {
    text-align: right;
}

/* RTL: Filter title icon */
[dir="rtl"] .filter-title i {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* RTL: Category and sort link icons */
[dir="rtl"] .category-link,
[dir="rtl"] .sort-link {
    text-align: right;
}

/* RTL: Accordion button arrow */
[dir="rtl"] .accordion-button::after {
    margin-left: 0;
    margin-right: auto;
}

/* RTL: Form check alignment */
[dir="rtl"] .form-check {
    padding-left: 0;
    padding-right: 1.75rem;
}

[dir="rtl"] .form-check-input {
    float: right;
    margin-left: 0;
    margin-right: -1.75rem;
}

/* ==================== 
   Active State Highlight
   ====================== */

/* Pulsing animation for active items */
@keyframes activeGlow {
    0%,
    100% {
        box-shadow: 0 4px 12px #1055a350;
    }
    50% {
        box-shadow: 0 4px 20px #1055a380;
    }
}

.category-link.active,
.sort-link.active,
.pagination .page-item.active .page-link {
    animation: activeGlow 2s ease-in-out infinite;
}

/* Hover effect improvements */
.category-link:not(.active):hover,
.sort-link:not(.active):hover {
    transform: translateX(5px);
}

[dir="rtl"] .category-link:not(.active):hover,
[dir="rtl"] .sort-link:not(.active):hover {
    transform: translateX(-5px);
}
