/* Product Card Component - Modern Glassmorphism Style */

/* ===== Wrapper ===== */
.product-card-wrapper {
    height: 100%;
}

/* ===== Card Base ===== */
.product-card.ui-card {
    padding: 0 !important;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ===== Image Section ===== */
.product-card-image-wrapper {
    position: relative;
}

.product-card-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: linear-gradient(135deg, 
        rgba(132, 0, 135, 0.03) 0%, 
        rgba(132, 0, 135, 0.01) 100%);
    display: block;
    text-decoration: none;
}

.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-base);
}

.product-card:hover .product-card-image img {
    transform: scale(1.05);
}

/* ===== Overlay (for quantity display) ===== */
.product-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: inherit;
}

.product-card-overlay.active {
    display: flex;
}

.product-card-overlay-count {
    font-size: 28px;
    font-weight: var(--font-weight-bold);
    line-height: 1.2;
}

.product-card-overlay-sum {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    opacity: 0.9;
}

.product-card-overlay-nomore {
    font-size: var(--font-size-xs);
    margin-top: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-md);
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius-full);
    display: none;
}

.product-card-overlay-nomore.visible {
    display: block;
}

/* ===== Discount Badge ===== */
.product-card-badge {
    position: absolute;
    top: var(--spacing-sm);
    left: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-md);
    background: linear-gradient(135deg, var(--color-danger) 0%, var(--color-danger-hover) 100%);
    color: white;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    border-radius: var(--border-radius-full);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* ===== Favorite Button ===== */
.product-card-favorite {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--color-text-muted);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.product-card-favorite:hover {
    background: white;
    color: var(--color-danger);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.product-card-favorite.active {
    color: var(--color-danger);
}

.product-card-favorite.active svg {
    fill: currentColor;
}

/* ===== Content Section ===== */
.product-card-content {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    flex: 1;
}

.product-card-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.7em;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.product-card-name:hover {
    color: var(--color-primary);
}

.product-card-shop {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: italic;
}

/* ===== Price Section ===== */
.product-card-price {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    margin-top: auto;
}

/* ===== Add to Cart Button ===== */
.product-card-add-wrapper {
    margin-top: auto;
}

.product-card-add-btn.ui-button {
    width: 100%;
    min-height: 44px;
}

/* Hide add button wrapper when product is in cart */
.product-card-wrapper[data-count]:not([data-count="0"]) .product-card-add-wrapper {
    display: none;
}

/* ===== Quantity Controls ===== */
.product-card-qty-controls {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 4px;
    min-height: 48px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: var(--border-radius-full);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Show qty controls when product is in cart */
.product-card-wrapper[data-count]:not([data-count="0"]) .product-card-qty-controls {
    display: flex;
}

/* Override ui-button styles for qty buttons */
.product-card-qty-btn.ui-button {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: var(--border-radius-full);
    box-shadow: none;
    flex-shrink: 0;
}

/* Hide text span in qty buttons (icon only) */
.product-card-qty-btn .ui-button-text {
    display: none;
}

.product-card-qty-btn .ui-button-icon {
    font-size: 1.25rem;
}

.product-card-qty-btn svg {
    width: 22px;
    height: 22px;
}

/* Quantity Input */
.product-card-qty-input {
    width: 48px;
    min-width: 48px;
    flex: 1;
    max-width: 60px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    text-align: center;
    padding: 0;
    margin: 0;
    -moz-appearance: textfield;
    appearance: textfield;
}

.product-card-qty-input::-webkit-outer-spin-button,
.product-card-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.product-card-qty-input:focus {
    outline: none;
    background: rgba(var(--color-primary-rgb), 0.08);
    border-radius: var(--border-radius-sm);
}

/* ===== States ===== */

/* When product is in cart */
.product-card-wrapper[data-count]:not([data-count="0"]) .product-card-overlay {
    display: flex;
}

/* When product is at max quantity */
.product-card-wrapper.at-max .product-card-overlay-nomore {
    display: block;
}

.product-card-wrapper.at-max .product-plus {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== Responsive ===== */

/* Tablet */
@media (max-width: 768px) {
    .product-card-favorite {
        width: 32px;
        height: 32px;
    }
    
    .product-card-favorite svg {
        width: 16px;
        height: 16px;
    }
}

/* Mobile */
@media (max-width: 576px) {
    .product-card-content {
        padding: var(--spacing-md);
        gap: var(--spacing-sm);
    }
    
    .product-card-name {
        font-size: var(--font-size-base);
        min-height: 2.6em;
        -webkit-line-clamp: 2;
        line-height: 1.4;
    }
    
    .product-card-shop {
        font-size: var(--font-size-sm);
    }
    
    .product-card-price {
        font-size: var(--font-size-lg);
    }
    
    /* Кнопка "В корзину" на мобильных */
    .product-card-add-btn.ui-button {
        min-height: 44px;
    }
    
    .product-card-add-btn svg {
        width: 20px;
        height: 20px;
    }
    
    /* Контролы количества на мобильных */
    .product-card-qty-controls {
        padding: 3px;
        min-height: 46px;
    }
    
    .product-card-qty-btn.ui-button {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
    }
    
    .product-card-qty-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .product-card-qty-input {
        font-size: var(--font-size-base);
        width: 40px;
        min-width: 40px;
        height: 28px;
    }
    
    /* Кнопка избранного */
    .product-card-favorite {
        width: 32px;
        height: 32px;
        border-radius: var(--border-radius-md);
    }
    
    .product-card-favorite svg {
        width: 16px;
        height: 16px;
    }
    
    /* Бейдж скидки */
    .product-card-badge {
        padding: 2px 6px;
        font-size: var(--font-size-xs);
    }
    
    /* Overlay с улучшенной читаемостью */
    .product-card-overlay-count {
        font-size: 28px;
    }
    
    .product-card-overlay-sum {
        font-size: var(--font-size-sm);
        margin-top: var(--spacing-xs);
    }
    
    .product-card-overlay-nomore {
        font-size: var(--font-size-xs);
        padding: var(--spacing-xs) var(--spacing-sm);
    }
}

/* Очень маленькие экраны */
@media (max-width: 375px) {
    .product-card-content {
        padding: var(--spacing-sm);
    }
    
    .product-card-name {
        font-size: var(--font-size-sm);
        min-height: 2.4em;
    }
    
    .product-card-shop {
        font-size: var(--font-size-xs);
    }
    
    .product-card-price {
        font-size: var(--font-size-base);
    }
    
    .product-card-add-btn.ui-button {
        min-height: 40px;
        font-size: var(--font-size-xs);
    }
    
    .product-card-qty-controls {
        padding: 2px;
        min-height: 42px;
    }
    
    .product-card-qty-btn.ui-button {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }
    
    .product-card-qty-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .product-card-qty-input {
        font-size: var(--font-size-sm);
        width: 36px;
        min-width: 36px;
        height: 26px;
    }
    
    .product-card-favorite {
        width: 28px;
        height: 28px;
    }
    
    .product-card-favorite svg {
        width: 14px;
        height: 14px;
    }
}

/* Touch устройства */
@media (hover: none) and (pointer: coarse) {
    /* Убираем hover-эффекты на touch устройствах */
    .product-card:hover .product-card-image img {
        transform: none;
    }
}

/* ===== Animation ===== */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.product-card-favorite.animate {
    animation: pulse 0.3s ease-in-out;
}

.product-card-price-old {
    color: #ff3b30;
    text-decoration: line-through;
    margin-right: 6px;
    font-size: 14px;
}

.product-card-price-current {
    font-weight: 600;
    font-size: 18px;
}