/**
 * - TOF Checkfront Motorhomes - Expansion Pack
 * v0.7.0
 * Safe presentation-only additions for Checkfront checkout.
 */

/* Internal validation bridge - never displayed to customers. */
#cfm_checkout .tof-cf-validation-marker {
    display: none !important;
}

/* Keep Checkfront's server/API errors available, but suppress the bulky
 * generic validation summary when our inline field validation is active. */
#cfm_checkout .cfm-checkout-errors.tof-cf-inline-validation-active
.cfm-checkout-error-fields,
#cfm_checkout .cfm-checkout-errors.tof-cf-inline-validation-active
.cfm-checkout-error-terms,
#cfm_checkout .cfm-checkout-errors.tof-cf-inline-validation-active
.cfm-checkout-error-conditions,
#cfm_checkout .cfm-checkout-errors.tof-cf-inline-validation-active
.cfm-checkout-error-phone,
#cfm_checkout .cfm-checkout-errors.tof-cf-inline-validation-active
.cfm-checkout-error-email {
    display: none !important;
}

/* If all known validation rows are hidden, don't leave a blank gap above the form. */
#cfm_checkout .cfm-checkout-errors.tof-cf-hide-validation-summary {
    display: none !important;
}

/* Text inputs/selects: retain the plugin's red border but make the state a
 * little clearer and consistent. */
#cfm_checkout .tof-cf-field-error input.cfm-form-field-text,
#cfm_checkout .tof-cf-field-error select,
#cfm_checkout input.cfm-form-field-empty,
#cfm_checkout select.cfm-form-field-empty {
    border-color: #cf2e30 !important;
    box-shadow: 0 0 0 1px rgba(207, 46, 48, 0.08);
}

/* Checkbox statements become a clear, contained error target. */
#cfm_checkout .cfm-form-field-checkbox.tof-cf-field-error {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    column-gap: 8px;
    row-gap: 4px;
    border: 1px solid #cf2e30;
    border-radius: 10px;
    padding: 12px 14px;
    background: rgba(207, 46, 48, 0.045);
}

#cfm_checkout .cfm-form-field-checkbox.tof-cf-field-error input[type="checkbox"] {
    margin-top: 3px;
}

#cfm_checkout .cfm-form-field-checkbox.tof-cf-field-error .cfm-form-cb-label {
    flex: 1 1 calc(100% - 28px);
}

/* Inline explanation immediately below the field that needs attention. */
#cfm_checkout .tof-cf-inline-error {
    width: 100%;
    margin-top: 6px;
    color: #cf2e30;
    font-size: 13px;
    line-height: 1.35;
    font-weight: 500;
}

#cfm_checkout .cfm-form-field-checkbox .tof-cf-inline-error {
    flex: 1 0 100%;
    padding-left: 26px;
    margin-top: 2px;
}

#cfm_checkout .tof-cf-required-star {
    margin-left: 4px;
}

/* Focus should remain obvious when we move the customer to the first issue. */
#cfm_checkout input:not([type="radio"]):not([type="checkbox"]):focus,
#cfm_checkout select:focus,
#cfm_checkout textarea:focus {
    outline: 2px solid rgba(207, 46, 48, 0.22);
    outline-offset: 2px;
}

/* Native radios/checkboxes already have their own browser focus treatment.
 * Do not draw the generic rectangular validation focus ring around them. */
#cfm_checkout input[type="radio"]:focus,
#cfm_checkout input[type="checkbox"]:focus {
    outline: none;
}

@media (max-width: 550px) {
    #cfm_checkout .cfm-form-field-checkbox.tof-cf-field-error {
        padding: 11px 12px;
    }

    #cfm_checkout .tof-cf-inline-error {
        font-size: 12.5px;
    }
}


/* Search result nightly price — deliberately compact so it does not make the
 * existing result cards materially taller. */
#cfm_motorhomes .tof-cf-search-price {
    margin-top: 14px;
    text-align: center;
    line-height: 1.35;
}

#cfm_motorhomes .tof-cf-search-price span {
    display: block;
    font-size: 12px;
    margin-bottom: 2px;
}

#cfm_motorhomes .tof-cf-search-price strong {
    display: block;
    font-size: 16px;
    font-weight: 700;
}

#cfm_motorhomes .tof-cf-search-price-loading {
    font-size: 11px;
    opacity: 0.55;
}


