/* ========================================
   Products Page - Filter & Layout
   ======================================== */

.products-page {
    padding: 1.5rem 0 3rem;
    min-height: calc(100vh - 200px);
    background: #f8fafc;
}

/* Page Header */
.products-page-header {
    margin-bottom: 1.5rem;
    position: relative;
}

.products-page-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.5rem;
}

.products-page-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.products-page-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.products-page-icon-placeholder {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1) 0%, rgba(var(--primary-rgb), 0.05) 100%);
    border-radius: 6px;
    color: var(--primary);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.products-page-title-text {
    flex: 1;
}

.products-page-subtitle {
    font-size: 0.75rem;
    color: #64748b;
    margin: 0;
    padding-left: 0;
    line-height: 1.4;
    max-width: 500px;
}

/* ========================================
   Filter Section
   ======================================== */
.mobile-filter-trigger-btn,
.mobile-filter-header,
.filter-mobile-overlay {
    display: none;
}

.products-filter-section {
    background: #ffffff;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

/* Use CSS Grid for consistent sizing */
.products-filter-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr 1fr auto;
    gap: 0.75rem;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Select Wrapper */
.filter-select-wrapper {
    position: relative;
    width: 100%;
}

.filter-select {
    width: 100%;
    height: 38px;
    padding: 0 2rem 0 0.75rem;
    font-size: 0.8125rem;
    color: #1e293b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    appearance: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-select:hover {
    border-color: #cbd5e1;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.filter-select-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.65rem;
    color: #94a3b8;
    pointer-events: none;
}

/* Input */
.filter-input {
    width: 100%;
    height: 38px;
    padding: 0 0.75rem;
    font-size: 0.8125rem;
    color: #1e293b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.filter-input:hover {
    border-color: #cbd5e1;
}

.filter-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.filter-input::placeholder {
    color: #94a3b8;
}

/* Price Inputs */
.filter-price-inputs {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.filter-price-inputs .filter-input {
    flex: 1;
    min-width: 0;
}

.filter-price-separator {
    color: #94a3b8;
    font-weight: 500;
    flex-shrink: 0;
}

/* Filter Buttons Group */
.filter-group-buttons {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.filter-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Filter Button */
.btn-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    height: 38px;
    padding: 0 1.25rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #ffffff;
    background: var(--primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-filter:hover {
    background: var(--primary-dark, var(--primary));
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.25);
}

.btn-filter i {
    font-size: 0.7rem;
}

/* Reset Filter Button */
.btn-reset-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    font-size: 0.75rem;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-reset-filter:hover {
    color: #ef4444;
    background: #fef2f2;
    border-color: #fecaca;
}

/* ========================================
   Results Info
   ======================================== */
.products-results-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
}

.results-count {
    font-size: 0.875rem;
    color: #64748b;
}

.results-count #resultsCount {
    font-weight: 600;
    color: #1e293b;
}

/* ========================================
   Products Grid Override
   ======================================== */
.products-page .products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 1200px) {
    .products-filter-wrapper {
        grid-template-columns: 1fr 1fr 1.5fr 1fr auto;
    }
    
    .products-page .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .products-filter-wrapper {
        grid-template-columns: 1fr 1fr 1fr auto;
        gap: 0.75rem;
    }
    
    /* Move price to second row */
    .products-filter-wrapper .filter-group-price {
        grid-column: 1 / 3;
    }
    
    .products-filter-wrapper .filter-group:nth-child(4) {
        grid-column: 3 / 4;
    }
    
    .products-page .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .products-page {
        padding: 1rem 0 2rem;
    }
    
    .products-page-title {
        font-size: 1.5rem;
        gap: 0.625rem;
    }
    
    .products-page-icon {
        width: 28px;
        height: 28px;
    }
    
    .products-page-icon-placeholder {
        width: 28px;
        height: 28px;
        font-size: 0.875rem;
    }
    
    .products-page-subtitle {
        font-size: 0.7rem;
        padding-left: 0;
    }

    /* Hiển thị nút mở bộ lọc với thiết kế bo tròn, shadow nhẹ và hiệu ứng hover mượt mà */
    .mobile-filter-trigger-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.625rem;
        width: 100%;
        height: 46px;
        padding: 0 1rem;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        font-size: 0.9rem;
        font-weight: 600;
        color: #1e293b;
        margin-bottom: 1.25rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
        cursor: pointer;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-filter-trigger-btn:active {
        transform: scale(0.97);
        background: #f8fafc;
        border-color: #cbd5e1;
    }

    .mobile-filter-trigger-btn i {
        font-size: 0.95rem;
        color: var(--primary);
    }

    /* Lớp phủ làm mờ và tối hình nền phía sau khi bộ lọc được mở */
    .filter-mobile-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(4px);
        z-index: 1050;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .filter-mobile-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Khung bộ lọc biến thành Bottom Sheet trượt từ dưới lên */
    .products-filter-section {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1060;
        background: #ffffff;
        border-radius: 24px 24px 0 0;
        padding: 1.5rem;
        margin-bottom: 0;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.12);
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        max-height: 80vh;
        border: none;
        border-top: 1px solid rgba(226, 232, 240, 0.8);
    }

    .products-filter-section.active {
        transform: translateY(0);
    }

    /* Thanh cầm dẹt ở trên cùng Bottom Sheet tạo cảm giác giống ứng dụng di động */
    .products-filter-section::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: #e2e8f0;
        border-radius: 2px;
        margin: -0.75rem auto 1rem;
    }

    /* Tiêu đề của drawer bộ lọc */
    .mobile-filter-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-bottom: 0.875rem;
        border-bottom: 1px solid #f1f5f9;
        margin-bottom: 1.25rem;
    }

    .mobile-filter-header h5 {
        font-size: 1rem;
        font-weight: 700;
        color: #0f172a;
        margin: 0;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .mobile-filter-header h5 i {
        color: var(--primary);
    }

    /* Nút đóng drawer */
    .btn-close-filter {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: #f1f5f9;
        border: none;
        color: #64748b;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .btn-close-filter:active {
        background: #e2e8f0;
        color: #0f172a;
        transform: scale(0.9);
    }

    /* Cuộn danh sách các bộ lọc theo chiều dọc bên trong drawer */
    .products-filter-wrapper {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
        overflow-y: auto;
        padding-right: 2px;
        max-height: calc(80vh - 120px);
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

    .filter-label {
        font-size: 0.725rem;
        font-weight: 700;
        color: #475569;
        margin-bottom: 0.5rem;
    }

    .filter-select, 
    .filter-input {
        height: 44px; /* Tăng chiều cao để người dùng mobile dễ bấm */
        border-radius: 10px;
        font-size: 0.875rem;
        border-color: #e2e8f0;
        background: #f8fafc;
    }

    .filter-price-inputs {
        gap: 0.625rem;
    }

    .filter-price-separator {
        font-size: 0.875rem;
        color: #94a3b8;
    }

    /* Nhóm nút xác nhận lọc và reset */
    .products-filter-wrapper .filter-group-buttons {
        margin-top: 0.75rem;
        padding-top: 1.25rem;
        border-top: 1px solid #f1f5f9;
        position: sticky;
        bottom: 0;
        background: #ffffff;
        z-index: 10;
    }

    .filter-buttons {
        display: flex;
        gap: 0.75rem;
        width: 100%;
    }

    .btn-filter {
        flex: 3;
        height: 44px;
        border-radius: 10px;
        font-size: 0.9rem;
        font-weight: 600;
        box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.15);
    }

    .btn-reset-filter {
        flex: 1;
        height: 44px;
        border-radius: 10px;
        background: #f1f5f9;
        border-color: transparent;
    }

    .products-page .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .products-page-title {
        font-size: 1.25rem;
        gap: 0.5rem;
    }
    
    .products-page-icon {
        width: 24px;
        height: 24px;
    }
    
    .products-page-icon-placeholder {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }
    
    .products-page-subtitle {
        font-size: 0.7rem;
        padding-left: 0;
    }
}

