.product-page-container {
    max-width: 1800px; /* Set a generous but realistic max-width for wider content */
    margin: 0 auto;
    padding: 2rem; /* Top padding is now handled by the body.page-products class */
}

.product-page-header {
    text-align: center;
    margin-bottom: 1.5rem; /* Reduced space below the main header */
}

.product-page-header h1 {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.product-page-header p {
    font-size: 1.1rem;
    color: #666;
}

.product-page-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.category-sidebar {
    flex: 0 0 240px; /* Made sidebar slightly narrower to give more space to products */
    background: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    position: sticky;
    top: 165px; /* Align with the container's top padding */
}

.category-sidebar h2 {
    font-size: 1.4rem;
    color: #c2185b;
    margin-top: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 0.75rem;
}

#category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#category-list li a {
    display: block;
    padding: 0.75rem 1rem;
    color: #555;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#category-list li a:hover {
    background-color: #fdf2f4;
    color: #c2185b;
}

#category-list li a.active {
    background-color: #c2185b;
    color: #fff;
    font-weight: 600;
}

.product-grid-container {
    flex: 1; /* Add spacing above the grid, as requested */
    min-width: 0; /* Prevents grid from overflowing its container */
    /* Override conflicting grid styles from style.css to ensure proper layout */
    display: block;
    padding: 0;
}



.product-grid-container h2 {
    font-size: 1.8rem;
    font-size: 1.6rem; /* Reduced font size for a more subtle heading */
    margin-top: 1rem; /* Add top margin to push the title and grid down */
    margin-bottom: 1.5rem;
    position: relative; /* Needed for z-index */
    z-index: 2;         /* Ensure title is above the product grid */
}

/* Overriding homepage grid for a fuller look */
.product-grid-container .product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns for mobile */
    gap: 1rem; /* Tighter gap for mobile to make cards feel wider */
    position: relative; /* Establish stacking context */
    z-index: 1;         /* Place grid below the title */
}

@media (min-width: 1200px) {
    .product-grid-container .product-grid {
        grid-template-columns: repeat(4, 1fr); /* 4 columns for desktop */
        gap: 1.5rem; /* Restore larger gap for desktop */
    }
}

/* --- Product Page Card --- */
/* This is a new, self-contained class to prevent clashes with global .product-card styles */
.product-page-card {
    /* Base styles for a clean card */
    background: white;
    border: 1px solid #ddd;
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    display: flex;

    /* Specific layout for this page */
    flex-direction: column; /* Ensures a vertical layout */
    height: auto;           /* Allows the card to grow with its content */
    /* Width is now controlled by the grid, so we set it to 100% of its column */
    width: 100%;
}

.product-page-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.product-page-card .product-image-container {
    position: relative; /* For wishlist/quick-view buttons */
}

.product-page-card .product-image {
    width: 100%;
    height: 180px; /* Consistent image height */
    object-fit: cover;
}

/* New wrapper for all content to the right/below the image */
.product-details-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allows it to take up space in a flex container */
    padding: 1rem;
    justify-content: space-between; /* Pushes actions to the bottom */
}

/* This is the new wrapper for the text content */
.product-main-info {
    flex-grow: 1; /* On mobile, this pushes the actions to the bottom */
}

.product-page-card .product-content {
    /* The wrapper now handles padding */
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
}