/* EU Travel: replace the original one-way checkbox with a clear required
 * Yes / No decision. The hidden original checkbox still drives Checkfront's
 * existing add/remove-extra logic. */
#cfm_checkout .tof-cf-eu-original-hidden {
    display: none !important;
}

#cfm_checkout .tof-cf-eu-choice {
    margin: 12px 0 18px;
    padding: 0;
}

#cfm_checkout .tof-cf-eu-question {
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.4;
}

#cfm_checkout .tof-cf-eu-options {
    display: flex;
    gap: 10px;
    max-width: 330px;
}

#cfm_checkout .tof-cf-eu-option {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid #d9d9d9;
    border-radius: 10px;
    cursor: pointer;
    background: #fff;
}

#cfm_checkout .tof-cf-eu-option:has(input:checked) {
    border-color: #6bb52a;
    box-shadow: 0 0 0 1px rgba(107, 181, 42, 0.12);
}

#cfm_checkout .tof-cf-eu-option input[type="radio"] {
    margin: 0;
}

#cfm_checkout .tof-cf-eu-choice.tof-cf-field-error .tof-cf-eu-options {
    padding: 8px;
    border: 1px solid #cf2e30;
    border-radius: 12px;
    background: rgba(207, 46, 48, 0.045);
}

#cfm_checkout .tof-cf-eu-choice .tof-cf-inline-error {
    padding-left: 0;
    margin-top: 7px;
}

@media (max-width: 550px) {
    #cfm_checkout .tof-cf-eu-options {
        max-width: none;
    }
}


/* -------------------------------------------------------------------------
 * Payment journey UX
 * Keeps the existing Checkfront/WooCommerce/Stripe architecture intact.
 * ---------------------------------------------------------------------- */
.tof-cf-payment-transition {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(255,255,255,0.96);
    opacity: 0;
    visibility: hidden;
    transition: opacity 160ms ease, visibility 160ms ease;
}

.tof-cf-payment-transition.tof-cf-payment-transition-visible {
    opacity: 1;
    visibility: visible;
}

body.tof-cf-payment-transitioning {
    overflow: hidden;
}

.tof-cf-payment-transition-card {
    width: min(460px, 100%);
    text-align: center;
    padding: 38px 32px;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 14px 50px rgba(0,0,0,0.10);
}

.tof-cf-payment-spinner {
    width: 44px;
    height: 44px;
    margin: 0 auto 20px;
    border: 4px solid #e8e8e8;
    border-top-color: #699e28;
    border-radius: 50%;
    animation: tof-cf-payment-spin 0.8s linear infinite;
}

@keyframes tof-cf-payment-spin {
    to { transform: rotate(360deg); }
}

.tof-cf-payment-transition-title {
    font-size: 22px;
    line-height: 1.25;
    font-weight: 700;
    margin-bottom: 8px;
}

.tof-cf-payment-transition-text {
    font-size: 14px;
    line-height: 1.5;
    color: #666;
}

/* Final payment page becomes a deliberate third/final step rather than raw
 * WooCommerce controls appearing underneath the booking summary. */
body.tof-cf-payment-loading #cfm_payment .cfm-payment-wc {
    min-height: 220px;
    position: relative;
    overflow: hidden;
}

body.tof-cf-payment-loading #cfm_payment .cfm-payment-wc > *:not(.tof-cf-secure-payment-heading) {
    opacity: 0;
    pointer-events: none;
}

body.tof-cf-payment-loading #cfm_payment .cfm-payment-wc::after {
    content: 'Loading secure payment…';
    position: absolute;
    inset: 105px 20px auto 20px;
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: #f7f8f6;
    color: #666;
    font-size: 14px;
    font-weight: 600;
}

#cfm_payment .cfm-payment-wc.tof-cf-payment-stage-card {
    position: relative !important;
    top: auto !important;
    padding: 24px !important;
    margin-top: 16px;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: opacity 180ms ease;
}

#cfm_payment .tof-cf-secure-payment-heading {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e7e7e7;
}

#cfm_payment .tof-cf-secure-payment-kicker {
    margin-bottom: 4px;
    color: #699e28;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

#cfm_payment .tof-cf-secure-payment-title {
    font-size: 21px;
    line-height: 1.25;
    font-weight: 700;
    color: #222;
}

