/* ============================================
   STILI CARRELLO - Blocksy Child
   ============================================ */

/* ============================================
   PAGINA CARRELLO (/cart)
   ============================================ */

/* Container principale */
.woocommerce-cart .woocommerce {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px;
}

/* Titolo pagina carrello */
.woocommerce-cart .woocommerce h1,
.woocommerce-cart .woocommerce .cart_totals h2 {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    color: #192a3d;
}

/* Tabella carrello */
.woocommerce-cart table.shop_table {
    border: none !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06) !important;
    margin-bottom: 30px !important;
}

.woocommerce-cart table.shop_table thead {
    background: #f7f9fc;
}

.woocommerce-cart table.shop_table thead th {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    color: #192a3d;
    padding: 16px 20px;
    border: none !important;
    text-transform: none;
}

.woocommerce-cart table.shop_table tbody td {
    padding: 20px;
    border: none !important;
    border-bottom: 1px solid #eee !important;
    vertical-align: middle;
}

.woocommerce-cart table.shop_table tbody tr:last-child td {
    border-bottom: none !important;
}

/* Immagine prodotto nel carrello */
.woocommerce-cart table.shop_table .product-thumbnail img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
}

/* Nome prodotto */
.woocommerce-cart table.shop_table .product-name a {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    color: #192a3d;
    text-decoration: none;
    transition: color 0.2s ease;
}

.woocommerce-cart table.shop_table .product-name a:hover {
    color: #2872fa;
}

/* Prezzo */
.woocommerce-cart table.shop_table .product-price,
.woocommerce-cart table.shop_table .product-subtotal {
    font-weight: 600;
    color: #2872fa;
}

