/* General Styling for the page */
main h2 {
    text-align: center;
    margin: 0;
    padding: 0;
    width: 98%;
    font-weight: 300;
}

.category-meta-description {
    text-align: center;
    margin-bottom: 20px;
    font-style: italic;
    color: var(--color-text);
}

.controls-container {
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #ddd;
    margin-bottom: 20px;
}

#controls-form {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap; /* Allows wrapping on smaller screens before the media query kicks in */
}

.sorting-controls, .view-controls, .per-page-controls {
    display: flex;
    align-items: center;
}

.sorting-controls label, .view-controls label, .per-page-controls label {
    margin-right: 10px;
    font-weight: bold;
    color: #333;
}

.select-wrapper {
    position: relative;
    display: inline-block;
}

.select-wrapper::after {
    content: '\25BC'; /* Unicode for down arrow */
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    pointer-events: none;
    color: #555;
    font-size: 12px;
}

#sort-select, #per-page-select, #view-select {
    padding: 10px 30px 10px 15px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #fff;
    cursor: pointer;
    appearance: none; /* Remove default arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#sort-select:hover, #per-page-select:hover, #view-select:hover {
    border-color: #888;
}

#sort-select:focus, #per-page-select:focus, #view-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

/* Product List Styling */
.product-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--spacing-large);
    padding: var(--spacing-medium); /* Add some padding to the list container */
}

.product-card {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-light);
    transition: box-shadow 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* min-height: 300px; Removed fixed height */
    width: 250px; /* Fixed width for homogeneous size */
    border: 2px solid transparent;
    justify-content: space-between; /* Distribute content vertically */
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 15px var(--color-primary);
    border-color: var(--color-primary);
}

.product-image-link {
    display: block;
    flex-shrink: 0; /* Prevent it from shrinking */
    flex-grow: 0; /* Prevent it from growing */
    text-decoration: none;
    color: var(--color-text);
}

.product-image-container {
    width: 100%;
    height: 200px; /* Hauteur fixe pour le conteneur d'image */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative; /* Pour la mise à l'échelle de l'image */
    padding: var(--spacing-small); /* Add padding around the image */
}

.product-image-container img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image-container img {
    transform: scale(1.05);
}

.product-name {
    font-size: 1.1em;
    font-weight: bold;
    margin: var(--spacing-small) 0; /* Add some vertical margin */
    text-align: center;
}

.product-price {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--color-primary);
    margin-bottom: var(--spacing-small); /* Add some bottom margin */
    text-align: center;
}

.add-to-cart-button {
    background-image: linear-gradient(to right, var(--color-primary) 50%, #FAD4B4 50%);
    background-size: 200% 100%;
    background-position: 0% 0%; /* Start from left */
    color: white;
    border: none;
    border-radius: 5px;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 1em;
    transition: background-position 1.5s ease, color 0.3s ease; /* Add color transition */
    width: 90%; /* Make button almost full width */
    margin: 0 auto var(--spacing-small) auto; /* Center button and add bottom margin */
    text-decoration: none; /* Remove underline */
    text-align: center; /* Center text */
    display: block; /* Make it a block element to apply width and margin auto */
}

.add-to-cart-button:hover {
    background-position: 100% 0%; /* End at right */
    color: black;
}

.pagination {
    margin-top: 40px;
    display: flex;
    flex-direction: column; /* Stack items vertically */
    align-items: center;   /* Center items horizontally */
    gap: 15px; /* Add space between the two rows */
}

.pagination .step-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px; /* Space between buttons */
}

.btn-pagination, .current-page-btn {
    display: inline-block;
    padding: 10px 20px;
    border: 1px solid var(--color-border);
    border-radius: 5px;
    text-decoration: none;
    font-size: 1em;
    transition: background-color 0.3s, color 0.3s, box-shadow 0.3s;
}

.btn-pagination {
    background-color: var(--color-surface);
    color: var(--color-primary);
    border-color: var(--color-primary);
    font-size: 0.9em; /* Matching font size */
}

.btn-pagination:hover {
    background-color: var(--color-primary);
    color: var(--color-surface);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.current-page-btn {
    background-color: var(--color-primary);
    color: var(--color-surface);
    border-color: var(--color-primary);
    font-weight: bold;
    font-size: 0.9em; /* Smaller font size */
}

.page-number-links {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.page-number-links a, .page-number-links span {
    color: var(--color-text);
    padding: 2px 5px;
    text-decoration: none;
}

.page-inactive {
    font-weight: bold;
}

.page-inactive:hover {
    text-decoration: underline;
    color: var(--color-primary);
}

.page-active {
    font-style: italic;
    color: var(--color-primary);
}


/* Responsive adjustments */
@media (max-width: 1000px) {
    #controls-form {
        justify-content: center;
    }
}

@media (max-width: 600px) {
    #controls-form {
        flex-direction: column;
        align-items: stretch;
    }

    .sorting-controls, .per-page-controls {
        width: 100%;
        justify-content: space-between;
    }

    #sort-select, #per-page-select {
        width: 100%;
        margin-top: 10px;
    }

    .view-controls {
        display: none;
    }

    .product-list {
        /* Force single column layout */
        gap: var(--spacing-medium);
        padding: 0;
    }

    .product-card {
        width: 100%; /* Full width for single column */
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 400px) {
    .btn-pagination, .current-page-btn {
        font-size: 0.7em;
        padding: 8px 12px; /* Adjust padding for smaller font */
    }
}


.category-header {
    text-align: center;
    margin-bottom: 30px;
}

.category-title {
    font-size: 2.5em;
    color: #333;
    margin-bottom: 10px;
}

.category-description {
    font-size: 1.2em;
    color: #666;
    max-width: 800px;
    margin: 0 auto;
}

.subcategories {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--spacing-medium);
    margin-bottom: 40px;
    padding: var(--spacing-medium); /* Add padding similar to product-list */
}

.subcategory-card {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-light);
    transition: box-shadow 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
    overflow: hidden;
    text-align: center;
    width: 250px; /* Fixed width for homogeneous size */
    height: 250px; /* Fixed height for homogeneous size */
    border: 2px solid transparent; /* Similar to product-card */
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Distribute content vertically */
}

.subcategory-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 15px var(--color-primary);
    border-color: var(--color-primary);
}

.subcategory-card a {
    text-decoration: none;
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.subcategory-image-container {
    width: 100%;
    height: 150px; /* Fixed height for the image container */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: var(--spacing-small); /* Add padding around the image */
}

.subcategory-image-container img {
    max-width: 95%; /* Similar to product images */
    max-height: 95%; /* Similar to product images */
    object-fit: contain;
    transition: transform 0.3s ease;
}

.subcategory-card:hover .subcategory-image-container img {
    transform: scale(1.05); /* Similar hover effect */
}

.subcategory-card h3 {
    padding: var(--spacing-medium); /* Consistent padding */
    margin: 0;
    font-size: 1.1em;
    font-weight: bold;
    background-color: var(--color-surface); /* Use theme surface color */
    flex-grow: 1; /* Allow title to take space */
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-price a {
    color: #eb5834;
    text-decoration: none;
    transition: color 0.3s ease;
}

.product-price a:hover {
    color: #630606;
}