/**
 * Product Comparison Table CSS
 * Struttura righe separate - No hover, altezza fissa 28px
 */

/* ===================================================== */
/* === SEZIONE CONFRONTO === */
/* ===================================================== */

.product-comparison-section {
    margin: 40px 0;
    padding: 0;
    background: #fff;
    position: relative;
}

.comparison-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 0 20px;
}

.comparison-title {
    font-size: 28px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px;
    line-height: 1.2;
}

.comparison-subtitle {
    font-size: 16px;
    color: #6b7280;
    margin: 0;
    opacity: 0.8;
}

/* ===================================================== */
/* === CONTAINER PRINCIPALE === */
/* ===================================================== */

.comparison-container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

/* ===================================================== */
/* === WRAPPER TABELLA === */
/* ===================================================== */

.comparison-table-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Nascondi scrollbar su desktop */
@media (min-width: 769px) {
    .comparison-table-wrapper {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .comparison-table-wrapper::-webkit-scrollbar {
        display: none;
    }
}

/* ===================================================== */
/* === GRIGLIA TABELLA === */
/* ===================================================== */

.comparison-table {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 600px;
    position: relative;
}

/* ===================================================== */
/* === RIGHE === */
/* ===================================================== */

.comparison-row {
    display: flex;
    width: 100%;
    border-bottom: 1px solid #e5e7eb;
}

/* Header row - sfondo bianco */
.comparison-row.header-row {
    background: #fff;
    border-bottom: 2px solid #e5e7eb;
    min-height: auto;
    padding: 20px 0;
}

/* Riga attributo - verde trasparente */
.comparison-row.attribute-row {
    background: rgba(20, 141, 70, 0.08);
    height: 28px;
    min-height: 28px;
    max-height: 28px;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
}

/* Riga valori - bianca con celle */
.comparison-row.values-row {
    background: #fff;
    height: 28px;
    min-height: 28px;
    max-height: 28px;
}

/* ===================================================== */
/* === CELLE === */
/* ===================================================== */

.comparison-cell {
    flex: 1;
    min-width: 180px;
    border-right: 1px solid #e5e7eb;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
}

.comparison-cell:last-child {
    border-right: none;
}

/* Header cells */
.product-header-cell {
    background: #fff;
    padding: 20px 16px;
    flex-direction: column;
    text-align: center;
    justify-content: center;
    min-height: auto;
    height: auto;
}

/* Value cells - altezza fissa 28px */
.value-cell {
    height: 28px;
    min-height: 28px;
    max-height: 28px;
    font-size: 14px;
    color: #374151;
    font-weight: 500;
    text-align: center;
    overflow: hidden;
}

/* Prima colonna - NO PIÙ STICKY su mobile */
.comparison-cell.main-product {
    background: rgba(255, 255, 255, 0.98);
    border-right: 2px solid #e5e7eb;
}

/* ===================================================== */
/* === HEADER ATTRIBUTO VERDE === */
/* ===================================================== */

.comparison-attribute-header {
    width: 100%;
    height: 28px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-weight: 700;
    font-size: 14px;
    color: #148d46;
    background: rgba(20, 141, 70, 0.08);
    box-sizing: border-box;
}

/* ===================================================== */
/* === HEADER PRODOTTI === */
/* ===================================================== */

.product-image-wrapper {
    margin-bottom: 16px;
}

.product-image-wrapper a {
    display: inline-block;
    border-radius: 0;
    overflow: hidden;
    background: transparent;
    padding: 0;
}

.product-image-wrapper img {
    width: 120px !important;
    height: 120px !important;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.product-name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 16px;
    color: #1f2937;
}

.product-name a {
    color: #1f2937;
    text-decoration: none;
}

/* ===================================================== */
/* === AZIONI PRODOTTO === */
/* ===================================================== */

.product-actions {
    width: 100%;
}

.product-comparison-section .add_to_cart_button {
    background: #148d46 !important;
    color: white !important;
    border: none !important;
    padding: 10px 20px !important;
    border-radius: 4px !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    width: 100% !important;
    height: auto !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    text-decoration: none !important;
}

.product-comparison-section .add_to_cart_button.loading {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
}

.comparison-select-options {
    background: #6b7280 !important;
    color: white !important;
    border: none !important;
    padding: 10px 20px !important;
    border-radius: 4px !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    width: 100%;
    text-align: center;
    display: block;
}

.comparison-unavailable {
    color: #ef4444;
    font-size: 13px;
    font-style: italic;
}

/* ===================================================== */
/* === VALUTAZIONI === */
/* ===================================================== */

.review-rating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 100%;
}

.star-rating {
    position: relative;
    display: inline-block;
    font-family: star, sans-serif;
    font-size: 14px;
    line-height: 1;
    color: #ddd;
}

.star-rating::before {
    content: "★★★★★";
    color: #e0e0e0;
    position: relative;
}

.star-rating span {
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    color: #ffc107;
    white-space: nowrap;
}

.star-rating span::before {
    content: "★★★★★";
}

.star-rating .rating {
    font-weight: 700;
    color: inherit;
}

/* ===================================================== */
/* === STOCK STATUS === */
/* ===================================================== */

