/**
 * CSS Unificato per Card Prodotti
 * Utilizzato in tutte le pagine: pneumatici, cerchi, ruotini, ruote complete
 */

/* ===== CONTAINER IMMAGINE ===== */
.product-image-container {
    aspect-ratio: 1 / 1 !important;
    width: 100% !important;
    height: auto !important;
    background: #f8fafc;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border-radius: 0.5rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transform: translateZ(0);
    will-change: transform;
}

.product-image-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* ===== IMMAGINE PRODOTTO ===== */
.product-image {
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    filter: contrast(1.1) brightness(1.05);
    transition: transform 0.3s ease;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

.product-image-container:hover .product-image {
    transform: scale(1.02);
}

/* ===== OVERLAY IMMAGINE ===== */
.product-image-overlay {
    background: linear-gradient(45deg, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.3) 100%);
}

/* ===== GRIGLIA PRODOTTI ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 640px) {
    .products-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* ===== CARD PRODOTTO ===== */
.product-card {
    transition: all 0.3s ease;
    border: 1px solid transparent;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.dark .product-card {
    background: #1f2937;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border-color: #e5e7eb;
}

.product-card:hover .product-image-container {
    transform: translateY(-2px);
}

/* ===== BADGES ===== */
.product-image-container .absolute {
    pointer-events: none;
}

.product-image-container .absolute span {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.75rem;
    font-weight: 600;
}

.dark .product-image-container .absolute span {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===== BADGE MARCA E FINITURA ===== */
.brand-badge, .finish-badge {
    transition: all 0.2s ease;
}

.brand-badge:hover, .finish-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== SPECIFICHE TECNICHE ===== */
.tech-specs {
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
    background: #f9fafb;
    border-radius: 0.5rem;
    padding: 0.75rem;
}

.dark .tech-specs {
    border-color: #374151;
    background: #374151;
}

.tech-specs:hover {
    border-color: #d1d5db;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dark .tech-specs:hover {
    border-color: #4b5563;
}

/* ===== ICONE TECNICHE ===== */
.tech-icon {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

/* ===== SEZIONE INFO ===== */
.info-section {
    border: 1px solid #d1fae5;
    transition: all 0.2s ease;
    background: #f0fdf4;
    border-radius: 0.5rem;
    padding: 0.75rem;
}

.dark .info-section {
    border-color: #065f46;
    background: rgba(6, 95, 70, 0.1);
}

.info-section:hover {
    border-color: #a7f3d0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dark .info-section:hover {
    border-color: #10b981;
}

/* ===== CONTROLLI QUANTITÀ ===== */
.quantity-input {
    -moz-appearance: textfield !important;
    text-align: center;
    font-weight: bold;
    height: 40px;
    line-height: 40px;
    width: 2rem !important;
    min-width: 2rem !important;
    max-width: 2rem !important;
    padding: 0 !important;
}

/* Nascondi frecce su tutti i browser */
.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    margin: 0 !important;
    display: none !important;
}

.quantity-input::-ms-clear {
    display: none !important;
}

/* Firefox - nascondi frecce */
.quantity-input[type="number"] {
    -moz-appearance: textfield !important;
}

/* Edge/IE - nascondi frecce */
.quantity-input::-webkit-inner-spin-button,
.quantity-input::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

.quantity-controls {
    height: 40px;
    display: flex;
    align-items: center;
    width: fit-content;
    min-width: auto;
    border: 1px solid #d1d5db;
    transition: border-color 0.2s ease;
    background: white;
    border-radius: 0.5rem;
}

.quantity-controls:hover {
    border-color: #9ca3af;
}

.dark .quantity-controls {
    border-color: #4b5563;
    background: #374151;
}

.dark .quantity-controls:hover {
    border-color: #6b7280;
}

.quantity-controls button {
    border: none;
    background: transparent;
    color: #6b7280;
    height: 40px;
    width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
}

.quantity-controls button:hover {
    background: #f3f4f6;
    color: #374151;
}

.dark .quantity-controls button:hover {
    background: #4b5563;
    color: #d1d5db;
}

/* ===== ICONE AZIONI ===== */
.action-icon {
    transition: all 0.2s ease;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
}

.action-icon[title="Visualizza prodotto"] {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
}

.dark .action-icon[title="Visualizza prodotto"] {
    background: #374151;
    border-color: #4b5563;
}

.action-icon[title="Visualizza prodotto"]:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.dark .action-icon[title="Visualizza prodotto"]:hover {
    background: #4b5563;
    border-color: #6b7280;
}

.action-icon:hover {
    transform: scale(1.1);
}

/* ===== PULSANTE CARRELLO ===== */
.cart-button {
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cart-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.cart-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ===== PREZZO ===== */
.price-display {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* ===== LAYOUT PREZZO E PULSANTE ===== */
.price-button-row {
    gap: 0.5rem;
    flex-wrap: nowrap !important;
    align-items: center;
    justify-content: space-between;
}

/* Wrapper per centrare la quantità tra prezzo e azioni */
.price-button-row .quantity-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
}

/* ===== QUANTITY CONTROLS ===== */
.quantity-controls {
    height: 32px;
    display: flex;
    align-items: center;
}

.quantity-controls button {
    padding: 0.25rem 0.375rem !important;
    min-width: 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-input {
    width: 2rem !important;
    min-width: 2rem !important;
    max-width: 2rem !important;
    padding: 0.125rem 0.25rem !important;
    font-size: 0.75rem !important;
}

/* ===== ACTION ICONS ===== */
.price-button-row .action-icon {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    padding: 0.25rem !important;
}

.price-button-row .action-icon .material-icons {
    font-size: 0.875rem !important;
}

.price-button-row .action-icon svg {
    width: 0.875rem !important;
    height: 0.875rem !important;
}

/* Ottimizzazioni per monitor desktop più piccoli (1024px - 1280px) */
@media (min-width: 1024px) and (max-width: 1280px) {
    .price-button-row {
        gap: 0.5rem;
        flex-wrap: wrap !important;
    }
    
    .price-display {
        min-width: 60px !important;
        flex-shrink: 0;
    }
    
    .price-display .text-base {
        font-size: 0.875rem !important;
    }
    
    .price-display .text-xs {
        font-size: 0.625rem !important;
    }
    
    .quantity-controls {
        height: 32px;
        flex-shrink: 0;
    }
    
    .quantity-controls button {
        padding: 0.25rem 0.375rem !important;
        min-width: 24px;
        height: 100%;
    }
    
    .quantity-controls .material-icons {
        font-size: 0.875rem !important;
    }
    
    .quantity-input {
        width: 2rem !important;
        min-width: 2rem !important;
        max-width: 2rem !important;
        padding: 0.125rem 0.25rem !important;
        font-size: 0.75rem !important;
    }
    
    .price-button-row .action-icon {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        padding: 0.25rem !important;
    }
    
    .price-button-row .action-icon .material-icons {
        font-size: 0.875rem !important;
    }
    
    .price-button-row .action-icon svg {
        width: 0.875rem !important;
        height: 0.875rem !important;
    }
    
    /* Assicura che il gruppo azioni non esca fuori */
    .price-button-row > div:last-child {
        flex-wrap: wrap;
        gap: 0.375rem;
    }
}

@media (max-width: 640px) {
    .price-button-row {
        flex-direction: row;
        flex-wrap: wrap !important;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        justify-content: space-between;
    }
    
    .price-button-row .price-display {
        min-width: 60px !important;
        max-width: 80px;
        flex-shrink: 0;
    }
    
    .price-button-row .quantity-wrapper {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        min-width: 0;
    }
    
    .price-button-row .quantity-controls {
        height: 32px;
        flex-shrink: 0;
        min-width: fit-content;
    }
    
    .price-button-row .quantity-controls button {
        padding: 0.25rem 0.375rem !important;
        min-width: 24px;
        height: 100%;
    }
    
    .price-button-row .quantity-input {
        width: 2rem !important;
        min-width: 2rem !important;
        max-width: 2rem !important;
        padding: 0.125rem 0.25rem !important;
        font-size: 0.75rem !important;
    }
    
    .price-button-row > div:last-child {
        flex-wrap: wrap;
        gap: 0.375rem;
        flex-shrink: 0;
        min-width: 0;
    }
    
    .price-button-row .action-icon {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        padding: 0.25rem !important;
        flex-shrink: 0;
    }
    
    .price-button-row .action-icon .material-icons {
        font-size: 0.875rem !important;
    }
    
    .price-button-row .action-icon svg {
        width: 0.875rem !important;
        height: 0.875rem !important;
    }
    
    .price-button-row .cart-button {
        width: auto;
        justify-content: center;
    }
}

/* ===== NOTIFICA CARRELLO ===== */
.cart-notification {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== RESPONSIVE ===== */
@media (min-width: 640px) {
    .product-image-container {
        height: 200px;
    }
}

@media (min-width: 768px) {
    .product-image-container {
        height: 220px;
    }
}

@media (min-width: 1024px) {
    .product-image-container {
        height: 240px;
    }
}

/* ===== OTTIMIZZAZIONI IMMAGINI ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .product-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ===== FORZA QUALITÀ IMMAGINI ===== */
.product-image-container img {
    max-width: none !important;
    max-height: none !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
}

/* ===== RIMOZIONE SCROLLING IMMAGINI PRODOTTO ===== */

/* Rimuovi scrolling orizzontale da tutti i contenitori immagini */
.space-y-4 {
    overflow: hidden !important;
}

.space-y-4 > div {
    overflow: hidden !important;
}

/* ===== RIMOZIONE SCROLLING SPECIFICO PAGINA PRODOTTO ===== */
#product-info {
    overflow-x: hidden !important;
}

#product-info .grid {
    overflow-x: hidden !important;
}

#product-info .space-y-4 {
    overflow-x: hidden !important;
}

#product-info .aspect-square {
    overflow: hidden !important;
}

#product-info img {
    overflow: hidden !important;
    max-width: 100% !important;
    height: auto !important;
}

