/**
 * W4Y Ngonia Event Tickets Bridge
 * Correzioni UX mobile per acquisto, registrazione partecipanti e carrello ticket.
 */

@media (max-width: 1024px) {
    /* Durante l'acquisto ticket le barre del tema coprono campi e CTA. */
    body.w4y-ngonia-event-ticket-flow .w4y-mobile-quickbar,
    body.w4y-ngonia-event-ticket-flow .mobile-sticky-bar,
    body.w4y-ngonia-event-ticket-flow .social-sticky-icon,
    body.w4y-ngonia-event-ticket-flow a.ftr_btn,
    body.w4y-ngonia-event-ticket-flow .ftr_btn {
        display: none !important;
    }

    /* Annulla lo spazio riservato dal child theme alla quickbar nascosta. */
    body.w4y-ngonia-event-ticket-flow {
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Fallback nel raro caso in cui il campo legacy sia già stato renderizzato. */
    body.w4y-ngonia-event-ticket-flow #billing_numero_ombrellone_field {
        display: none !important;
    }

    /* Mantiene le azioni del ticket sopra la safe-area di iPhone/Android. */
    body.w4y-ngonia-event-ticket-flow .tribe-tickets__attendee-tickets-footer,
    body.w4y-ngonia-event-ticket-flow .tribe-tickets__registration-footer {
        position: relative;
        z-index: 2;
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 767px) {
    /* CTA più leggibili e senza sovrapposizioni nel pannello partecipanti. */
    body.w4y-ngonia-event-ticket-flow .tribe-tickets__attendee-tickets-footer {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 12px !important;
        align-items: stretch !important;
    }

    body.w4y-ngonia-event-ticket-flow .tribe-tickets__attendee-tickets-footer-divider {
        display: none !important;
    }

    body.w4y-ngonia-event-ticket-flow .tribe-tickets__attendee-tickets-footer-cart-button,
    body.w4y-ngonia-event-ticket-flow .tribe-tickets__attendee-tickets-footer-checkout-button,
    body.w4y-ngonia-event-ticket-flow .tribe-tickets__registration-submit {
        width: 100% !important;
        min-height: 52px;
        margin: 0 !important;
        box-sizing: border-box;
        text-align: center;
    }

    body.w4y-ngonia-event-ticket-flow .tribe-tickets__registration-footer {
        display: block !important;
    }

    /* --- Carrello ticket WooCommerce: layout a card più leggibile --- */
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart thead {
        display: none !important;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tbody,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item {
        position: relative;
        margin: 0 0 16px;
        padding: 16px 14px 14px;
        border: 1px solid rgba(0, 0, 0, 0.12);
        background: #fff;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td {
        padding: 0 !important;
        border: 0 !important;
        text-align: left !important;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td.product-remove {
        position: absolute;
        top: 12px;
        left: 10px;
        width: 28px;
        padding: 0 !important;
        z-index: 2;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td.product-remove a.remove {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        line-height: 28px;
        font-size: 22px;
        text-decoration: none;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td.product-thumbnail {
        display: none !important;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td.product-name {
        padding-left: 34px !important;
        margin-bottom: 10px;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td.product-name a,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td.product-name {
        font-size: 16px;
        line-height: 1.35;
        word-break: break-word;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td.product-price,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td.product-quantity,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td.product-subtotal {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding-left: 34px !important;
        margin-bottom: 10px;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td.product-price::before,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td.product-quantity::before,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr.woocommerce-cart-form__cart-item td.product-subtotal::before {
        content: attr(data-title);
        flex: 0 0 auto;
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #555;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow .eltd-quantity-buttons {
        display: inline-flex !important;
        align-items: stretch;
        float: none !important;
        margin: 0 !important;
        width: auto !important;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow .eltd-quantity-buttons .eltd-quantity-input {
        width: 54px !important;
        min-width: 54px;
        height: 44px !important;
        line-height: 44px !important;
        font-size: 20px !important;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow .eltd-quantity-buttons .eltd-quantity-control {
        width: 30px !important;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow .eltd-quantity-buttons .eltd-quantity-control .eltd-quantity-plus,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow .eltd-quantity-buttons .eltd-quantity-control .eltd-quantity-minus {
        width: 30px !important;
        line-height: 21px;
    }

    /* Riga azioni carrello più ordinata */
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow table.shop_table.shop_table_responsive.cart tr:last-child td.actions {
        padding: 8px 0 0 !important;
        border: 0 !important;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .coupon,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .eltd-cart-proceed-update {
        width: 100% !important;
        float: none !important;
        display: block !important;
        text-align: left !important;
        margin: 0 0 14px !important;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .coupon input[type="text"].input-text,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .coupon .input-text {
        width: 100% !important;
        margin: 0 0 10px !important;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .coupon .button,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .coupon input[type="submit"],
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .coupon button {
        width: 100% !important;
        margin: 0 !important;
        float: none !important;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .eltd-cart-proceed-update {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .eltd-cart-proceed-update .wc-proceed-to-checkout,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .eltd-cart-proceed-update .wc-proceed-to-checkout > * {
        width: 100%;
    }

    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .eltd-cart-proceed-update a.checkout-button,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .eltd-cart-proceed-update .button,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow td.actions .eltd-cart-proceed-update input[name="update_cart"] {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        float: none !important;
        text-align: center;
        min-height: 52px;
        box-sizing: border-box;
    }

    /* Stripe / Apple Pay / Google Pay */
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow #wc-stripe-payment-request-wrapper,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow #wcpay-payment-request-wrapper,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow .wc-proceed-to-checkout #wc-stripe-payment-request-wrapper,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow .wc-proceed-to-checkout #wcpay-payment-request-wrapper {
        width: 100% !important;
        min-width: 0;
        margin: 0 !important;
    }

    /* Totali e spedizione */
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow .cart-collaterals,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow .cart-collaterals .eltd-shipping-calculator,
    body.woocommerce-cart.w4y-ngonia-event-ticket-flow .cart-collaterals .eltd-cart-totals {
        width: 100% !important;
        float: none !important;
        display: block !important;
    }
}

/* ========================================================================
   v1.2.0 — Pagina evento singola: UX mobile premium
   ======================================================================== */

/* Gli helper aggiunti via JS restano invisibili fuori dal layout mobile. */
body.single-tribe_events .w4y-event-summary__label,
body.single-tribe_events .w4y-event-summary__price-label,
body.single-tribe_events .w4y-event-summary__cta {
    display: none;
}

@media (max-width: 767px) {
    /* Riduce il vuoto iniziale generato dal vecchio tema Chandelier. */
    body.single-tribe_events .eltd-content .eltd-content-inner > .eltd-container > .eltd-container-inner,
    body.single-tribe_events .eltd-content .eltd-content-inner > .eltd-full-width > .eltd-full-width-inner {
        padding-top: 24px !important;
        padding-bottom: 40px !important;
    }

    body.single-tribe_events #tribe-events-content.tribe-events-single {
        width: 100%;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Link di ritorno più leggibile, ma non invasivo. */
    body.single-tribe_events .tribe-events-back {
        margin: 0 0 22px !important;
    }

    body.single-tribe_events .tribe-events-back a {
        display: inline-flex;
        align-items: center;
        min-height: 38px;
        padding: 7px 12px;
        border: 1px solid rgba(90, 124, 176, 0.18);
        border-radius: 999px;
        background: #f6f8fc;
        color: #102136 !important;
        font-family: "Cabin", sans-serif;
        font-size: 14px;
        font-weight: 700;
        line-height: 1.2;
        text-decoration: none;
    }

    /* Titolo meno compresso e con gerarchia più elegante. */
    body.single-tribe_events .tribe-events-single-event-title {
        margin: 0 0 16px !important;
        color: #101827;
        font-family: "Cabin", sans-serif;
        font-size: clamp(28px, 8vw, 34px) !important;
        font-weight: 700;
        line-height: 1.14 !important;
        letter-spacing: -0.025em;
        overflow-wrap: anywhere;
    }

    /* Card riepilogo: data/orario separati chiaramente dal prezzo. */
    body.single-tribe_events .tribe-events-schedule,
    body.single-tribe_events .tribe-events-schedule.w4y-event-summary {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
        width: 100%;
        margin: 0 0 22px !important;
        padding: 16px !important;
        border: 1px solid rgba(90, 124, 176, 0.2);
        border-radius: 18px;
        background: linear-gradient(145deg, #f6f8fc 0%, #ffffff 100%);
        box-shadow: 0 14px 34px rgba(16, 33, 54, 0.09);
        box-sizing: border-box;
        overflow: hidden;
    }

    body.single-tribe_events .tribe-events-schedule > div,
    body.single-tribe_events .tribe-events-schedule .w4y-event-summary__datetime {
        display: block !important;
        width: 100%;
        margin: 0 !important;
        color: #4b5c70;
        font-family: Georgia, serif;
        font-size: 17px !important;
        font-weight: 400;
        line-height: 1.55 !important;
        box-sizing: border-box;
    }

    body.single-tribe_events .w4y-event-summary__label {
        display: block;
        margin: 0 0 5px;
        color: #5a7cb0;
        font-family: "Cabin", sans-serif;
        font-size: 11px;
        font-weight: 700;
        line-height: 1.2;
        letter-spacing: 0.12em;
        text-transform: uppercase;
    }

    /* Badge prezzo: non può più confondersi con l'orario. */
    body.single-tribe_events .tribe-events-schedule .tribe-events-cost,
    body.single-tribe_events .tribe-events-schedule .w4y-event-summary__price {
        display: inline-flex !important;
        align-items: center;
        justify-content: flex-start;
        justify-self: start;
        gap: 8px;
        width: auto !important;
        min-height: 42px;
        margin: 0 !important;
        padding: 9px 14px !important;
        float: none !important;
        border: 0;
        border-radius: 999px;
        background: #102136;
        box-shadow: 0 9px 22px rgba(16, 33, 54, 0.18);
        color: #ffffff !important;
        font-family: "Cabin", sans-serif;
        line-height: 1 !important;
        white-space: nowrap;
        box-sizing: border-box;
    }

    body.single-tribe_events .w4y-event-summary__price-label {
        display: inline-block;
        color: #d9bd9f;
        font-size: 10px;
        font-weight: 700;
        line-height: 1;
        letter-spacing: 0.09em;
        text-transform: uppercase;
    }

    body.single-tribe_events .w4y-event-summary__price-value {
        color: #ffffff;
        font-size: 18px;
        font-weight: 700;
        line-height: 1;
    }

    /* CTA inline: nessuna nuova barra fissa che possa coprire il contenuto. */
    body.single-tribe_events .w4y-event-summary__cta {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        width: 100%;
        min-height: 52px;
        padding: 12px 18px;
        border-radius: 13px;
        background: #c9a482;
        box-shadow: 0 11px 24px rgba(114, 83, 51, 0.17);
        color: #102136 !important;
        font-family: "Cabin", sans-serif;
        font-size: 13px;
        font-weight: 700;
        line-height: 1.2;
        letter-spacing: 0.08em;
        text-align: center;
        text-decoration: none !important;
        text-transform: uppercase;
        box-sizing: border-box;
        transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    }

    body.single-tribe_events .w4y-event-summary__cta::after {
        content: "→";
        font-size: 18px;
        line-height: 1;
    }

    body.single-tribe_events .w4y-event-summary__cta:active {
        transform: translateY(1px);
        box-shadow: 0 7px 16px rgba(114, 83, 51, 0.15);
    }

    /* Flyer con taglio più premium. */
    body.single-tribe_events .tribe-events-event-image {
        margin: 0 0 28px !important;
        border-radius: 18px;
        background: #f6f8fc;
        box-shadow: 0 18px 42px rgba(16, 33, 54, 0.12);
        overflow: hidden;
        transform: translateZ(0);
    }

    body.single-tribe_events .tribe-events-event-image img {
        display: block;
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    /* Testo evento più facile da leggere da smartphone. */
    body.single-tribe_events .tribe-events-single-event-description,
    body.single-tribe_events .tribe-events-single-event-description p,
    body.single-tribe_events .tribe-events-single-event-description li {
        font-size: 16px;
        line-height: 1.72;
    }

    body.single-tribe_events .tribe-events-single-event-description h2,
    body.single-tribe_events .tribe-events-single-event-description h3,
    body.single-tribe_events .tribe-events-single-event-description h4 {
        color: #102136;
        line-height: 1.25;
    }

    /* Il pulsante della card raggiunge il blocco ticket senza finire sotto l'header. */
    body.single-tribe_events #tribe-tickets__tickets-form,
    body.single-tribe_events #w4y-ngonia-ticket-area,
    body.single-tribe_events .tribe-tickets__tickets-wrapper {
        scroll-margin-top: 96px;
    }

    body.single-tribe_events .event-tickets .tribe-tickets__tickets-form,
    body.single-tribe_events .tribe-tickets__tickets-wrapper {
        border-radius: 18px !important;
        box-shadow: 0 16px 38px rgba(16, 33, 54, 0.09);
        overflow: hidden;
    }

    body.single-tribe_events .event-tickets .tribe-tickets__tickets-buy.tribe-common-c-btn {
        min-height: 50px;
        border-radius: 12px;
        background-color: #102136 !important;
    }
}

@media (max-width: 360px) {
    body.single-tribe_events .tribe-events-single-event-title {
        font-size: 27px !important;
    }

    body.single-tribe_events .tribe-events-schedule,
    body.single-tribe_events .tribe-events-schedule.w4y-event-summary {
        padding: 14px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.single-tribe_events .w4y-event-summary__cta {
        transition: none;
    }
}
