/* MT Secure Gateway - Checkout CSS styling */
.mt-gateway-form-container,
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) {
    --mt-checkout-surface: #ffffff;
    --mt-checkout-surface-muted: #f0efec;
    --mt-checkout-text: #232220;
    --mt-checkout-muted: #6e6b65;
    --mt-checkout-border: #87837c;
    --mt-checkout-accent: #292724;
    --mt-checkout-positive: #166544;
    --mt-checkout-negative: #b42318;
    --mt-checkout-negative-bg: #fff1ef;
}

.mt-gateway-form-container {
    width: 100%;
    min-width: 0;
    max-width: 500px;
    margin: 15px 0;
    padding: 20px;
    background: var(--mt-checkout-surface);
    color: var(--mt-checkout-text);
    border: 1px solid #dedbd5;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.025);
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-optical-sizing: auto;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.mt-gateway-form-container * {
    box-sizing: border-box;
}

.mt-gateway-form-container .mt-form-row {
    display: flex;
    margin-bottom: 16px;
    gap: 16px;
}

.mt-gateway-form-container .mt-form-row.two-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mt-gateway-form-container .mt-form-group {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
}

.mt-gateway-form-container .mt-form-group.full-width {
    width: 100%;
}

.mt-gateway-form-container .mt-form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--mt-checkout-text);
    margin-bottom: 6px;
    text-transform: none;
    letter-spacing: 0;
}

.mt-gateway-form-container .mt-form-group label .required {
    color: var(--mt-checkout-negative);
    margin-left: 2px;
}

.mt-gateway-form-container .mt-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
}

.mt-gateway-form-container .mt-input-wrapper input:not([type="hidden"]) {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 48px !important;
    height: auto !important;
    padding: 10px 14px !important;
    font-family: inherit !important;
    font-size: 16px !important;
    line-height: 1.5 !important;
    border: 1px solid var(--mt-checkout-border) !important;
    border-radius: 10px !important;
    background-color: var(--mt-checkout-surface) !important;
    color: var(--mt-checkout-text) !important;
    transition: border-color 0.16s ease, background-color 0.16s ease !important;
    box-shadow: none !important;
    margin: 0 !important;
}

.mt-gateway-form-container .mt-input-wrapper input:not([type="hidden"]):hover {
    border-color: var(--mt-checkout-accent) !important;
}

.mt-gateway-form-container .mt-input-wrapper input:not([type="hidden"]):focus {
    border-color: var(--mt-checkout-accent) !important;
    outline: 2px solid var(--mt-checkout-accent) !important;
    outline-offset: 2px !important;
}

.mt-gateway-form-container .mt-input-wrapper input:not([type="hidden"])::placeholder {
    color: var(--mt-checkout-muted) !important;
    opacity: 1;
}

.mt-gateway-form-container .mt-input-wrapper input:not([type="hidden"]):disabled {
    background-color: var(--mt-checkout-surface-muted) !important;
    cursor: not-allowed;
}

.mt-gateway-form-container .mt-input-wrapper input:not([type="hidden"])[readonly] {
    background-color: var(--mt-checkout-surface-muted) !important;
}

/* Card Number specific styles with Brand logo inside */
.mt-gateway-form-container .card-number-wrapper input:not([type="hidden"]) {
    padding-right: 48px !important;
}

.mt-gateway-form-container .mt-card-brand-icon {
    position: absolute;
    right: 12px;
    width: 32px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    color: var(--mt-checkout-muted);
}

