/* ============================================================
   فلتر المنتجات - CSS كامل
   ============================================================ */

/* ============================================================
   1. الأساسيات
   ============================================================ */
.filter-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
}

/* ============================================================
   2. حاوية الفلتر
   ============================================================ */
.filter-container {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
    overflow: hidden;
    position: sticky;
    top: 20px;
    max-height: calc(60vh - 40px);
    display: flex;
    flex-direction: column;
}

.filter-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.filter-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d1d1d;
}

.filter-header h3 i {
    color: #5e37a6;
    margin-right: 8px;
}

.filter-header .btn-reset {
    background: none;
    border: none;
    color: #5e37a6;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 12px;
    border-radius: 20px;
    transition: all 0.2s ease;
}

.filter-header .btn-reset:hover {
    background: rgba(94, 55, 166, 0.1);
}

.filter-body {
    padding: 8px 0;
    overflow-y: auto;
    flex: 1;
}

.filter-body::-webkit-scrollbar {
    width: 4px;
}

.filter-body::-webkit-scrollbar-track {
    background: #f1f3f5;
}

.filter-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

/* ============================================================
   3. أقسام الفلتر
   ============================================================ */
.filter-section {
    border-bottom: 1px solid #f1f3f5;
}

.filter-section:last-child {
    border-bottom: none;
}

.filter-section-header {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s ease;
    user-select: none;
}

.filter-section-header:hover {
    background: #f8f9fa;
}

.filter-section-header .title {
    font-size: 14px;
    font-weight: 500;
    color: #1d1d1d;
}

.filter-section-header .title i {
    width: 20px;
    color: #5e37a6;
    margin-right: 8px;
}

.filter-section-header .count {
    font-size: 12px;
    color: #999;
    background: #f1f3f5;
    padding: 2px 10px;
    border-radius: 12px;
    margin-left: auto;
    margin-right: 8px;
    transition: all 0.3s ease;
}

.filter-section-header .count.active {
    background: #5e37a6;
    color: white;
}

.filter-section-header .arrow {
    color: #999;
    transition: transform 0.3s ease;
    font-size: 12px;
}

.filter-section-header.active .arrow {
    transform: rotate(180deg);
}

.filter-section-body {
    padding: 0 20px 12px;
    display: none;
}

.filter-section-body.open {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   4. البحث داخل الفلتر
   ============================================================ */
.filter-search {
    margin-bottom: 8px;
}

.filter-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #e9ecef;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.3s ease;
}

.filter-search input:focus {
    border-color: #5e37a6;
}

/* ============================================================
   5. قائمة الخيارات
   ============================================================ */
.filter-list {
    max-height: 180px;
    overflow-y: auto;
}

.filter-list::-webkit-scrollbar {
    width: 4px;
}

.filter-list::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 4px;
}

.filter-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.filter-item {
    display: flex;
    align-items: center;
    padding: 6px 4px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.filter-item:hover {
    background: #f8f9fa;
}

.filter-item input[type="checkbox"] {
    display: none;
}

.filter-item .checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
    transition: all 0.2s ease;
    background: white;
}

.filter-item .checkmark i {
    font-size: 10px;
    color: white;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.filter-item.checked .checkmark {
    background: #5e37a6;
    border-color: #5e37a6;
}

.filter-item.checked .checkmark i {
    opacity: 1;
}

.filter-item .label {
    font-size: 13px;
    color: #1d1d1d;
    flex: 1;
}

.filter-item .label img {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 6px;
}

.filter-item .count {
    font-size: 12px;
    color: #999;
    background: #f1f3f5;
    padding: 0 8px;
    border-radius: 10px;
}

.filter-item.checked .count {
    background: rgba(94, 55, 166, 0.15);
    color: #5e37a6;
}

/* ============================================================
   6. فلتر الألوان
   ============================================================ */
.filter-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

.color-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    color: #555;
}

.color-option:hover {
    border-color: #d1d5db;
}

.color-option.checked {
    border-color: #5e37a6;
    background: rgba(94, 55, 166, 0.05);
}

.color-option .dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #e9ecef;
    flex-shrink: 0;
}

.color-option .name {
    font-size: 12px;
    color: #555;
}

.color-option .count {
    font-size: 11px;
    color: #999;
}