.stock-indicator {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

.stock-indicator.in-stock {
    background: #10b981;
}

.stock-indicator.out-of-stock {
    background: #ef4444;
}

/* ===================================================== */
/* === PULSANTE ESPANDI === */
/* ===================================================== */

.comparison-expand-row {
    padding: 16px;
    text-align: left; /* Allineato a sinistra per visibilità mobile */
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.comparison-expand-btn {
    background: none;
    border: 1px solid #d1d5db;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: border-color 0.2s ease;
}

.comparison-expand-btn:hover {
    border-color: #9ca3af;
    /* Rimosso background hover che causava effetto bianco */
}

.comparison-expand-btn:focus {
    outline: 2px solid #148d46;
    outline-offset: 2px;
}

.comparison-expand-btn[aria-expanded="true"] .expand-icon {
    transform: rotate(180deg);
}

.comparison-expand-btn .expand-icon {
    transition: transform 0.3s ease;
}

/* ===================================================== */
/* === HIDDEN ATTRIBUTES ANIMATION === */
/* ===================================================== */

.comparison-hidden-attributes {
    transition: all 0.15s ease;
    overflow: hidden;
}

.comparison-hidden-attributes.expanded {
    display: block !important;
    animation: fadeInDown 0.15s ease;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================================================== */
/* === MOBILE SCROLL INDICATOR === */
/* ===================================================== */

.mobile-scroll-indicator {
    display: none !important; /* Completamente rimosso */
}

.mobile-scroll-indicator svg {
    flex-shrink: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* ===================================================== */
/* === RESPONSIVE MOBILE === */
/* ===================================================== */

/* ===================================================== */
/* === RESPONSIVE MOBILE - BREAKPOINT ESTESI === */
/* ===================================================== */

/* Mobile medio (fino a 834px) - include Galaxy A52s */
@media (max-width: 834px) {
    .comparison-container {
        margin: 0 10px;
        border-radius: 6px;
    }
    
    .comparison-table {
        min-width: 800px; /* Forza scroll orizzontale */
    }
    
    .comparison-cell {
        min-width: 140px;
        padding: 0 8px;
    }
    
    /* Header mobile */
    .product-header-cell {
        padding: 16px 12px;
        min-width: 140px;
    }
    
    .product-image-wrapper img {
        width: 80px !important;
        height: 80px !important;
    }
    
    .product-name {
        font-size: 13px;
        margin-bottom: 12px;
    }
    
    .add_to_cart_button {
        padding: 8px 12px !important;
        font-size: 11px !important;
        min-height: 34px !important;
    }
    
    /* Attributi mobile */
    .comparison-attribute-header {
        padding: 0 12px;
        font-size: 12px;
    }
    
    .value-cell {
        font-size: 12px;
        padding: 0 8px;
    }
    
    .star-rating {
        font-size: 12px;
    }
}

/* Mobile standard (fino a 768px) */
@media (max-width: 768px) {
    .comparison-expand-row {
        padding: 12px;
    }
}

/* ===================================================== */
/* === MOBILE PICCOLO === */
/* ===================================================== */

/* Mobile piccolo (fino a 480px) - Galaxy A52s e simili */
@media (max-width: 480px) {
    .comparison-title {
        font-size: 24px;
    }
    
    .comparison-subtitle {
        font-size: 14px;
    }
    
    .comparison-container {
        margin: 0 5px;
    }
    
    .comparison-table {
        min-width: 700px;
    }
    
    .comparison-cell {
        min-width: 120px;
        padding: 0 6px;
    }
    
    .product-header-cell {
        padding: 12px 8px;
        min-width: 120px;
    }
    
    .product-image-wrapper img {
        width: 70px !important;
        height: 70px !important;
    }
    
    .product-name {
        font-size: 12px;
        line-height: 1.2;
    }
    
    .product-comparison-section .add_to_cart_button {
        padding: 6px 10px !important;
        font-size: 10px !important;
        min-height: 30px !important;
    }
    
    .comparison-attribute-header {
        padding: 0 8px;
        font-size: 11px;
    }
    
    .value-cell {
        font-size: 11px;
        padding: 0 6px;
    }
    
    .comparison-expand-row {
        padding: 8px;
    }
    
    .comparison-expand-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* Mobile extra piccolo (fino a 393px) - Galaxy A52s esatto */
@media (max-width: 393px) {
    .comparison-table {
        min-width: 650px;
    }
    
    .comparison-cell {
        min-width: 110px;
        padding: 0 4px;
    }
    
    .product-header-cell {
        min-width: 110px;
        padding: 10px 6px;
    }
    
    .product-image-wrapper img {
        width: 60px !important;
        height: 60px !important;
    }
    
    .product-name {
        font-size: 11px;
    }
    
    .product-price {
        font-size: 13px;
    }
    
    .product-comparison-section .add_to_cart_button {
        padding: 5px 8px !important;
        font-size: 9px !important;
        min-height: 28px !important;
    }
}

/* ===================================================== */
/* === ACCESSIBILITÀ === */
/* ===================================================== */

.comparison-table-wrapper:focus {
    outline: 2px solid #148d46;
    outline-offset: 2px;
}

.comparison-cell a:focus,
.single_add_to_cart_button:focus,
.comparison-expand-btn:focus {
    outline: 2px solid #148d46 !important;
    outline-offset: 2px !important;
    z-index: 10;
    position: relative;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .comparison-container {
        border: 2px solid #000;
    }
    
    .comparison-attribute-header {
        background: #000 !important;
        color: #fff !important;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .comparison-hidden-attributes,
    .comparison-expand-btn .expand-icon {
        transition: none !important;
        animation: none !important;
    }
    
    .comparison-table-wrapper {
        scroll-behavior: auto !important;
    }
}

/* ===================================================== */
/* === LOADING STATE === */
/* ===================================================== */

.single_add_to_cart_button.loading {
    position: relative;
    overflow: hidden;
}

.single_add_to_cart_button.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}