/* Thumbnails sempre quadrate - coprono l'area disponibile */
.thumbnail-item {
    overflow: hidden !important;
    position: relative;
    aspect-ratio: 1 / 1 !important; /* Forza ratio quadrato */
}

.thumbnail-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* Copre l'area tagliando se necessario */
    object-position: center !important; /* Centra l'immagine */
    display: block;
}

/* ===== REGOLE GLOBALI PER TUTTE LE IMMAGINI PRODOTTO ===== */
/* Assicura che tutte le immagini prodotto siano quadrate con ritaglio centrale */

/* Container immagini prodotto - sempre quadrati */
.product-image-container {
    aspect-ratio: 1 / 1 !important;
    width: 100% !important;
    overflow: hidden !important;
    position: relative !important;
}

/* Immagini dentro container prodotto - sempre cover e centrate */
.product-image-container img,
.product-image {
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}

/* Container aspect-square - sempre quadrati */
.aspect-square {
    aspect-ratio: 1 / 1 !important;
    width: 100% !important;
    overflow: hidden !important;
    position: relative !important;
}

/* Immagini dentro aspect-square - sempre cover e centrate */
.aspect-square img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

/* Immagini nella pagina prodotto */
#product-info .aspect-square {
    aspect-ratio: 1 / 1 !important;
    width: 100% !important;
    overflow: hidden !important;
    position: relative !important;
}

#product-info .aspect-square img,
#product-info img[class*="product"],
#main-product-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

/* Thumbnails nella pagina prodotto */
#product-info .thumbnail-item {
    aspect-ratio: 1 / 1 !important;
    width: 100% !important;
    overflow: hidden !important;
    position: relative !important;
}

#product-info .thumbnail-item img,
#product-info .grid img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

/* Regole generali per tutte le immagini prodotto (fallback) */
.products-grid img,
.product-card img,
[class*="product-card"] img {
    object-fit: cover !important;
    object-position: center !important;
}