.color-option.checked .name {
    color: #5e37a6;
    font-weight: 500;
}

/* ============================================================
   7. فلتر السعر
   ============================================================ */
.filter-price {
    padding: 4px 0;
}

.price-slider {
    position: relative;
    height: 30px;
    margin: 8px 0 16px;
}

.price-slider input[type="range"] {
    position: absolute;
    width: 100%;
    height: 4px;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    pointer-events: none;
    top: 50%;
    transform: translateY(-50%);
}

.price-slider input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: #e9ecef;
    border-radius: 4px;
}

.price-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #5e37a6;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    margin-top: -6px;
}

.price-slider input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #5e37a6;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.price-slider input[type="range"]:first-child {
    z-index: 2;
}

.price-slider input[type="range"]:last-child {
    z-index: 1;
}

.price-inputs {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.price-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.price-input-group label {
    font-size: 12px;
    color: #999;
    font-weight: 500;
}

.price-input-group input {
    width: 70px;
    padding: 6px 8px;
    border: 1.5px solid #e9ecef;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
    outline: none;
    transition: border-color 0.3s ease;
}

.price-input-group input:focus {
    border-color: #5e37a6;
}

.price-separator {
    color: #999;
    font-size: 14px;
}

/* ============================================================
   8. أزرار التطبيق
   ============================================================ */
.filter-actions {
    display: flex;
    gap: 10px;
    padding: 12px 20px 8px;
    border-top: 1px solid #f1f3f5;
    flex-shrink: 0;
}

.btn-apply {
    flex: 1;
    padding: 10px;
    background: linear-gradient(135deg, #5e37a6, #4a2a8a);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-apply:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(94, 55, 166, 0.3);
}

.btn-clear {
    flex: 0.5;
    padding: 10px;
    background: #f1f3f5;
    color: #555;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-clear:hover {
    background: #e9ecef;
}

/* ============================================================
   9. عدد النتائج
   ============================================================ */
.filter-results {
    padding: 12px 20px 16px;
    text-align: center;
    font-size: 14px;
    color: #999;
    border-top: 1px solid #f1f3f5;
    flex-shrink: 0;
}

.filter-results span {
    font-weight: 700;
    color: #5e37a6;
    font-size: 18px;
}

/* ============================================================
   10. عرض المنتجات
   ============================================================ */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.product-card .image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #f8f9fa;
}

.product-card .body {
    padding: 12px 14px;
}

.product-card .name {
    font-size: 14px;
    font-weight: 600;
    color: #1d1d1d;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card .brand {
    font-size: 12px;
    color: #999;
}

.product-card .price {
    font-size: 18px;
    font-weight: 700;
    color: #5e37a6;
    margin-top: 6px;
}

.product-card .status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin-top: 6px;
}

.product-card .status.in-stock {
    background: #d1fae5;
    color: #065f46;
}

.product-card .status.out-of-stock {
    background: #fee2e2;
    color: #991b1b;
}

.product-card .colors {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    align-items: center;
}

.product-card .colors .dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid #e9ecef;
    display: inline-block;
}

.product-card .colors .label {
    font-size: 11px;
    color: #999;
    margin-left: 4px;
}

/* ============================================================
   11. الشاشات الصغيرة
   ============================================================ */
@media (max-width: 1024px) {
    .filter-page {
        grid-template-columns: 1fr;
    }

    .filter-container {
        position: static;
        max-height: none;
    }

    .filter-body {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    .filter-page {
        padding: 10px;
    }

    .filter-container {
        border-radius: 12px;
    }

    .filter-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .filter-header h3 {
        font-size: 14px;
    }

    .filter-section-header {
        padding: 10px 16px;
    }

    .filter-section-body {
        padding: 0 16px 10px;
    }

    .filter-actions {
        flex-direction: column;
    }

    .btn-clear {
        flex: 1;
    }

    .price-input-group input {
        width: 60px;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .product-card .image {
        height: 140px;
    }
}

@media (max-width: 400px) {
    .products-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .product-card .body {
        padding: 8px 10px;
    }

    .product-card .name {
        font-size: 12px;
    }

    .product-card .price {
        font-size: 14px;
    }
}

/* ============================================================
   12. Animations
   ============================================================ */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}
