﻿/* ========= Desktop Layout ========= */
/* Outer container: two columns (categories | products) */
.body-productlist {
    font-family: sans-serif;
    line-height: 1.5;
    background-color: #f5f5f5;
    color: #333;
    display: grid;
    grid-template-columns: 1fr 4fr;
    gap: 10px;
    padding: 10px;
}

/* Categories section (left column) */

.productlist-categories {
    font-family: 'Roboto', sans-serif;
    width: 240px;
    background-color: #fff;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 6px;
}

    .productlist-categories .item {
        margin: 10px 0;
        font-size: 16px;
        display: flex;
        align-items: center;
        color: #333;
        padding: 10px;
        border-radius: 4px;
        transition: background 0.3s ease, transform 0.3s ease, color 0.3s ease;
    }

        .productlist-categories .item i {
            margin-right: 10px;
            color: #555;
            transition: transform 0.3s ease, color 0.3s ease;
        }

        .productlist-categories .item:hover {
            background: #ddd;
            cursor: pointer;
            transform: translateX(5px);
            color: #000;
        }

            .productlist-categories .item:hover i {
                transform: rotate(15deg);
                color: #000;
            }

/* Products container now uses flex to stack the heading and cards container */
#productsContainer.productList {
    display: flex;
    flex-direction: column;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Heading styling remains as before */
.productlistHeading {
    margin-bottom: 20px;
}

    .productlistHeading h2 {
        font-size: 24px;
        color: #333;
        font-weight: 600;
        border-bottom: 2px solid #eee;
        padding-bottom: 10px;
    }

/* Cards container: grid to arrange product cards */
.cards-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    min-height: 400px;
}

/* Product card styles */
.product-card {
    background-color: #fff;
    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;
    display: flex;
    flex-direction: column;
    height: 100%;
}

    .product-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    }

.product-image {
    height: 280px;
    overflow: hidden;
    position: relative;
    background-color: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .product-image img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        transition: transform 0.5s ease;
    }

    .product-image .no-image {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100%;
        width: 100%;
        color: #999;
        font-style: italic;
        font-size: 0.9rem;
    }

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-details {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 10px;
    color: #333;
    height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.price {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.original-price {
    text-decoration: line-through;
    color: #999;
    font-size: 0.9rem;
    margin-left: 5px;
}

.discount {
    color: #e53e3e;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 5px;
    white-space: nowrap;
}

.product-colors {
    font-size: 0.8rem;
    color: #666;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

/* Loading spinner and messages */
.products-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 50px 0;
    grid-column: 1 / -1;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-radius: 50%;
    border-top: 4px solid #333;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.products-loading p {
    color: #666;
    font-size: 14px;
}

/* Error and No Products Messages */
.error-message {
    background-color: #fee2e2;
    color: #b91c1c;
    padding: 15px;
    border-radius: 5px;
    margin: 20px auto;
    max-width: 80%;
    text-align: center;
    grid-column: 1 / -1;
}

.no-products {
    color: #6b7280;
    text-align: center;
    padding: 40px 0;
    font-style: italic;
    grid-column: 1 / -1;
}

/* Pagination styles */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

#pagination-controls {
    display: flex;
    gap: 5px;
}

.pagination-button {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-width: 32px;
    font-size: 14px;
}

    .pagination-button:hover {
        background: #e5e7eb;
        text-decoration: none;
        color: #000;
    }

    .pagination-button.active {
        background: #1f2937;
        color: white;
        border-color: #1f2937;
    }

    .pagination-button.disabled {
        opacity: 0.5;
        cursor: not-allowed;
        pointer-events: none;
    }

.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    color: #6b7280;
}

#items-per-page {
    display: flex;
    align-items: center;
    gap: 10px;
}

    #items-per-page label {
        font-size: 14px;
        color: #4b5563;
    }

    #items-per-page select {
        padding: 5px 10px;
        border: 1px solid #d1d5db;
        border-radius: 4px;
        background-color: white;
        font-size: 14px;
    }

/* ========= Tablet Layout (768px to 1023px) ========= */
@media (min-width: 768px) and (max-width: 1023px) {
    .body-productlist {
        grid-template-columns: 1fr 3fr;
        gap: 15px;
        padding: 15px;
    }

    /* Adjust the cards grid to 3 columns on tablets */
    .cards-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }

    .product-image {
        height: 240px;
    }
}

/* ========= Mobile Layout (below 768px) ========= */
@media (max-width: 767px) {
    #productsContainer.productList {
        padding: 10px;
    }

    .body-productlist {
        display: block;
        padding: 10px;
    }

    /* Example: change categories background color on mobile */
    .productlist-categories {
        display: none;
    }

    /* On mobile, the cards grid can be adjusted; here we use 2 columns */
    .cards-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .pagination-container {
        flex-direction: column;
        gap: 15px;
    }

    #pagination-controls {
        order: 2;
    }

    #items-per-page {
        order: 1;
    }

    .product-image {
        height: 200px;
    }
    
    .product-title {
        height: auto;
        max-height: 40px;
    }
}
