/* --- Proper Grid & Card Layout Fixes --- */

.card-grid {
    display: grid;
    /* Reduced minwidth to fit significantly more cards per row across all screens */
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    justify-content: center;
    gap: 12px;
    padding: 15px 10px; /* Minimized padding to maximize usable grid space */
}

/* Individual wrapper that contains both the image card and the details below it */
.product-item-wrapper {
    display: flex;
    flex-direction: column;
    background-color: #F7F4F0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-item-wrapper:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

/* Constrains the card image area so it doesn't scale infinitely */
.card {
    background-color: #FFFFFF;
    width: 100%;
    aspect-ratio: 1 / 1; /* Makes product images square and uniform */
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-details {
    display: flex;
    flex-direction: column;
    padding: 8px 10px; /* Compact padding so cards don't feel bulky */
    gap: 6px;
    background-color: #FFFFFF;
    flex-grow: 1;
    justify-content: space-between;
}

.product-title {
    font-size: 12px;
    font-weight: 600;
    color: #0d2240;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    gap: 4px;
}

.product-price {
    font-size: 13px;
    font-weight: bold;
    color: #ff7b00;
    margin: 0;
}

/* Stable Add-to-Cart button scaled down to match compact cards */
.add-to-cart-btn {
    background-color: #0d2240;
    color: #FFFFFF;
    border: none;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.add-to-cart-btn:hover {
    background-color: #ff7b00;
}

/* --- Fully Responsive Shop Layout & Stationary Filter Sidebar --- */
.shop-main-layout {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 15px;
    box-sizing: border-box;
}

.filter-sidebar {
    position: static; /* Completely stationary, scrolls naturally with the page */
    width: 220px;
    flex-shrink: 0;
    background-color: #F7F4F0;
    border-radius: 10px;
    padding: 14px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

.filter-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(13, 34, 64, 0.1);
    padding-bottom: 6px;
}

.filter-header-row h3 {
    margin: 0;
    font-size: 14px;
    color: #0d2240;
}

.reset-filters-btn {
    font-size: 11px;
    color: #ff7b00;
    text-decoration: none;
    font-weight: 600;
}
.reset-filters-btn:hover {
    text-decoration: underline;
}

.filter-group {
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: #0d2240;
}

.filter-group label {
    font-weight: 600;
}

.filter-select {
    width: 100%;
    padding: 7px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-family: 'Poppins', sans-serif;
    background-color: #FFFFFF;
    color: #0d2240;
    font-size: 12px;
    cursor: pointer;
    box-sizing: border-box;
}

.dropdown-filter {
    position: relative;
}

.filter-dropdown-toggle {
    width: 100%;
    padding: 7px;
    background-color: #FFFFFF;
    border: 1px solid #ccc;
    border-radius: 6px;
    text-align: left;
    font-family: 'Poppins', sans-serif;
    color: #0d2240;
    font-size: 12px;
    cursor: pointer;
    box-sizing: border-box;
}

.filter-dropdown-content {
    display: none;
    flex-direction: column;
    gap: 5px;
    background-color: #FFFFFF;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
    margin-top: 4px;
    font-size: 12px;
    max-height: 150px;
    overflow-y: auto;
}

.filter-group input[type="range"] {
    width: 100%;
    accent-color: #ff7b00;
    cursor: pointer;
}

.price-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #666;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #0d2240;
    max-height: 120px;
    overflow-y: auto;
    background: #fff;
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.checkbox-list::-webkit-scrollbar,
.filter-dropdown-content::-webkit-scrollbar {
    width: 5px;
}
.checkbox-list::-webkit-scrollbar-thumb,
.filter-dropdown-content::-webkit-scrollbar-thumb {
    background-color: rgba(13, 34, 64, 0.2);
    border-radius: 4px;
}

.checkbox-list label,
.filter-dropdown-content label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: normal;
}

.no-filter-text {
    font-size: 11px;
    color: #888;
    font-style: italic;
}

.product-grid-container {
    flex-grow: 1;
    min-width: 0;
}

/* --- Mobile Filter Toggle Bar (Hidden on Desktop) --- */
.mobile-filter-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background-color: #F7F4F0;
    padding: 10px 15px;
    margin: 0 10px 10px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.mobile-filter-toggle-btn {
    background: none;
    border: none;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #0d2240;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 0;
}

.mobile-filter-toggle-btn svg {
    transition: transform 0.3s ease;
}

.mobile-filter-toggle-btn.active svg {
    transform: rotate(180deg);
}

.mobile-reset-btn {
    font-size: 11px;
    color: #ff7b00;
    font-weight: 600;
    text-decoration: none;
}

/* --- Mobile Responsiveness Adjustments --- */
@media (max-width: 900px) {
    .mobile-filter-bar {
        display: flex; /* Show bar only on mobile/tablet */
    }

    .shop-main-layout {
        flex-direction: column;
        padding: 0 10px 15px 10px;
        gap: 10px;
    }

    .filter-sidebar {
        display: none; /* Hidden by default on mobile */
        width: 100%;
        box-sizing: border-box;
    }

    /* Expands to full length when toggled open */
    .filter-sidebar.mobile-open {
        display: flex;
        flex-direction: column;
        animation: fadeInDown 0.25s ease forwards;
    }

    /* Forces at least 2 columns on mobile screens instead of a single giant card */
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 5px;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}