/* ========================================
   Dark Mode
   ======================================== */

/* === Page Background === */
[data-theme="dark"] .products-page {
    background: #111827;
}

/* === Page Header === */
[data-theme="dark"] .products-page-title {
    color: #f3f4f6;
}

[data-theme="dark"] .products-page-subtitle {
    color: #9ca3af;
}

[data-theme="dark"] .products-page-icon-placeholder {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.15) 0%, rgba(var(--primary-rgb), 0.08) 100%);
}

/* === Filter Section === */
[data-theme="dark"] .products-filter-section {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* === Filter Labels === */
[data-theme="dark"] .filter-label {
    color: #9ca3af;
}

/* === Filter Select === */
[data-theme="dark"] .filter-select {
    background: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

[data-theme="dark"] .filter-select:hover {
    border-color: #6b7280;
}

[data-theme="dark"] .filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

[data-theme="dark"] .filter-select option {
    background: #374151;
    color: #f3f4f6;
}

[data-theme="dark"] .filter-select-icon {
    color: #6b7280;
}

/* === Filter Input === */
[data-theme="dark"] .filter-input {
    background: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

[data-theme="dark"] .filter-input:hover {
    border-color: #6b7280;
}

[data-theme="dark"] .filter-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

[data-theme="dark"] .filter-input::placeholder {
    color: #6b7280;
}

/* === Price Separator === */
[data-theme="dark"] .filter-price-separator {
    color: #6b7280;
}

/* === Filter Buttons === */
[data-theme="dark"] .btn-filter {
    background: var(--dm-btn-primary-bg);
    border-color: var(--dm-btn-primary-border);
    color: var(--dm-btn-primary-text);
}

[data-theme="dark"] .btn-filter:hover {
    background: var(--dm-btn-primary-hover-bg);
    border-color: var(--dm-btn-primary-hover-border);
    color: var(--dm-btn-primary-hover-text);
    box-shadow: var(--dm-shadow-md);
}

/* === Reset Filter Button === */
[data-theme="dark"] .btn-reset-filter {
    background: var(--dm-btn-primary-bg);
    border-color: var(--dm-btn-primary-border);
    color: var(--dm-text-muted);
}

[data-theme="dark"] .btn-reset-filter:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* === Results Info === */
[data-theme="dark"] .results-count {
    color: #9ca3af;
}

[data-theme="dark"] .results-count #resultsCount {
    color: #f3f4f6;
}

/* === Products Results Info === */
[data-theme="dark"] .products-results-info {
    border-color: #374151;
}

/* === Mobile Filter Dark Mode === */
@media (max-width: 768px) {
    [data-theme="dark"] .mobile-filter-trigger-btn {
        background: #1f2937;
        border-color: #374151;
        color: #f3f4f6;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    [data-theme="dark"] .mobile-filter-trigger-btn:active {
        background: #111827;
    }

    [data-theme="dark"] .products-filter-section {
        background: #1f2937;
        border-top: 1px solid #374151;
    }

    [data-theme="dark"] .products-filter-section::before {
        background: #374151;
    }

    [data-theme="dark"] .mobile-filter-header {
        border-bottom: 1px solid #374151;
    }

    [data-theme="dark"] .mobile-filter-header h5 {
        color: #f3f4f6;
    }

    [data-theme="dark"] .btn-close-filter {
        background: #374151;
        color: #9ca3af;
    }

    [data-theme="dark"] .btn-close-filter:active {
        background: #4b5563;
        color: #f3f4f6;
    }

    [data-theme="dark"] .filter-label {
        color: #9ca3af;
    }

    [data-theme="dark"] .filter-select, 
    [data-theme="dark"] .filter-input {
        background: #111827;
        border-color: #374151;
        color: #f3f4f6;
    }

    [data-theme="dark"] .products-filter-wrapper .filter-group-buttons {
        border-top: 1px solid #374151;
        background: #1f2937;
    }

    [data-theme="dark"] .btn-reset-filter {
        background: #374151;
        color: #9ca3af;
    }
}