#cfm_payment .tof-cf-secure-payment-text {
    margin-top: 6px;
    font-size: 13.5px;
    line-height: 1.45;
    color: #666;
}

/* CFM hides the gateway title but leaves its native radio control behind on
 * the final payment step. Hide that redundant selector; the chosen gateway is
 * already fixed by CFM's server-side payment type. */
#cfm_payment .cfm-payment-wc.tof-cf-payment-stage-card .wc_payment_method > input[type="radio"],
#cfm_payment .cfm-payment-wc.tof-cf-payment-stage-card .wc_payment_method > label,
#cfm_payment .cfm-payment-wc.tof-cf-payment-stage-card .wc-block-components-radio-control__input,
#cfm_payment .cfm-payment-wc.tof-cf-payment-stage-card .wc-block-components-radio-control__label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

#cfm_payment .cfm-payment-wc.tof-cf-payment-stage-card fieldset,
#cfm_payment .cfm-payment-wc.tof-cf-payment-stage-card #payment,
#cfm_payment .cfm-payment-wc.tof-cf-payment-stage-card .wc-block-components-sidebar-layout {
    border-radius: 14px;
    box-shadow: none;
}

#cfm_payment .cfm-payment-wc.tof-cf-payment-stage-card #payment {
    padding: 0;
}

#cfm_payment .cfm-payment-wc.tof-cf-payment-stage-card fieldset {
    border-color: #dedede;
    margin-bottom: 16px;
}

#cfm_payment #place_order,
#cfm_payment .wc-block-components-checkout-place-order-button {
    width: 100%;
    min-height: 52px;
    border: 0 !important;
    border-radius: 10px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
}

#cfm_payment #cfm_pay_select {
    margin-top: 8px;
    background: transparent !important;
    color: #555 !important;
    text-decoration: underline;
    font-size: 13px;
    padding: 8px 0 !important;
}

@media (max-width: 880px) {
    #cfm_payment .cfm-payment-wc.tof-cf-payment-stage-card {
        padding: 18px !important;
    }

    .tof-cf-payment-transition-card {
        padding: 30px 22px;
    }
}

/* v0.7.1 — immediate feedback on the details -> payment hand-off. */
.cfm-form-button-text.tof-cf-submit-loading {
    cursor: wait;
    pointer-events: none;
    opacity: 0.92;
}

.tof-cf-inline-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 16px;
    animation: tofCfInlineSpin 0.7s linear infinite;
}

@keyframes tofCfInlineSpin {
    to { transform: rotate(360deg); }
}


/* -------------------------------------------------------------------------
 * v0.8.0 — Booking confirmation overhaul + Booking Hub hand-off
 * ---------------------------------------------------------------------- */
body.tof-cf-confirmation-page .cfm-top-banner-wrapper,
body.tof-cf-confirmation-page #cfm_recieved {
    width: min(920px, calc(100% - 40px));
    margin-left: auto;
    margin-right: auto;
}

body.tof-cf-confirmation-page .cfm-top-banner-wrapper {
    margin-bottom: 20px;
}

body.tof-cf-confirmation-page .cfm-top-banner {
    padding: 36px 40px;
}

body.tof-cf-confirmation-page .cfm-top-banner-header,
body.tof-cf-confirmation-page .cfm-top-banner-text {
    margin-bottom: 8px;
}

body.tof-cf-confirmation-page .cfm-top-banner-h1 {
    font-size: clamp(30px, 4vw, 40px);
}

body.tof-cf-confirmation-page #cfm_recieved {
    padding-bottom: 20px;
}

body.tof-cf-confirmation-page #cfm_recieved .tof-cf-confirmation-reference {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0 0 20px;
    padding: 10px 14px;
    border-radius: 999px;
    background: #f2f5f1;
    color: #333;
    font-size: 14px;
    font-weight: 600;
}

body.tof-cf-confirmation-page #cfm_recieved .tof-cf-confirmation-reference span {
    font-weight: 800;
}

.tof-cf-booking-hub-confirmation {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    margin: 0 0 26px;
    padding: 22px 24px;
    border: 1px solid #dce8d4;
    border-radius: 18px;
    background: #f7fbf4;
}

.tof-cf-booking-hub-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #76bd2a;
    color: #fff;
    font-size: 22px;
    font-weight: 800;
}

.tof-cf-booking-hub-kicker {
    margin-bottom: 3px;
    color: #5f9f22;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .055em;
}

