/* Animaciones y estilos mejorados */
.product-card {
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 24px rgba(0,0,0,0.12);
}

.product-image-container {
    position: relative;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
    background: white;
    /* Altura fija para evitar que se encime */
    height: 200px;
    min-height: 200px;
    max-height: 200px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Skeleton loader mientras carga la imagen */
.product-image-container.loading {
    position: relative;
    overflow: hidden;
}

.product-image-container.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.3) 50%, 
        transparent 100%);
    animation: loadingShimmer 1.5s infinite;
    z-index: 1;
}

@keyframes loadingShimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.product-img-top {
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    width: 100%;
    height: 100%;
    object-fit: contain; /* CAMBIADO: Ahora muestra el producto completo sin recortar */
    object-position: center;
    padding: 12px;       /* NUEVO: Margen interno para que la imagen respire */
    box-sizing: border-box; /* Asegura que el padding no rompa las dimensiones */
}

/* Fallback para imágenes que no cargan */
.product-img-top.error {
    object-fit: contain;
    padding: 20px;
    background: #f8f9fa;
}

.product-img-top.loading {
    opacity: 0;
}

.product-img-top.loaded {
    opacity: 1;
    animation: fadeInImage 0.3s ease;
}

@keyframes fadeInImage {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 0 0 12px 12px;
}

.offer-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    z-index: 2;
    animation: pulse 1.5s infinite;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.95;
    }
}

.itaubadge {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    color: #FFD700;
    padding: 6px 10px;
    border-radius: 30px;
    font-size: 0.65rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 2;
    letter-spacing: 0.3px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    animation: slideUp 0.5s ease-out;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.itaubadge:hover {
    background: rgba(0, 0, 0, 0.95);
    border-color: #FFD700;
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

.itaulogo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.product-title {
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0 0 8px 0;
    color: #2c3e50;
    transition: color 0.3s ease;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 34px;
}

.product-card:hover .product-title {
    color: #3498db;
}

.product-price {
    font-size: 1rem;
    font-weight: 700;
    color: #2c3e50;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: all 0.3s ease;
    display: inline-block;
}

.product-card:hover .product-price {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    background-clip: text;
    -webkit-background-clip: text;
}

.btn-add-cart {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.btn-add-cart:hover {
    transform: scale(1.15) rotate(8deg);
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    box-shadow: 0 6px 12px rgba(231, 76, 60, 0.3);
}

.btn-add-cart i {
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.btn-add-cart:active {
    transform: scale(0.95);
}

/* Asegurar que el contenedor de precio y botón no se desborde */
.d-flex.justify-content-between {
    gap: 8px;
    flex-wrap: wrap;
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .product-image-container {
        height: 160px;
        min-height: 160px;
        max-height: 160px;
    }
    
    .product-img-top {
        padding: 8px; /* Reducimos un poco el margen en móviles para aprovechar espacio */
    }
    
    .itaubadge {
        font-size: 0.55rem;
        padding: 4px 8px;
        white-space: normal;
        line-height: 1.2;
    }
    
    .itaulogo {
        width: 14px;
        height: 14px;
    }
    
    .product-title {
        font-size: 0.75rem;
        min-height: 30px;
    }
    
    .product-price {
        font-size: 0.85rem;
    }
    
    .btn-add-cart {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 576px) {
    .product-image-container {
        height: 140px;
        min-height: 140px;
        max-height: 140px;
    }
    .product-img-top {
        padding: 6px; /* Margen aún más optimizado para pantallas muy chicas */
    }
}

/* Animación de entrada para los productos */
.product-card {
    animation: fadeInUp 0.6s ease-out backwards;
    animation-delay: calc(var(--order, 0) * 0.05s);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}