﻿/**
 * Product Card Carousel - Unified card for Related Products and Suggested Promotions
 * Mobile-first design following the specification
 * FIXED: All cards have consistent size regardless of content
 */

:root {
    --product-card-carousel-touch-target: 25px;
}

/* ============================================
   Product Card Carousel - Main Component
   ============================================ */
.product-card-carousel {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    /* Fixed height for consistency */
    height: 100%;
    width: 100%;
}

.product-card-carousel:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

/* ============================================
   Image Section
   ============================================ */
.product-card-carousel__image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* Fixed size - doesn't shrink */
    flex: 0 0 auto;
}

.product-card-carousel__image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 1rem;
    transition: transform 0.3s ease;
}

.product-card-carousel:hover .product-card-carousel__image {
    transform: scale(1.05);
}

.product-card-carousel__discount-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: #dc3545;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ============================================
   Body Section
   ============================================ */
.product-card-carousel__body {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    /* Fixed constraints for flex items */
    min-height: 0;
    overflow: hidden;
}

.product-card-carousel__price-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
    /* Fixed size - price section doesn't grow */
    flex: 0 0 auto;
}

.product-card-carousel__price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-color);
    margin: 0;
    line-height: 1.2;
    word-break: break-word;
    white-space: normal;
}

.product-card-carousel__price--old {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 0;
    line-height: 1.2;
    word-break: break-word;
    white-space: normal;
}

.product-card-carousel__name {
    font-size: 0.875rem;
    color: #333;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    /* Fixed height: 2 lines * 1.4 line-height = 2.8em */
    height: 2.8em;
    /* Don't grow or shrink beyond this */
    flex: 0 0 2.8em;
}

.product-card-carousel__stock {
    font-size: 0.8125rem;
    color: #666;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    /* Fixed size - stock section doesn't grow */
    flex: 0 0 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 1.2em;
}

.product-card-carousel__stock i {
    color: var(--brand-color);
    font-size: 0.875rem;
    flex-shrink: 0;
}

/* ============================================
   Actions Section
   ============================================ */
.product-card-carousel__actions {
    padding: 0.75rem 1rem 1rem;
    display: flex;
    gap: 0.5rem;
    border-top: 1px solid #e0e0e0;
    background-color: #fafafa;
    /* Fixed size - actions section doesn't grow */
    flex: 0 0 auto;
    flex-wrap: wrap;
}

.product-card-carousel__button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.product-card-carousel__button--add {
    flex: 1;
    background-color: var(--brand-color);
    color: #fff;
    min-width: 80px;
}

.product-card-carousel__button--add:hover:not(:disabled) {
    background-color: var(--brand-color-dark-10);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 168, 89, 0.3);
}

.product-card-carousel__button--add:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 168, 89, 0.3);
}

.product-card-carousel__button--add:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.product-card-carousel__button--favorite {
    min-width: 40px;
    width: 40px;
    padding: 0.625rem;
    background-color: transparent;
    border: 1px solid #e0e0e0;
    color: #666;
    flex-shrink: 0;
}

.product-card-carousel__button--favorite:hover {
    background-color: #fff;
    border-color: var(--brand-color);
    color: var(--brand-color);
    transform: scale(1.05);
}

.product-card-carousel__button--favorite:active {
    transform: scale(0.95);
}

.product-card-carousel__button--favorite i {
    font-size: 1.125rem;
}

/* Quantity Control State */
.product-card-carousel__quantity-control {
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: fadeIn 0.3s ease;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-card-carousel__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.product-card-carousel__control-btn {
    min-width: var(--product-card-carousel-touch-target);
    min-height: var(--product-card-carousel-touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 50%;
    color: #212529;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    cursor: pointer;
    padding: 5px;
}

    .product-card-carousel__control-btn:active:not(:disabled) {
        transform: scale(0.95);
        background-color: #e9ecef;
    }

    .product-card-carousel__control-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

.product-card-carousel__control-btn--decrease {
    border-color: var(--brand-color); /* Uses theme brand color */
    color: var(--brand-color);
}

.product-card-carousel__control-btn--increase {
    border-color: var(--brand-color); /* Uses theme brand color */
    color: var(--brand-color);
}

.product-card-carousel__quantity-display {
    min-width: 30px;
    text-align: center;
}

.product-card-carousel__quantity-value {
    font-size: 1rem;
    font-weight: 700;
    color: #212529;
}

/* ============================================
   Related Products Integration
   ============================================ */
.related-products__item {
    cursor: default;
}

.related-products__item .product-card-carousel {
    cursor: pointer;
}

.related-products__icon {
    color: var(--brand-color);
    font-size: 1.125rem;
}

/* ============================================
   Suggested Promotion Integration
   ============================================ */
.product-promotion__item {
    cursor: default;
}

.product-promotion__item .product-card-carousel {
    cursor: default;
}

.product-promotion__products-section {
    margin-bottom: 1rem;
}

.product-promotion__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
}

.product-promotion__icon {
    color: var(--brand-color);
    font-size: 1.125rem;
}

.product-promotion__title {
    font-size: 1rem;
    font-weight: 700;
    color: #333;
    margin: 0;
}

.product-promotion__table-section {
    margin-top: 1rem;
}

.product-promotion__table {
    margin-bottom: 0;
}

/* ============================================
   Compact Mode - Reduced sizes for density
   ============================================ */
.product-card-carousel.product-card-carousel--compact {
    border-radius: 6px;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__image-container {
    aspect-ratio: 1 / 1;
    /* Fixed size */
    flex: 0 0 auto;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__image {
    padding: 0.375rem;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__body {
    padding: 0.5rem;
    gap: 0.25rem;
    /* Fixed constraints */
    min-height: 0;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__price {
    font-size: 0.9375rem;
    word-break: break-word;
    white-space: normal;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__price--old {
    font-size: 0.75rem;
    word-break: break-word;
    white-space: normal;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__name {
    font-size: 0.75rem;
    -webkit-line-clamp: 2;
    line-height: 1.3;
    word-break: break-word;
    /* Fixed height: 2 lines * 1.3 line-height = 2.6em, but set to 1.95em for compact */
    height: 1.95em;
    flex: 0 0 1.95em;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__stock {
    font-size: 0.6875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 1.1em;
    flex: 0 0 1.1em;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__actions {
    padding: 0.375rem 0.5rem 0.5rem;
    gap: 0.25rem;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__button {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    min-height: 36px;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__button--add {
    min-width: 60px;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__button--favorite {
    min-width: 36px;
    width: 36px;
    padding: 0.375rem;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__button--favorite i {
    font-size: 1rem;
}

.product-card-carousel.product-card-carousel--compact .product-card-carousel__discount-badge {
    top: 4px;
    right: 4px;
    padding: 2px 6px;
    font-size: 0.6875rem;
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-card-carousel {
    animation: fadeIn 0.3s ease;
}