.tof-cf-booking-hub-copy h2 {
    margin: 0 0 6px;
    font-size: 20px;
    line-height: 1.25;
}

.tof-cf-booking-hub-copy p {
    margin: 0;
    color: #4f4f4f;
    font-size: 14px;
    line-height: 1.5;
}

.tof-cf-booking-hub-copy .tof-cf-booking-hub-access {
    margin-top: 5px;
    color: #666;
    font-size: 12.5px;
}

.tof-cf-booking-hub-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    background: #76bd2a;
    color: #fff !important;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none !important;
    white-space: nowrap;
}

.tof-cf-booking-hub-button:hover,
.tof-cf-booking-hub-button:focus {
    background: #67a923;
    color: #fff !important;
}

body.tof-cf-confirmation-page #cfm_recieved .tof-cf-confirmation-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 28px;
    align-items: start;
}

body.tof-cf-confirmation-page #cfm_recieved .cfm-recieved-column1 {
    gap: 18px;
}

body.tof-cf-confirmation-page #cfm_recieved .cfm-recieved-module,
body.tof-cf-confirmation-page #cfm_recieved .cfm-recieved-contacts,
body.tof-cf-confirmation-page #cfm_recieved .tof-cf-confirmation-next {
    padding: 20px 22px;
    border: 1px solid #ececec;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,.035);
}

body.tof-cf-confirmation-page #cfm_recieved .cfm-recieved-contacts {
    margin-top: -6px;
}

body.tof-cf-confirmation-page #cfm_recieved .cfm-recieved-module {
    gap: 12px;
}

body.tof-cf-confirmation-page #cfm_recieved .cfm-order-recieved-title,
body.tof-cf-confirmation-page #cfm_recieved .cfm-recieved-title {
    margin: 0;
    font-size: 21px;
    line-height: 1.25;
    font-weight: 700;
}

body.tof-cf-confirmation-page #cfm_recieved .cfm-recieved-row {
    line-height: 1.6;
}

body.tof-cf-confirmation-page #cfm_recieved .cfm-recieved-column2 {
    position: sticky;
    top: 110px;
    padding: 22px;
    border-radius: 18px;
    background: #f7f8f7;
}

body.tof-cf-confirmation-page #cfm_recieved .cfm-booking-image {
    max-width: 100%;
}

body.tof-cf-confirmation-page #cfm_recieved .cfm-booking-img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    margin: 0 auto;
}

body.tof-cf-confirmation-page #cfm_recieved .tof-cf-confirmation-next {
    gap: 10px;
    margin-top: 24px;
    padding: 22px 24px;
}

body.tof-cf-confirmation-page #cfm_recieved .cfm-recieved-text {
    font-size: 14px;
    line-height: 1.6;
}

@media (max-width: 880px) {
    body.tof-cf-confirmation-page .cfm-top-banner-wrapper,
    body.tof-cf-confirmation-page #cfm_recieved {
        width: min(100% - 28px, 680px);
    }

    .tof-cf-booking-hub-confirmation {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .tof-cf-booking-hub-button {
        grid-column: 1 / -1;
        width: 100%;
    }

    body.tof-cf-confirmation-page #cfm_recieved .tof-cf-confirmation-main {
        grid-template-columns: 1fr;
    }

    body.tof-cf-confirmation-page #cfm_recieved .cfm-recieved-column2 {
        position: static;
        grid-row: 1;
        max-width: 360px;
        margin: 0 auto;
    }
}

@media (max-width: 550px) {
    body.tof-cf-confirmation-page .cfm-top-banner-wrapper {
        display: block;
    }

    body.tof-cf-confirmation-page .cfm-top-banner {
        padding: 26px 24px;
    }

    body.tof-cf-confirmation-page #cfm_recieved .tof-cf-confirmation-reference {
        margin-top: 4px;
    }

    .tof-cf-booking-hub-confirmation {
        grid-template-columns: 1fr;
        padding: 20px;
    }

    .tof-cf-booking-hub-icon {
        width: 38px;
        height: 38px;
    }

    body.tof-cf-confirmation-page #cfm_recieved .cfm-recieved-module,
    body.tof-cf-confirmation-page #cfm_recieved .cfm-recieved-contacts,
    body.tof-cf-confirmation-page #cfm_recieved .tof-cf-confirmation-next {
        padding: 18px;
    }
}
