/*
    MerchStudio version 0.01 - Core CSS File
    Copyright (c) 2025 Michael Lewis White and MerchStudio Inc.
    Client-side CSS for Product Lists and Cards
    @version tpl/core/client/css/product.css - 0.01 - 10-10-2025 - khushi

    # included by client/css_load.tpl
*/

/* --- Product List Wrapper --- */
.product_list_wrap {
    margin: 30px 0;
    padding: 20px;
    border: 1px solid var(--base);
    border-radius: 6px;
}

.product_list_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 15px;
}

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

.product_sort_controls label {
    font-weight: bold;
}

.product_sort_controls .select_wrapper {
    min-width: 180px;
}

.product_view_controls {
    display: flex;
    gap: 5px;
}

.product_view_controls .view_toggle {
    background-color: var(--base);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    line-height: 0;
}

.product_view_controls .view_toggle:hover {
    background-color: var(--hover);
}

.product_view_controls .view_toggle.active {
    background-color: var(--highlight);
    color: var(--bg);
    border-color: var(--highlight);
}

/* --- Product List Container (Grid and List Views) --- */
.product_list {
    display: grid;
    gap: 20px;
    transition: all 0.3s ease-in-out;
}

/* Grid Layout (Default) */
.product_list.grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 280px));
    justify-content: center;
}

/* List Layout */
.product_list.list {
    grid-template-columns: 1fr; /* Single column */
}

/* --- Individual Product Card --- */
.product_card {
    border: 1px solid transparent; /* For transition */
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--base);
    transition: all 0.3s ease-in-out;
}

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

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

/* List View Specific Styles for Card */
.product_list.list .product_card a.product_link { /* <-- Targeted the flex container */
    flex-direction: row;
}

.product_image {
    width: 100%;
    aspect-ratio: 1 / 1; /* Square images */
    background-color: var(--bg);
    position: relative;
}

.product_image img,
.product_image .image_placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* List View Specific Styles for Image */
.product_list.list .product_image {
    width: 150px;
    height: 150px;
    flex-shrink: 0; /* Prevent image from shrinking */
}

.product_details {
    padding: 15px;
    text-align: center;
    flex-grow: 1; /* Allows footer to align */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* List View Specific Styles for Details */
.product_list.list .product_details {
    text-align: left;
    justify-content: center;
}

.product_title {
    font-size: 1.1em;
    font-family: 'Manrope', sans-serif;
    font-weight: bold;
    margin: 0 0 10px 0;
    padding: 0;
}

.product_price {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--highlight);
    margin: 0;
}

/* PIX related Styles */
.pix_type_badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
}

/* --- Product Card Slideshow --- */
.card_slideshow {
    position: relative;
    z-index: 0; /* own stack, so the option badge stays on top */
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    background: var(--base);
}

.card_slideshow .slideshow_img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    z-index: 1;
    /* Keeps the image on top for 0.4s while it fades out, then drops it back */
    transition: opacity 0.8s ease-in-out, z-index 0s linear 0.8s; 
}

.card_slideshow .slideshow_img.active {
    opacity: 1;
    z-index: 2;
    /* Instantly brings the new image to the front, then fades it in */
    transition: opacity 0.8s ease-in-out, z-index 0s linear 0s; 
}

.slideshow_controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 3;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.product_card:hover .slideshow_controls {
    opacity: 1;
}

.slideshow_controls button {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--line);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
}

.slideshow_controls button:hover {
    background: var(--highlight);
    color: var(--contrast);
}