/* Pulsante rimuovi nella pagina carrello */
.woocommerce-cart table.shop_table .product-remove a.remove {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    background: #e8eaed !important;
    border-radius: 50% !important;
    color: #ff4d4f !important;
    text-decoration: none !important;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease !important;
    font-size: 16px !important;
    margin-inline-start: 0 !important;
    padding-inline-start: 0 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

.woocommerce-cart table.shop_table .product-remove a.remove svg {
    display: block;
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.woocommerce-cart table.shop_table .product-remove a.remove:hover {
    background: #ff4d4f !important;
    color: #fff !important;
    transform: scale(1.1) !important;
    box-shadow: 0 2px 8px rgba(255, 77, 79, 0.4) !important;
}

/* Nascondi form codice promozionale */
.woocommerce-cart .coupon,
.woocommerce-cart .cart-collaterals .cart_totals .coupon,
.woocommerce-cart form.checkout_coupon,
.woocommerce-cart .woocommerce-form-coupon-toggle,
.woocommerce-cart .woocommerce-form-coupon {
    display: none !important;
}

/* Totali carrello */
.woocommerce-cart .cart_totals {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
}

.woocommerce-cart .cart_totals h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
}

.woocommerce-cart .cart_totals table {
    border: none !important;
}

.woocommerce-cart .cart_totals table td,
.woocommerce-cart .cart_totals table th {
    padding: 14px 16px !important;
    border: none !important;
    border-bottom: 1px solid #eee !important;
}

.woocommerce-cart .cart_totals table tr:last-child td,
.woocommerce-cart .cart_totals table tr:last-child th {
    border-bottom: none !important;
}

.woocommerce-cart .cart_totals .order-total .woocommerce-Price-amount {
    font-size: 1.4rem;
    font-weight: 700;
    color: #2872fa;
}

/* Pulsante Checkout */
.woocommerce-cart .wc-proceed-to-checkout .checkout-button {
    display: block !important;
    width: 100% !important;
    padding: 16px 24px !important;
    background: #2872fa !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    font-family: 'Nunito Sans', sans-serif !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    text-align: center !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    margin-top: 20px !important;
}

.woocommerce-cart .wc-proceed-to-checkout .checkout-button:hover {
    background: #1a5ed8 !important;
}

/* Pulsante aggiorna carrello - NASCOSTO */
.woocommerce-cart button[name='update_cart'],
.woocommerce-cart .actions .coupon + button {
    display: none !important;
}

/* Fix: Nascondi duplicato "carrello vuoto" */
.woocommerce-cart .cart-empty.woocommerce-info ~ .cart-empty.woocommerce-info,
.woocommerce-cart .cart-empty + .cart-empty,
.woocommerce-cart p.cart-empty:not(:first-of-type) {
    display: none !important;
}

/* Nascondi anche il secondo blocco return-to-shop se duplicato */
.woocommerce-cart .return-to-shop ~ .return-to-shop {
    display: none !important;
}

/* Carrello vuoto styling - migliorato */
.woocommerce-cart .cart-empty {
    text-align: center;
    padding: 60px 40px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    position: relative; /* Ensure stacking context */
    z-index: 1;
}

/* Reset specifico per woocommerce-info::before per evitare sovrapposizioni */
.woocommerce-cart .cart-empty.woocommerce-info::before {
    content: '';
    display: block !important;
    position: static !important; /* Reset absolute positioning di default */
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, #f8f9fc 0%, #e8f1ff 100%);
    border-radius: 50%;
    margin: 0 auto 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24' fill='none' stroke='%232872fa' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='21' r='1'/%3E%3Ccircle cx='20' cy='21' r='1'/%3E%3Cpath d='M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 48px;
    left: auto !important;
    top: auto !important;
    transform: none !important;
}

.woocommerce-cart .cart-empty.woocommerce-info {
    font-family: 'Nunito', sans-serif;
    font-size: 1.3rem;
    font-weight: 600;
    color: #192a3d;
    border: none;
    background-color: #fff;
    padding-left: 40px !important; /* Reset padding left che WC aggiunge per l'icona */
    padding-right: 40px !important;
}

.woocommerce-cart .cart-empty.woocommerce-info::after {
    content: 'Inizia ad esplorare i nostri servizi!';
    display: block;
    font-size: 1rem;
    font-weight: 400;
    color: #666;
    margin-top: 8px;
}

.woocommerce-cart .return-to-shop {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.woocommerce-cart .return-to-shop .button {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    padding: 16px 32px !important;
    background: #2872fa !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 1.1rem !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 4px 12px rgba(40, 114, 250, 0.3);
}

.woocommerce-cart .return-to-shop .button:hover {
    background: #1a5ed8 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(40, 114, 250, 0.4);
}

/* ============================================
   MESSAGGIO ANNULLA RIMOZIONE
   ============================================ */
.woocommerce-cart .woocommerce-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    background: #fff8e6;
    border: 1px solid #ffe0a3;
    border-left: 4px solid #ff9800;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 24px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    color: #5d4e37;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    position: relative;
}

/* Fix overlap icona su messaggio */
.woocommerce-cart .woocommerce-message::before {
    content: none !important;
    display: none !important;
}

.woocommerce-cart .woocommerce-message .restore-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ff9800;
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.woocommerce-cart .woocommerce-message .restore-item:hover {
    background: #f57c00;
    transform: translateY(-1px);
}

/* ============================================
   RESPONSIVE CARRELLO
   ============================================ */
@media (max-width: 768px) {
    .ct-cart-content,
    #mini-cart-panel {
        min-width: 300px !important;
        max-width: calc(100vw - 40px) !important;
    }

    .ct-woocommerce-cart-form {
        gap: 0px !important;
    }

    /* Tabella diventa lista di card */
    .woocommerce-cart table.shop_table {
        display: block;
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    .woocommerce-cart table.shop_table thead {
        display: none;
    }

    .woocommerce-cart table.shop_table tbody {
        display: block;
    }

    /* Ogni riga è una card */
    .woocommerce-cart table.shop_table tbody tr {
        display: grid;
        grid-template-columns: 80px 1fr;
        grid-template-areas:
            'image name'
            'image price'
            'image subtotal';
        gap: 10px 15px;
        background: #fff;
        padding: 20px;
        margin-bottom: 15px;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        position: relative; /* Per posizionare il tasto rimuovi */
        border: 1px solid #eee;
    }

    .woocommerce-cart table.shop_table tbody td {
        display: block;
        padding: 0 !important;
        border: none !important;
    }

    /* Immagine */
    .woocommerce-cart table.shop_table tbody td.product-thumbnail {
        grid-area: image;
    }

    .woocommerce-cart table.shop_table .product-thumbnail img {
        width: 80px;
        height: 80px;
        border-radius: 8px;
    }

    /* Nome prodotto */
    .woocommerce-cart table.shop_table tbody td.product-name {
        grid-area: name;
        padding-right: 30px !important; /* Spazio per tasto rimuovi */
    }

    .woocommerce-cart table.shop_table .product-name a {
        font-size: 1.1rem;
        line-height: 1.3;
        display: block;
    }

    /* Prezzo */
    .woocommerce-cart table.shop_table tbody td.product-price {
        grid-area: price;
        font-size: 0.95rem;
        color: #666;
    }

    /* Subtotale */
    .woocommerce-cart table.shop_table tbody td.product-subtotal {
        grid-area: subtotal;
        font-size: 1.1rem;
        font-weight: 700;
        color: #2872fa;
        align-self: end;
    }

    /* Tasto Rimuovi - Posizionato in alto a destra */
    .woocommerce-cart table.shop_table tbody td.product-remove {
        position: absolute;
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
        padding: 0 !important;
        z-index: 2;
    }

    .woocommerce-cart table.shop_table .product-remove a.remove {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 32px !important;
        height: 32px !important;
        background: #e8eaed !important;
        color: #ff4d4f !important;
        font-size: 16px !important;
        border-radius: 50% !important;
        padding: 0 !important;
        margin: 0 !important;
        margin-inline-start: 0 !important;
        padding-inline-start: 0 !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
        transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease !important;
    }

    .woocommerce-cart table.shop_table .product-remove a.remove:hover {
        background: #ff4d4f !important;
        color: #fff !important;
        transform: scale(1.1) !important;
        box-shadow: 0 2px 8px rgba(255, 77, 79, 0.4) !important;
    }

    .woocommerce-cart table.shop_table .product-remove a.remove svg {
        display: block;
        width: 14px;
        height: 14px;
        fill: currentColor;
    }

    /* Nascondi righe che non sono prodotti (es. azioni carrello) */
    .woocommerce-cart table.shop_table tbody tr:not(.cart_item) {
        display: none;
    }

    /* Nascondi quantità se non serve o gestiscila se presente */
    .woocommerce-cart table.shop_table tbody td.product-quantity {
        display: none; /* Se vendi servizi singoli */
    }

    /* Ripristino stile Totali su mobile */
    .woocommerce-cart .cart-collaterals,
    .woocommerce-cart .cart_totals {
        width: 100% !important;
        float: none !important;
        clear: both;
        margin-top: 20px;
    }

    .woocommerce-cart .cart_totals {
        background: #fff !important;
        border-radius: 12px !important;
        padding: 24px !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06) !important;
    }

    /* Forza visualizzazione tabella totali */
    .woocommerce-cart .cart_totals table.shop_table {
        display: table !important;
        width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        background: transparent !important;
        margin: 0 !important;
        border-collapse: separate !important;
        border-spacing: 0 !important;
    }

    .woocommerce-cart .cart_totals table.shop_table tbody {
        display: table-row-group !important;
    }

    .woocommerce-cart .cart_totals table.shop_table tr {
        display: table-row !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .woocommerce-cart .cart_totals table.shop_table th,
    .woocommerce-cart .cart_totals table.shop_table td {
        display: table-cell !important;
        padding: 16px 0 !important;
        text-align: right !important;
        border: none !important;
        border-bottom: 1px solid #eee !important;
        vertical-align: middle !important;
    }

    /* Rimuovi etichette duplicate generate da WooCommerce su mobile */
    .woocommerce-cart .cart_totals table.shop_table td::before {
        content: none !important;
        display: none !important;
    }

    .woocommerce-cart .cart_totals table.shop_table th {
        text-align: left !important;
        font-weight: 600;
        color: #192a3d;
        width: 40%;
        font-family: 'Nunito', sans-serif;
    }

    .woocommerce-cart .cart_totals table.shop_table tr:last-child th,
    .woocommerce-cart .cart_totals table.shop_table tr:last-child td {
        border-bottom: none !important;
    }
}
