/**
 * ================================================
 * BENESSENCE - CHECKOUT CUSTOM CSS
 * ================================================
 * Custom styling for WooCommerce Checkout
 * - 60% / 40% layout (desktop)
 * - Sticky order review
 * - Responsive mobile
 */

/* ========================================
   CHECKOUT HEADER (LOGO CENTRATO)
   ======================================== */

.benessence-checkout-header {
    background-color: #4da585;
    border-bottom: 1px solid #DAF6DD;
    padding: 20px 0;
    margin-bottom: 30px;
}

.checkout-logo-wrapper {
    text-align: center;
}

.checkout-logo-wrapper a {
    display: inline-block;
}

.checkout-logo-wrapper img {
    max-height: 60px;
    width: auto;
}

/* ========================================
   CONTAINER E LAYOUT PRINCIPALE
   ======================================== */

/* Prevent horizontal scroll on mobile */
@media (max-width: 767px) {

    body.woocommerce-checkout,
    html {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
}

#ship-to-different-address {
    margin: 0 !important;
}

.shipping_address {
    padding-top: 25px;
}

#billing_address_2_field .optional {
    display: none !important;
}

.ppcp-messages {
    display: none !important;
}

.select2-selection__rendered {
    padding: 0 15px !important;
}

/* Hide "Spedizione" label before shipping methods */
.benessence-total-value>#shipping_method::before {
    display: none !important;
}

.benessence-total-value {
    font-size: 0;
    /* Hide text nodes */
}

.benessence-total-value #shipping_method {
    font-size: 14px;
    /* Restore font size for shipping methods */
}

.stripe-cards-icon {
    width: 60px;
}

.optional {
    font-size: 14px;
}

.woocommerce-remove-coupon {
    font-size: 14px;
    color: #4da585;
}

#coupon_code {
    padding: 16px !important;
}

@media (max-width: 767px) {

    #wc-stripe-express-checkout-element {
        padding: 0 15px;
        max-width: 100%;
        overflow-x: hidden;
    }

    #order_review {
        margin-top: -65px;
        padding: 23px 15px;
        overflow-x: hidden;
    }

    #order_review_heading {
        padding: 15px;
    }

    .benessence-order-review-wrapper {
        margin-top: 5px;
        padding: 23px 0px;
        overflow-x: hidden;
    }

    .woocommerce-checkout {
        overflow-x: hidden !important;
    }

    .benessence-checkout-form {
        overflow-x: hidden !important;
    }
}

.benessence-checkout-form {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Grid a 2 colonne - Desktop */
.benessence-checkout-grid {
    display: grid;
    grid-template-columns: 60fr 40fr;
    gap: 30px;
    align-items: start;
}

/* Mobile: stack verticale */
@media (max-width: 767px) {
    .benessence-checkout-grid {
        display: flex;
        flex-direction: column-reverse;
        /* Carrello prima su mobile */
        gap: 20px;
    }
}

/* Colonne */
.benessence-checkout-column {
    background: #fff;
}

.benessence-checkout-left {
    padding: 0;
}

.benessence-checkout-right {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

@media (max-width: 767px) {
    .benessence-checkout-right {
        position: relative;
        top: 0;
        max-height: none;
    }
}

/* ========================================
   SEZIONI FORM
   ======================================== */

.woocommerce-billing-fields,
.woocommerce-shipping-fields,
#payment {
    background: #f9f9f9;
    padding: 20px;
    margin-bottom: 15px;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    /* Ridotto da 10px */
}

.woocommerce-billing-fields .woocommerce-billing-fields {
    background-color: #fff;
}

.woocommerce-shipping-fields .woocommerce-shipping-fields {
    background-color: #fff;
}

#payment {
    background-color: #f9f9f9 !important;
}

.woocommerce-billing-fields h3,
.woocommerce-shipping-fields h3,
#payment h3,
.benessence-order-review-heading {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1D3653;
}

/* ========================================
   FORM FIELDS
   ======================================== */

.form-row {
    margin-bottom: 12px;
    /* Ridotto da 20px */
}

.form-row label {
    display: block;
    margin-bottom: 5px;
    /* Ridotto da 8px */
    font-weight: 500;
    font-size: 14px;
    color: #1D3653;
}

.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="tel"],
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 10px 12px;
    /* Ridotto da 12px 15px */
    border: 1px solid #ddd;
    border-radius: 4px;
    /* Ridotto da 6px */
    font-size: 14px;
    transition: border 0.3s ease;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: none;
    border-color: #4CA585;
}