/* Fix for vertical stars: ensures stars and review count are in a row */
.product-page-card .product-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@media (min-width: 1200px) {
    .product-page-card {
        flex-direction: row; /* Horizontal layout on desktop */
        height: 240px; /* A fixed height for better alignment */
    }
    .product-page-card .product-image-container {
        flex: 0 0 40%; /* Fixed width for the image container */
        height: 100%;
    }
    .product-page-card .product-details-wrapper {
        flex: 1 1 60%; /* Allow content to take up remaining space */
        /* This wrapper is now a column to hold the top content and the bottom rating */
    }
    .product-page-card .card-top-content {
        display: flex;
        flex-grow: 1; /* Take up available vertical space */
        align-items: center; /* Vertically center the content and buttons */
        justify-content: space-between; /* Push info to left, buttons to right */
        gap: 1rem; /* Space between info and buttons */
    }
    .product-page-card .product-rating {
        justify-content: center; /* Center the stars horizontally */
        padding-bottom: 0.5rem; /* Give it some breathing room at the bottom */
    }
    .product-page-card .product-main-info {
        flex-grow: 1; /* Allow the main info to take up available space */
        min-width: 0; /* Prevents long text from breaking the layout */
    }
    .product-page-card .product-actions {
        flex-direction: column; /* Stack buttons vertically */
        flex-shrink: 0; /* Prevent button container from shrinking */
        flex-basis: 100px; /* Reduced width to make buttons more square-like */
        gap: 0.75rem; /* Space between the vertical buttons */
    }
}
/* Responsive adjustments */
@media (max-width: 992px) {
    .product-page-container {
        /* Adjust top padding for mobile's smaller fixed header and reduce side padding */
        padding: 50px 1rem 1.5rem; /* Space for the fixed 50px navbar on tablets */
    }
    .product-page-header {
        display: none; /* Hide the main header on mobile to bring categories to the top */
    }
    .product-page-layout {
        display: block;
    }

    .category-sidebar {
        /* On mobile, it becomes a dropdown container */
        position: static; /* Ensure it stays in the normal document flow on mobile, preventing overlap */
        width: 100%;
        margin-bottom: 1.5rem; /* Space between dropdown and product grid */
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    }

    .category-sidebar h2 {
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin: 0; /* Remove desktop margins */
        padding: 1rem 1.5rem;
        /* The h2 is now just a header inside the styled container */
        border-bottom: 1px solid #f0f0f0; /* Add a separator line */
    }

    .category-sidebar h2::after {
        content: '\f078'; /* Font Awesome chevron-down */
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        transition: transform 0.3s ease;
    }

    /* When open, remove the bottom border from the h2 to merge with the list */
    .category-sidebar.open h2 {
        border-bottom-color: transparent; /* Hide the line when open for a seamless look */
    }

    .category-sidebar.open h2::after {
        transform: rotate(180deg); /* Point up when open */
    }

    #category-list {
        display: none; /* Hidden by default on mobile */
        /* Removed absolute positioning to make it an accordion that pushes content down */
        /* The list now lives inside the main styled container, so it needs less styling */
        padding: 0 0.5rem 0.5rem; /* Add some padding around the list items */
        margin: 0; /* Ensure no margin is pushing the list down */
        max-height: 45vh; /* Limit the height of the dropdown to 45% of the viewport height */
        overflow-y: auto; /* Make it scrollable if content overflows */
    }

    .category-sidebar.open #category-list {
        display: block; /* Show when the .open class is present */
    }
}

/* Custom scrollbar for the mobile category dropdown for a cleaner look */
@media (max-width: 992px) {
    #category-list::-webkit-scrollbar {
        width: 6px;
    }
    #category-list::-webkit-scrollbar-track {
        background: #f8f9fa;
        border-radius: 10px;
    }
    #category-list::-webkit-scrollbar-thumb {
        background: #e0e0e0;
        border-radius: 10px;
    }
}

/* --- Quick View Button on Product Card --- */
.product-image-container {
    position: relative;
    overflow: hidden; /* To contain the button */
}

.quick-view-btn {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 10px;
    cursor: pointer;
    transform: translateY(100%);
    transition: transform 0.3s ease, opacity 0.3s ease;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
}

.product-image-container:hover .quick-view-btn {
    transform: translateY(0);
    opacity: 1;
}

/* --- Quick View Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(25, 25, 30, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content.quick-view-modal {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    padding: 0;
}

.modal-overlay.visible .modal-content.quick-view-modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

#quick-view-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2.5rem;
    max-height: 90vh;
    overflow-y: auto;
}

.quick-view-image-container img {
    width: 100%;
    height: auto;
    max-height: 450px;
    object-fit: contain;
    border-radius: 8px;
}

.quick-view-details h2 { margin-top: 0; font-size: 2rem; color: #333; }
.quick-view-details .price { font-size: 1.8rem; font-weight: bold; color: #c2185b; margin: 0.5rem 0 1rem; }
.quick-view-details .description { font-size: 0.95rem; line-height: 1.6; color: #555; margin-bottom: 1.5rem; }
.quick-view-details .view-full-details-btn { display: inline-block; margin-top: 1.5rem; color: #c2185b; text-decoration: none; font-weight: 600; }
