/* 
  Unified Product Card Stylesheet 
  - All classes are prefixed with `upc-` to ensure they are isolated
    and do not conflict with other styles on any page.
*/

:root {
    --upc-pink: #c2185b;
    --upc-dark-pink: #a91650;
    --upc-text-dark: #333;
    --upc-text-light: #666;
    --upc-border-color: #e0e0e0;
    --upc-bg-light: #f9f9f9;
    --upc-star-color: #ffc107;
}

.upc-card {
    background: #fff;
    border: 1px solid var(--upc-border-color);
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, height 0.3s ease;
    position: relative;
}

.upc-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}

/* --- Image Section --- */
.upc-image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 100%; /* Creates a 1:1 aspect ratio container */
    overflow: hidden;
}

.upc-image-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.upc-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.upc-card:hover .upc-image {
    transform: scale(1.05);
}

.upc-badges {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
}

.upc-discount-badge {
    background: var(--upc-pink);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
}

.upc-wishlist-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    border: 1px solid var(--upc-border-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    color: var(--upc-text-dark);
    transition: all 0.2s ease;
    z-index: 2;
}

.upc-wishlist-btn:hover {
    background: var(--upc-pink);
    color: white;
    transform: scale(1.1);
}

.upc-wishlist-btn.active {
    background: var(--upc-pink);
    color: white;
}

.upc-quick-view-btn {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 2;
}

.upc-card:hover .upc-quick-view-btn {
    opacity: 1;
    transform: translateY(0);
}

/* --- Content Section --- */
.upc-content-wrapper {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.upc-title-link {
    text-decoration: none;
    color: inherit;
}

.upc-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--upc-text-dark);
    margin: 0 0 0.25rem 0;
    line-height: 1.3;
    /* Clamp to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden; /* This is correct */
}

.upc-seller {
    font-size: 0.8rem;
    color: var(--upc-text-light);
    margin: 0 0 0.5rem 0;
}

.upc-seller-link {
    color: var(--upc-pink);
    text-decoration: none;
}

.upc-rating {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    position: relative;
}

.upc-stars-background, .upc-stars-foreground {
    display: flex;
    color: var(--upc-star-color);
}
.upc-stars-background { color: #e0e0e0; }
.upc-stars-foreground {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
}

.upc-rating-count {
    font-size: 0.8rem;
    color: var(--upc-text-light);
    margin-left: 0.25rem;
}

.upc-price-wrapper {
    margin-top: auto; /* Pushes price to the bottom */
    padding-top: 0.5rem;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.upc-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--upc-pink);
}

.upc-price--original {
    font-size: 0.9rem;
    color: var(--upc-text-light);
    text-decoration: line-through;
}

/* --- Actions Section --- */
.upc-actions {
    padding: 0 1rem 1rem 1rem;
    display: flex;
    justify-content: center; /* Center the buttons now that they don't fill the space */
    gap: 0.5rem;
}

.upc-btn {
    /* flex: 1; Removed to stop the buttons from stretching */
    padding: 8px 16px; /* Reduced padding for a smaller button */
    border-radius: 8px;
    font-size: 0.85rem; /* Slightly smaller font */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-left: 20px;
}

.upc-btn--primary {
    background: var(--upc-pink);
    color: white;
    border: 1px solid var(--upc-pink);
}

.upc-btn--primary:hover {
    background: var(--upc-dark-pink);
    border-color: var(--upc-dark-pink);
    transform: translateY(-2px);
}

.upc-btn--secondary {
    background: transparent;
    color: var(--upc-pink);
    border: 1px solid var(--upc-pink);
}

.upc-btn--secondary:hover {
    background: var(--upc-pink);
    color: white;
}

/* --- DESKTOP HORIZONTAL LAYOUT --- */
@media (min-width: 992px) {
    .upc-card {
        flex-direction: row;
        height: 220px; /* A fixed height for a clean, aligned row */
    }

    .upc-image-wrapper {
        flex: 0 0 40%; /* Image container takes a consistent 40% of the card width */
        width: 40%;
        height: 100%;
        padding-top: 0; /* Remove padding-top hack for aspect ratio */
    }

    /* Create a new flex container for the right side content */
    .upc-card-main-content {
        display: flex;
        flex-direction: row;
        align-items: stretch; /* Allow children to fill the height */
        justify-content: space-between; /* Push text to the left and buttons to the right */
        flex-grow: 1;
        padding: 1rem;
        min-width: 0; /* Prevents flexbox overflow issues */
    }

    .upc-text-content {
        flex-grow: 1; /* Allow text content to take up available space */
        min-width: 0; /* Prevent long text from pushing buttons out */
        padding-right: 1rem; /* Add space between text and buttons */
    }

    .upc-content-wrapper {
        display: flex;
        flex-direction: column;
        justify-content: center; /* Vertically center the text inside its container */
        padding: 0;
    }

    .upc-price-wrapper {
        margin-top: 0.5rem;
        padding-top: 0;
    }

    .upc-actions {
        flex-direction: column; /* Stack the buttons vertically */
        flex-shrink: 0; /* Prevent buttons from shrinking */
        flex-basis: 130px; /* Give the button column a fixed width */
        padding: 0; /* Reset padding */
        margin-top: 0; /* Remove the margin-top that pushed it down */
        margin-left: 1rem; /* Add space between text and buttons */
        border-top: none; /* Remove the top border */
        justify-content: center;
    }
}