/* Nome e Cognome affiancati */
.woocommerce-billing-fields__field-wrapper,
.woocommerce-shipping-fields__field-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    /* Ridotto da 15px */
}

.form-row.form-row-wide {
    grid-column: 1 / -1;
}

@media (max-width: 767px) {

    .woocommerce-billing-fields__field-wrapper,
    .woocommerce-shipping-fields__field-wrapper {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   ORDER REVIEW (Carrello)
   ======================================== */

/* ACCORDION MOBILE per carrello */
@media (max-width: 767px) {
    .benessence-order-review-heading {
        cursor: pointer;
        position: relative;
        padding-right: 30px;
        user-select: none;
    }

    .benessence-order-review-heading::after {
        content: '+';
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 24px;
        font-weight: 300;
        transition: transform 0.3s ease;
    }

    .benessence-order-review-heading.active::after {
        content: '−';
    }

    .benessence-order-review {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .benessence-order-review.active {
        max-height: 2000px;
        /* Valore grande per contenere tutto */
    }
}

#shipping_method li label {
    font-size: 14px;
}

.benessence-total-value {
    font-size: 14px;
}

.includes_tax {
    font-size: 14px !important;
    font-weight: 400 !important;
}

.benessence-order-review {
    background: #fff;
    padding: 20px;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    /* Ridotto da 10px */
}

/* Items del carrello */
.benessence-cart-items {
    margin-bottom: 15px;
    /* Ridotto da 20px */
}

.benessence-cart-item {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 12px;
    /* Ridotto da 15px */
    padding: 12px 0;
    /* Ridotto da 15px */
    border-bottom: 1px solid #f0f0f0;
}

.benessence-cart-item:last-child {
    border-bottom: none;
}

.benessence-cart-item-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    /* Ridotto da 6px */
    border: 1px solid #e5e5e5;
}

.benessence-cart-item-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.benessence-cart-item-name {
    font-weight: 600;
    font-size: 14px;
    color: #1D3653;
}

.benessence-cart-item-quantity {
    font-size: 13px;
    color: #666;
}

.benessence-cart-item-meta {
    font-size: 12px;
    color: #888;
}

.benessence-cart-item-meta dl {
    margin: 0;
}

.benessence-cart-item-price {
    font-weight: 600;
    font-size: 15px;
    color: #1D3653;
    display: flex;
    align-items: center;
}

/* Totali */
.benessence-cart-totals {
    border-top: 2px solid #e5e5e5;
    padding-top: 15px;
    /* Ridotto da 20px */
    margin-top: 15px;
    /* Ridotto da 20px */
}

.benessence-total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    /* Ridotto da 12px */
    font-size: 14px;
    gap: 10px;
}

.benessence-total-label {
    color: #000;
}

.benessence-total-value {
    font-weight: 600;
    color: #1D3653;
}

/* Totale finale */
.benessence-total-row.order-total {
    border-top: 2px solid #1D3653;
    padding-top: 12px;
    /* Ridotto da 15px */
    margin-top: 8px;
    /* Ridotto da 10px */
    font-size: 18px;
}

.benessence-total-row.order-total .benessence-total-value {
    color: #000;
}

/* ========================================
   PAYMENT METHODS
   ======================================== */

#payment {
    margin-top: 15px;
    /* Ridotto da 20px */
}

.woocommerce-terms-and-conditions-link {
    color: #4da585;
    font-size: 16px !important;
}

.woocommerce-checkout #payment ul.payment_methods {
    list-style: none;
    padding: 0;
    margin: 0 0 15px 0;
    /* Ridotto da 20px */
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    /* Ridotto da 8px */
    overflow: hidden;
}

.woocommerce-checkout #payment ul.payment_methods li {
    padding: 12px 15px;
    /* Ridotto da 15px 20px */
    border-bottom: 1px solid #e5e5e5;
    cursor: pointer;
    transition: background 0.2s ease;
}

.woocommerce-checkout #payment ul.payment_methods li:last-child {
    border-bottom: none;
}

.woocommerce-checkout #payment ul.payment_methods li:hover {
    background: #f9f9f9;
}

.woocommerce-checkout #payment ul.payment_methods li.wc_payment_method input {
    margin-right: 8px;
}

.wc_payment_method {
    background-color: #fff;
}

.woocommerce-checkout #payment ul.payment_methods li label {
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
}

