/* ========================
   PRODUCTS SECTION STYLES
   ======================== */
.products {
    padding: 40px 0;
    background-color: #f8f9fa;
}

.products .container h2 {
    text-align: center;
    font-size: 2.2rem;
    margin-bottom: 3rem;
    color: #2c3e50;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.product-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.product-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: #ffffff;
}

.product-card h3 {
    padding: 1rem;
    font-size: 1.2rem;
    color: #2c3e50;
}

.product-card .price {
    padding: 0 1rem;
    font-size: 1.5rem;
    color: #27ae60;
    font-weight: bold;
}

.product-card .description {
    padding: 0 1rem 1rem;
    color: #666;
    font-size: 0.95rem;
}

.add-to-cart {
    width: 90%;
    margin: 0 5%;
    padding: 10px;
    background-color: #3498db;
    color: rgb(255, 255, 255);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    margin-bottom: 1rem;
    transition: background-color 0.3s ease;
}

.add-to-cart:hover {
    background-color: #2980b9;
}

/* Out of Stock */
.product-card.out-of-stock {
    opacity: 0.6;
}

.product-card.out-of-stock .add-to-cart {
    background-color: #999;
    cursor: not-allowed;
}

/* Sort Bar */
.sort-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    align-items: center;
}

.sort-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-label {
    font-size: 13px;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sort-btn, .filter-btn, .category-btn {
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid #ccc;
    background: white;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
}

.sort-btn:hover, .filter-btn:hover, .category-btn:hover {
    border-color: #260d47;
    color: #260d47;
}

.sort-btn.active, .filter-btn.active, .category-btn.active {
    background: #260d47;
    color: white;
    border-color: #260d47;
}

/* Responsive */
@media (max-width: 768px) {
    .sort-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .sort-group {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    .btn-group {
        width: 100%;
    }

    .sort-btn, .filter-btn, .category-btn {
        font-size: 13px;
        padding: 7px 13px;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

    .products .container h2 {
        font-size: 1.8rem;
    }
}

@media (max-width: 480px) {
    .sort-btn, .filter-btn, .category-btn {
        font-size: 12px;
        padding: 6px 11px;
    }

    .product-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================
   SIDEBAR FILTER LAYOUT
   ======================== */
.products-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.filter-sidebar {
    width: 220px;
    min-width: 220px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 60px;        /* stays visible while scrolling, clears the navbar */
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.products-main {
    flex: 1;
    min-width: 0;     /* prevents grid from overflowing */
}

/* Adjust sort bar to stack vertically in sidebar */
.filter-sidebar .sort-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 0;
}

.filter-sidebar .sort-group {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
}

.filter-sidebar .btn-group {
    flex-direction: column;
    width: 100%;
}

.filter-sidebar .sort-btn,
.filter-sidebar .filter-btn,
.filter-sidebar .category-btn {
    width: 100%;
    text-align: left;
    border-radius: 8px;    /* square-ish instead of pill shape in sidebar */
}

.filter-sidebar .sort-label {
    font-size: 14px;
    font-weight: 700;
    color: #260d47;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

/* Responsive — sidebar goes back to top on mobile */
@media (max-width: 768px) {
    .products-layout {
        flex-direction: column;
    }

    .filter-sidebar {
        width: 100%;
        min-width: unset;
        position: static;   /* not sticky on mobile */
        max-height: unset;
    }

    .filter-sidebar .btn-group {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .filter-sidebar .sort-btn,
    .filter-sidebar .filter-btn,
    .filter-sidebar .category-btn {
        width: auto;
        border-radius: 999px;  /* pill shape back on mobile */
    }
}