/* ===========================================
   STILI TABELLE ASSISTENZA - RESPONSIVE v2
   =========================================== */

/* Container tabella */
.assistenza-content table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1.5rem 0;
    font-size: 0.95rem;
    background: #fff;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Header tabella */
.assistenza-content table thead {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.assistenza-content table thead th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: #fff;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
}

.assistenza-content table thead th:first-child {
    border-radius: 12px 0 0 0;
}

.assistenza-content table thead th:last-child {
    border-radius: 0 12px 0 0;
}

/* Corpo tabella */
.assistenza-content table tbody tr {
    transition: background-color 0.2s ease;
}

.assistenza-content table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.assistenza-content table tbody tr:hover {
    background-color: #e8f4f8;
}

.assistenza-content table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
    color: #333;
    position: relative;
    overflow: visible;
}

.assistenza-content table tbody tr:last-child td {
    border-bottom: none;
}

.assistenza-content table tbody tr:last-child td:first-child {
    border-radius: 0 0 0 12px;
}

.assistenza-content table tbody tr:last-child td:last-child {
    border-radius: 0 0 12px 0;
}

/* Stile celle specifiche */
.assistenza-content table td:first-child {
    font-weight: 600;
    color: #1a1a2e;
}

/* Prezzi */
.assistenza-content table td:nth-child(2) {
    color: #e74c3c;
    font-weight: 600;
}

/* ===========================================
   CODICI PRODOTTO - BADGE
   =========================================== */
.product-code {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f0f4f8;
    padding: 5px 12px;
    border-radius: 6px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    color: #2c3e50;
    margin: 2px 4px 2px 0;
    border: 1px solid #dce4ec;
    transition: all 0.2s ease;
}

.product-code:hover {
    background: #e3eaf2;
    border-color: #b8c9d9;
}

/* Codice con link al prodotto - VERDE con icona visibile */
.product-code.has-product {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: #fff;
    border-color: #28a745;
    cursor: pointer;
    position: relative;
    font-weight: 600;
}

.product-code.has-product:hover {
    background: linear-gradient(135deg, #218838 0%, #1db888 100%);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(40, 167, 69, 0.35);
}

/* Icona carrello SVG - sempre visibile su verde */
.product-code.has-product::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zM1 2v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.58-6.49c.08-.14.12-.31.12-.48 0-.55-.45-1-1-1H5.21l-.94-2H1zm16 16c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    flex-shrink: 0;
}

/* ===========================================
   PREVIEW PRODOTTO - DESKTOP
   =========================================== */
.product-preview {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 16px;
    width: 260px;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.product-preview.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

/* Freccia in basso */
.product-preview::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 10px solid transparent;
    border-top-color: #fff;
}

/* Preview che si apre verso il basso se non c'è spazio */
.product-preview.position-below {
    bottom: auto;
    top: calc(100% + 12px);
}

.product-preview.position-below::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #fff;
}

/* Immagine prodotto */
.product-preview-image {
    width: 100%;
    height: 140px;
    object-fit: contain;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 12px;
    display: block;
}

/* Titolo prodotto */
.product-preview-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 8px;
    line-height: 1.4;
    max-height: 2.8em;
    overflow: hidden;
    text-transform: capitalize;
}

/* Prezzo */
.product-preview-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: #e74c3c;
    margin-bottom: 12px;
}

/* Pulsante Acquista - FIX pointer-events */
.product-preview-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: #fff !important;
    text-align: center;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none !important;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.product-preview-btn:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
    color: #fff !important;
    text-decoration: none !important;
}

/* Pulsante chiudi - solo desktop */
.product-preview-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: #f0f0f0;
    border-radius: 50%;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s ease;
    z-index: 10;
}

.product-preview-close:hover {
    background: #e0e0e0;
    color: #333;
}

/* ===========================================
   MOBILE RESPONSIVE - Card Layout
   =========================================== */
@media (max-width: 768px) {
    .assistenza-content table {
        display: block;
        border-radius: 12px;
        box-shadow: none;
        overflow: visible;
    }

    .assistenza-content table thead {
        display: none;
    }

    .assistenza-content table tbody {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .assistenza-content table tbody tr {
        display: flex;
        flex-direction: column;
        background: #fff;
        border-radius: 12px;
        padding: 16px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        border: 1px solid #e9ecef;
    }

    .assistenza-content table tbody tr:nth-child(even) {
        background: #fff;
    }

    .assistenza-content table tbody tr:hover {
        background: #fff;
        box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    }

    .assistenza-content table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 8px 0;
        border-bottom: 1px solid #f0f0f0;
        overflow: visible;
    }

    .assistenza-content table tbody td:last-child {
        border-bottom: none;
    }

    .assistenza-content table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #666;
        font-size: 0.8rem;
        text-transform: uppercase;
        flex-shrink: 0;
        margin-right: 12px;
    }

    /* Prima cella = brand/titolo */
    .assistenza-content table tbody td:first-child {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
        color: #fff;
        margin: -16px -16px 12px -16px;
        padding: 14px 16px;
        border-radius: 12px 12px 0 0;
        font-size: 1rem;
    }

    .assistenza-content table tbody td:first-child::before {
        display: none;
    }

    /* Codici su mobile */
    .assistenza-content table tbody td:last-child {
        flex-wrap: wrap;
        gap: 6px;
    }

    .product-code {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    /* Preview su mobile - fixed bottom sheet */
    .product-preview {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: translateY(100%) !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 20px 20px 0 0;
        padding: 24px 20px;
        max-height: 75vh;
        overflow-y: auto;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.25);
    }

    .product-preview.show {
        transform: translateY(0) !important;
    }

    .product-preview::after {
        display: none;
    }

    .product-preview-close {
        display: flex;
        position: absolute;
        top: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
    }

    .product-preview-image {
        height: 180px;
        margin-bottom: 16px;
    }

    .product-preview-title {
        font-size: 1rem;
        max-height: none;
    }

    .product-preview-btn {
        padding: 14px 20px;
        font-size: 1rem;
    }
}

/* ===========================================
   OVERLAY MOBILE
   =========================================== */
.product-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.product-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ===========================================
   FIX OVERFLOW per preview visibile
   =========================================== */
.assistenza-content,
.assistenza-content table,
.assistenza-content table tbody,
.assistenza-content table tbody tr {
    overflow: visible !important;
}