.woocommerce-checkout #payment div.payment_box {
    background: #DAF6DD;
    padding: 15px;
    /* Ridotto da 20px */
    margin: 10px 0;
    /* Ridotto da 15px */
    border-radius: 4px;
    /* Ridotto da 6px */
    font-size: 14px !important;
}

div.payment_box::before {
    display: none !important;
}

div.payment_box p {
    font-size: 14px !important;
}

/* Place Order Button */
#place_order {
    width: 100%;
    padding: 15px 25px;
    /* Ridotto da 18px 30px */
    background: #4CA585;
    color: #fff;
    border: none;
    border-radius: 6px;
    /* Ridotto da 8px */
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

#place_order:hover {
    background: #3d8a6d;
}

/* ========================================
   COUPON SECTION
   ======================================== */


.benessence-coupon-desktop {
    display: block;
    margin-top: 15px;
    /* Ridotto da 20px */
    padding: 15px;
    /* Ridotto da 20px */
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    /* Ridotto da 8px */
}


.checkout_coupon {
    padding: 15px;
    /* Ridotto da 20px */
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    /* Ridotto da 6px */
    margin-top: 10px;
    /* Ridotto da 15px */
}

.checkout_coupon p {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #666;
}

.checkout_coupon input[type="text"] {
    width: calc(100% - 120px);
    padding: 10px 12px;
    /* Ridotto da 12px 15px */
    border: 1px solid #ddd;
    border-radius: 4px;
    /* Ridotto da 6px */
    font-size: 14px;
    margin-right: 8px;
}

.checkout_coupon button {
    padding: 10px 20px;
    /* Ridotto da 12px 25px */
    background: #4CA585;
    color: #fff;
    border: none;
    border-radius: 4px;
    /* Ridotto da 6px */
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

.checkout_coupon button:hover {
    background: #3d8a6d;
}

/* Nascondi i messaggi coupon duplicati creati da WooCommerce prima del form */
.woocommerce-form-coupon-toggle,
.woocommerce-additional-fields .showcoupon {
    display: none !important;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 767px) {
    .benessence-checkout-form {
        padding: 10px;
    }

    .woocommerce-billing-fields,
    .woocommerce-shipping-fields,
    #payment,
    .benessence-order-review {
        padding: 15px;
        /* Ridotto da 20px */
        margin-bottom: 12px;
        /* Ridotto da 15px */
    }

    .benessence-cart-item {
        grid-template-columns: 50px 1fr auto;
        gap: 10px;
        /* Ridotto da 12px */
    }
}

/* ========================================
   PAYMENT SECTION FULL WIDTH (in fondo)
   ======================================== */

.benessence-checkout-payment-full {
    width: 100%;
    margin-top: 20px;
}

.benessence-checkout-payment-full #payment {
    max-width: 100%;
}

/* Place Order Button - centrato */
.benessence-checkout-payment-full #place_order {
    max-width: 400px;
    display: block;
    margin: 0 auto;
}

.benessence-checkout-payment-full .woocommerce-terms-and-conditions-wrapper {
    max-width: 800px;
    margin: 15px auto;
}

@media (max-width: 767px) {
    .benessence-checkout-payment-full {
        margin-top: 15px;
    }

    .benessence-checkout-payment-full #place_order {
        max-width: 100%;
    }
}

/* ========================================
   STRIPE PAYMENT GATEWAY FIXES
   ======================================== */

/* Hide the Stripe Link modal trigger button that appears incorrectly */
.stripe-gateway-stripelink-modal-trigger {
    display: none !important;
}

/* Ensure payment request buttons (Apple Pay / Google Pay) are visible */
#wc-stripe-payment-request-wrapper,
#wc-stripe-payment-request-button-separator {
    display: block !important;
}

#billing_first_name_field {
    width: 100%;
}

#billing_last_name_field {
    width: 100%;
}

#billing_country_field {
    width: 100%;
}

#billing_address_1_field {
    width: 100%;
}

#billing_address_2_field {
    width: 100%;
}

#billing_postcode_field {
    width: 100%;
}

#billing_city_field {
    width: 100%;
}

#billing_state_field {
    width: 100%;
}

#shipping_first_name_field {
    width: 100%;
}

#shipping_last_name_field {
    width: 100%;
}

#shipping_country_field {
    width: 100%;
}

#shipping_address_1_field {
    width: 100%;
}

#shipping_address_2_field {
    width: 100%;
}

#shipping_postcode_field {
    width: 100%;
}

#shipping_city_field {
    width: 100%;
}

#shipping_state_field {
    width: 100%;
}