/* product-list.css */
/* Styles adapted from dishes.css for product_list.html, using prefixed class names */

/* Common styles for both desktop and mobile */
.styled-product-card { /* Renamed from .product-card */
    background: var(--white, #fff);
    border-radius: 8px;
    padding: 16px;
    height: 100%; /* Makes card take full height of its parent */
    display: flex;
    flex-direction: column;
    border: 1px solid transparent;
    box-sizing: border-box;
}

/* Ensure the intermediate .col div (parent of styled-product-card) also takes full height */
/* This targets a .col that is a direct child of a Bootstrap column (e.g., col-sm-6, col-md-4) */
/* based on the structure in product_list.html: <div class="{{@products_class}}"><div class="col"><div class="styled-product-card">...</div></div></div> */
[class*="col-"] > .col {
    height: 100%;
    display: flex; /* Ensures the child .styled-product-card (which is height:100%) can properly fill it */
    flex-direction: column; /* Aligns with the card's flex direction if needed, though card itself handles its children */
}


/* Product content area within the card */
.styled-product-content { /* Renamed from .product-content */
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allows this section to grow and fill available vertical space */
    padding-top: 12px; /* Retained, adjust as needed */
}

/* Image styles */
.styled-product-media { /* Renamed from .product-media */
    position: relative;
}

.styled-product-image img { /* Renamed from .product-image img */
    width: 100%;
    border-radius: 6px;
    display: block;
    object-fit: cover;
    border: 1px solid transparent;
}

/* Title styles */
.styled-product-name { /* Renamed from .product-name */
    font-size: 16px;
    line-height: 1.3;
    font-weight: 600;
    margin: 8px 0 8px;
    color: var(--sub-heading, #333);
}

/* Description text */
.styled-product-info { /* Renamed from .product-info */
    font-size: 14px;
    line-height: 1.5;
    color: #666;
    margin: 0 0 8px;
    flex-grow: 1; /* Allows description to take available space, pushing price/button down */
}

/* Price styles */
.styled-product-price { /* Renamed from .product-price */
    min-height: 26px;
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    margin-bottom: 12px;
    color: var(--primary, #007bff);
}

.styled-product-price del {
    color: var(--red, #dc3545);
    margin-right: 8px;
    font-size: 13px;
}

.styled-product-price span {
    white-space: nowrap;
    font-weight: 500;
}

.styled-product-price span small {
    font-weight: 400;
}

/* Button styles for the main "Add to Cart" button */
/* Targeting the new class .styled-product-add-btn */
.buy_form .cart-form a.styled-product-add-btn {
    width: 100%;
    padding: 8px 16px;
    font-size: 14px;
    height: 40px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: var(--white, #fff);
    color: #333;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    margin-top: auto; /* Pushes button to the bottom of .styled-product-content if it's the last child */
}

.buy_form .cart-form a.styled-product-add-btn:hover {
    border-color: var(--primary, #007bff);
    color: var(--primary, #007bff);
}

.buy_form .cart-form a.styled-product-add-btn i {
    font-size: 14px;
    margin-right: 8px;
}

/* Hide the +/- quantity selector by default */
.buy_form .cart-form .styled-product-action { /* Renamed from .product-action */
    display: none;
    margin-top: auto; /* Pushes action to the bottom if it's shown */
}

/* Show quantity selector when product is added/selected (example) */
.styled-product-card.item-in-cart .cart-form a.styled-product-add-btn {
    display: none;
}
.styled-product-card.item-in-cart .cart-form .styled-product-action {
    display: flex;
    /* You might need to style .styled-product-action and its children further */
}

/* Selected state for the product card */
.styled-product-card.selected .styled-product-image img {
    border: 1px solid var(--primary, #007bff);
}

.styled-product-card.selected .buy_form .cart-form a.styled-product-add-btn {
    background: var(--primary, #007bff);
    color: var(--white, #fff);
    border-color: var(--primary, #007bff);
}

/* Desktop grid refinements */
@media (min-width: 768px) {
    /* No specific changes here, but you can add if needed */
}

/* Mobile-only styles */
@media (max-width: 767px) {
    .styled-product-card {
        flex-direction: row; /* Image left, content right */
        padding: 8px;
        margin-bottom: 8px; /* Space between cards on mobile */
        gap: 12px; /* Space between image and content */
        /* height: auto; /* On mobile, let height be determined by content if not using 100% for row alignment */
                       /* Keeping height: 100% from common styles will attempt to make cards in a mobile row (if any) equal height */
    }

    /* The [class*="col-"] > .col rule for height: 100% will also apply here,
       which is generally fine if Bootstrap columns are still in a row on mobile. */

    .styled-product-media {
        width: 33.333%;
        flex: 0 0 33.333%;
        position: relative;
    }

    .styled-product-media .styled-product-image { /* The <a> tag */
        display: block;
    }

    .styled-product-media .styled-product-image img {
        height: auto; /* Let image aspect ratio determine height within its container */
    }

    .styled-product-content {
        width: 66.667%;
        flex: 0 0 66.667%;
        min-width: 0; /* Prevent flex item from growing too large */
        display: flex;
        flex-direction: column;
        padding: 0; /* Reset padding if parent .styled-product-card has it */
        justify-content: space-between; /* Try to space out content vertically */
    }

    .styled-product-name {
        font-size: 14px;
        margin: 0 0 4px 0; /* Reset desktop margin */
    }

    .styled-product-info {
        flex-grow: 0; /* Don't let it grow excessively on mobile row layout */
        font-size: 12px;
        line-height: 1.3;
        margin: 0 0 6px 0;
        display: -webkit-box;
        -webkit-line-clamp: 2; /* Limit to 2 lines */
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .styled-product-price {
        margin-bottom: 8px; /* Adjust spacing */
        font-size: 13px; /* Slightly smaller price text */
    }

    .buy_form { /* Ensure this is the parent of .cart-form */
        margin-top: auto; /* Push to bottom of .styled-product-content */
    }
    .buy_form .cart-form a.styled-product-add-btn {
        width: auto; /* Allow button to size based on content */
        min-width: 100px; /* Minimum touch target */
        padding: 4px 12px;
        height: 32px; /* Adjusted height */
        font-size: 13px;
    }

    .buy_form .cart-form a.styled-product-add-btn i {
        font-size: 12px;
    }
}

/* Extra small devices optimization */
@media (max-width: 380px) {
    .styled-product-card {
        padding: 6px;
        gap: 8px;
    }

    .styled-product-name {
        font-size: 13px;
    }

    .styled-product-info {
        font-size: 11px;
        -webkit-line-clamp: 2; /* Ensure it's still readable */
    }
    
    .styled-product-price {
        font-size: 12px;
    }

    .buy_form .cart-form a.styled-product-add-btn {
        padding: 4px 8px; /* Smaller padding */
        height: 28px;
        font-size: 12px;
        min-width: 80px;
    }
}