.mt-gateway-form-container .mt-card-brand-icon svg,
.mt-gateway-form-container .mt-card-brand-icon img {
    display: block;
    width: 32px;
    height: 22px;
    max-height: 100%;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

.mt-gateway-form-container .mt-accepted-cards {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.mt-gateway-form-container .mt-accepted-cards-label {
    color: var(--mt-checkout-muted);
    font-size: 12px;
    line-height: 1.4;
}

.mt-gateway-form-container .mt-accepted-card-logos {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.mt-gateway-form-container .mt-accepted-card-logo {
    display: inline-flex;
    width: 42px;
    height: 26px;
    align-items: center;
    justify-content: center;
}

.mt-gateway-form-container .mt-accepted-card-logo img {
    display: block;
    width: 42px;
    height: 26px;
    max-width: none;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.12));
}

.mt-gateway-form-container .mt-payment-notice {
    font-size: 12px;
    color: var(--mt-checkout-muted);
    margin: 12px 0 0 0 !important;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
}

.mt-gateway-form-container .mt-lock-icon {
    font-size: 13px;
    color: var(--mt-checkout-positive);
}

/* Validation Styling states */
.mt-gateway-form-container .mt-input-wrapper.is-invalid input:not([type="hidden"]) {
    border-color: var(--mt-checkout-negative) !important;
    background-color: var(--mt-checkout-negative-bg) !important;
}

.mt-gateway-form-container .mt-input-wrapper.is-invalid input:not([type="hidden"]):focus {
    outline-color: var(--mt-checkout-negative) !important;
}

.mt-gateway-form-container .mt-input-wrapper.is-valid input:not([type="hidden"]) {
    border-color: var(--mt-checkout-positive) !important;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .mt-gateway-form-container {
        padding: 16px;
    }
    .mt-gateway-form-container .mt-form-row.two-columns {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mt-gateway-form-container .mt-input-wrapper input:not([type="hidden"]) {
        transition: none !important;
    }
}

/* Keep Woo's native address schema, enhanced selects and visibility rules.
 * Only the active MT classic checkout gets this visual treatment. */
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-billing-fields .input-text,
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-shipping-fields .input-text,
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-billing-fields select:not(.select2-hidden-accessible),
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-shipping-fields select:not(.select2-hidden-accessible),
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-additional-fields select:not(.select2-hidden-accessible),
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-additional-fields .input-text {
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    color: var(--mt-checkout-text);
    background: var(--mt-checkout-surface);
    border: 1px solid var(--mt-checkout-border);
    border-radius: 10px;
    box-shadow: none;
}

form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-billing-fields .form-row label,
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-shipping-fields .form-row label,
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-additional-fields .form-row label {
    margin-bottom: 6px;
    color: var(--mt-checkout-text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: 0;
    text-transform: none;
    overflow-wrap: anywhere;
}

form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-billing-fields .input-text:focus,
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-shipping-fields .input-text:focus,
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-billing-fields select:not(.select2-hidden-accessible):focus,
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-shipping-fields select:not(.select2-hidden-accessible):focus,
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-additional-fields select:not(.select2-hidden-accessible):focus,
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .woocommerce-additional-fields .input-text:focus {
    outline: 2px solid var(--mt-checkout-accent);
    outline-offset: 2px;
}

form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .select2-container .select2-selection--single {
    min-height: 48px;
    color: var(--mt-checkout-text);
    background: var(--mt-checkout-surface);
    border: 1px solid var(--mt-checkout-border);
    border-radius: 10px;
    font-size: 16px;
}

form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .select2-container .select2-selection__rendered {
    color: var(--mt-checkout-text);
    line-height: 46px;
}

form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .select2-container .select2-selection__arrow {
    height: 46px;
}

form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .select2-container .select2-selection--single:focus {
    outline: 2px solid var(--mt-checkout-accent);
    outline-offset: 2px;
}

form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) #mt_shipping_same_as_billing_field label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) #mt_shipping_same_as_billing {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--mt-checkout-accent);
}

form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) #mt_shipping_same_as_billing:focus-visible {
    outline: 2px solid var(--mt-checkout-accent);
    outline-offset: 3px;
}

form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .form-row.woocommerce-invalid .input-text,
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .form-row.woocommerce-invalid select:not(.select2-hidden-accessible),
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .form-row.woocommerce-invalid .select2-selection--single {
    border-color: var(--mt-checkout-negative);
}

form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .form-row.woocommerce-validated .input-text,
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .form-row.woocommerce-validated select:not(.select2-hidden-accessible),
form.checkout.woocommerce-checkout:has(#payment_method_mt_secure_gateway:checked) .form-row.woocommerce-validated .select2-selection--single {
    border-color: var(--mt-checkout-positive);
}
