/**
 * Checkout Page Styles
 * Payment methods list + Credit card form
 * 
 * Updated: 2025-12-23
 */

/* ==================== Reset ==================== */

#payment,
.woocommerce-checkout-payment,
.wfacp-comm-wrapper,
.wfacp_main_form {
    margin: 0;
    padding: 0;
}

/* ==================== Payment Methods Container ==================== */

#payment ul.payment_methods,
ul.wc_payment_methods,
.payment_methods {
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    overflow: visible;
    background: #fff;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ==================== Payment Method Item ==================== */

#payment ul.payment_methods li.wc_payment_method,
#payment ul.payment_methods li,
ul.wc_payment_methods li,
.payment_methods li {
    border-bottom: 1px solid #e6e6e6;
    background: #fff;
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
    display: block;
    min-height: 56px;
    box-sizing: border-box;
}

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

/* PayPal specific - prevent squeeze */
#payment ul.payment_methods li.payment_method_cpg_paypal {
    opacity: 1;
    transform: none;
    visibility: visible;
    height: auto;
    min-height: 56px;
    overflow: visible;
}

/* ==================== Radio Button ==================== */

/* Hide native radio */
#payment ul.payment_methods li input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* ==================== Label ==================== */

#payment ul.payment_methods li.wc_payment_method > label,
#payment ul.payment_methods li label[for^="payment_method_"] {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    padding: 18px 20px;
    cursor: pointer;
    background: #fff;
    height: 56px;
    min-height: 56px;
    font-size: 14px;
    font-weight: 400;
    color: #333;
    border: 2px solid transparent;
    margin: 0;
    box-sizing: border-box;
    position: relative;
    width: 100%;
    overflow: visible;
}

/* Label text color */
#payment ul.payment_methods li.wc_payment_method > label *:not(.pay):not(.pal) {
    color: #333;
    text-decoration: none;
}

/* Selected state - blue border */
#payment ul.payment_methods li input[type="radio"]:checked + label {
    border: 2px solid #1773b0;
    border-radius: 4px;
}

/* ==================== Custom Radio Circle ==================== */

#payment ul.payment_methods li.wc_payment_method > label::before,
#payment ul.payment_methods li label[for^="payment_method_"]::before,
#payment .payment_methods li.payment_method_clean_payment_gateway > label::before,
#payment .payment_methods li.payment_method_cpg_paypal > label::before,
body #wfacp-e-form #payment ul.payment_methods li > label::before,
body .wfacp-template-container #payment ul.payment_methods li > label::before {
    content: '' !important;
    display: inline-block !important;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    border: 2px solid #c4c4c4 !important;
    border-radius: 50% !important;
    margin-right: 12px !important;
    flex-shrink: 0 !important;
    background: #fff !important;
    box-sizing: border-box !important;
}

/* Selected radio - blue fill */
#payment ul.payment_methods li input[type="radio"]:checked + label::before,
body #wfacp-e-form #payment ul.payment_methods li input[type="radio"]:checked + label::before,
body .wfacp-template-container #payment ul.payment_methods li input[type="radio"]:checked + label::before {
    border-color: #1773b0 !important;
    background: #1773b0 !important;
    box-shadow: inset 0 0 0 3px #fff !important;
}

/* Hide WooCommerce default icons */
#payment ul.payment_methods li.wc_payment_method > label img:not(.cpg-card-icon) {
    display: none;
}

/* ==================== Card Icons ==================== */

.cpg-payment-icons {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
}

.cpg-payment-icons > svg {
    height: 24px !important;
    width: 38px !important;
    flex-shrink: 0 !important;
    display: inline-block !important;
}

/* Rotating card icons */
.cpg-rotating-cards {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 24px;
    position: relative;
    overflow: hidden;
}

.cpg-rotating-cards > svg,
.cpg-rotating-cards > .cpg-more-indicator {
    position: absolute;
    width: 38px;
    height: 24px;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.cpg-rotating-cards > .cpg-active {
    opacity: 1;
}

.cpg-more-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #6D7175;
    background: #F6F6F6;
    border-radius: 3px;
    font-weight: 600;
    border: 1px solid #E3E3E3;
}

/* ==================== PayPal ==================== */

.cpg-paypal-logo {
    display: inline-block;
    margin-left: auto;
    flex-shrink: 0;
    width: 70px;
    height: 18px;
}

.cpg-paypal-content {
    padding: 0;
    background: #fafafa;
}

.cpg-paypal-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px 16px;
    background: #fafafa;
}

.cpg-redirect-icon {
    margin-bottom: 16px;
    display: block;
}

.cpg-redirect-icon svg {
    width: 163px;
    height: 81px;
    color: #8a8a8a;
    display: block;
}

.cpg-paypal-text {
    font-size: 13px;
    color: #000;
    line-height: 1.5;
    max-width: 320px;
    margin: 0 auto;
}

html body .cpg-paypal-text,
html body #wfacp-e-form .cpg-paypal-text,
html body .wfacp-template-container .cpg-paypal-text,
html body #payment .cpg-paypal-text {
    color: #000 !important;
}

/* 🔥 PayPal FunnelKit/WooCommerce Override - 最高优先级 */
body #payment div.payment_box.payment_method_cpg_paypal,
body.woocommerce-checkout #payment div.payment_box.payment_method_cpg_paypal,
#wfacp-e-form #payment div.payment_box.payment_method_cpg_paypal,
html body #wfacp-e-form #payment div.payment_box.payment_method_cpg_paypal,
html body .wfacp-template-container #payment div.payment_box.payment_method_cpg_paypal {
    background: #fafafa !important;
    padding: 0 !important;
}

html body .cpg-paypal-content,
html body .cpg-paypal-info,
html body #wfacp-e-form .cpg-paypal-content,
html body #wfacp-e-form .cpg-paypal-info,
html body .wfacp-template-container .cpg-paypal-content,
html body .wfacp-template-container .cpg-paypal-info,
html body #payment .cpg-paypal-content,
html body #payment .cpg-paypal-info {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background: #fafafa !important;
    padding: 24px 16px !important;
}

html body .cpg-redirect-icon,
html body #wfacp-e-form .cpg-redirect-icon,
html body .wfacp-template-container .cpg-redirect-icon,
html body #payment .cpg-redirect-icon {
    display: block !important;
    margin-bottom: 16px !important;
}

html body .cpg-redirect-icon svg,
html body #wfacp-e-form .cpg-redirect-icon svg,
html body .wfacp-template-container .cpg-redirect-icon svg,
html body #payment .cpg-redirect-icon svg {
    width: 163px !important;
    height: 81px !important;
    color: #8a8a8a !important;
    display: block !important;
}

/* ==================== Payment Box ==================== */

#payment div.payment_box {
    display: none;
    background: #fafafa;
    padding: 0;
    margin: 0;
    border: none;
    border-top: 1px solid #e6e6e6;
}

#payment ul.payment_methods li input[type="radio"]:checked ~ div.payment_box {
    display: block;
}

/* Hide arrow */
#payment div.payment_box::before,
#payment div.payment_box::after {
    display: none;
    content: none;
}

/* ==================== Credit Card Form ==================== */

#cpg-payment-form-container {
    background: #fafafa;
    padding: 16px;
    margin: 0;
}

#cpg-payment-form-container .card-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 !important;
    padding: 0 !important;
}

#cpg-payment-form-container .form-field {
    position: relative;
    margin: 0 !important;
    padding: 0 !important;
}

/* 🔥 Reset all margins inside card form */
#cpg-payment-form-container .card-form > * {
    margin: 0 !important;
}

#cpg-payment-form-container .form-row {
    margin: 0 !important;
}

#cpg-payment-form-container .form-input,
.card-form .form-input {
    width: 100% !important;
    padding: 14px 40px 14px 12px !important;
    border: 1px solid #d9d9d9 !important;
    border-radius: 5px !important;
    font-size: 14px !important;
    color: #333 !important;
    background: #fff !important;
    outline: none !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif !important;
    box-sizing: border-box !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
    line-height: 1.4 !important;
    height: 48px !important;
    min-height: 48px !important;
}

#cpg-payment-form-container .form-input:focus,
.card-form .form-input:focus {
    border-color: #1773b0;
    box-shadow: 0 0 0 1px #1773b0;
}

#cpg-payment-form-container .form-input::placeholder,
.card-form .form-input::placeholder {
    color: #717171;
}

#cpg-payment-form-container .form-icon,
.card-form .form-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #717171;
    pointer-events: none;
}

#cpg-payment-form-container .form-icon svg,
.card-form .form-icon svg {
    width: 18px;
    height: 18px;
}

#cpg-payment-form-container .form-row,
.card-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* ==================== Checkbox ==================== */

#cpg-payment-form-container .checkbox-row,
.card-form .checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

#cpg-payment-form-container .checkbox-row input[type="checkbox"],
.card-form .checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    border: 2px solid #d9d9d9;
    border-radius: 4px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    position: relative;
    background: #fff;
    flex-shrink: 0;
    transition: all 0.2s ease;
    margin: 0;
    padding: 0;
}

#cpg-payment-form-container .checkbox-row input[type="checkbox"]:hover,
.card-form .checkbox-row input[type="checkbox"]:hover {
    border-color: #1773b0;
}

#cpg-payment-form-container .checkbox-row input[type="checkbox"]:checked,
.card-form .checkbox-row input[type="checkbox"]:checked {
    background: #1773b0;
    border-color: #1773b0;
}

#cpg-payment-form-container .checkbox-row input[type="checkbox"]:checked::after,
.card-form .checkbox-row input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    display: block;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%) rotate(45deg);
}

#cpg-payment-form-container .checkbox-label,
.card-form .checkbox-label {
    font-size: 14px;
    color: #333;
    cursor: pointer;
    line-height: 1.4;
}

/* ==================== FunnelKit Override (最高优先级) ==================== */

/* 🔥 支付方式容器 - 覆盖FunnelKit的边框 */
html body #wfacp-e-form #payment ul.payment_methods,
html body .wfacp-template-container #payment ul.payment_methods,
html body.woocommerce-checkout #wfacp-e-form #payment ul.payment_methods {
    border: 1px solid #d9d9d9 !important;
    border-radius: 4px !important;
    overflow: visible !important;
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 🔥 支付方式项 - 覆盖FunnelKit的padding/margin */
html body #wfacp-e-form #payment ul.payment_methods li,
html body .wfacp-template-container #payment ul.payment_methods li,
html body.woocommerce-checkout #wfacp-e-form #payment ul.payment_methods li {
    border-bottom: 1px solid #e6e6e6 !important;
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 56px !important;
}

html body #wfacp-e-form #payment ul.payment_methods li:last-child,
html body .wfacp-template-container #payment ul.payment_methods li:last-child {
    border-bottom: none !important;
}

/* 🔥 Label样式 - 覆盖FunnelKit */
html body #wfacp-e-form #payment ul.payment_methods li > label,
html body .wfacp-template-container #payment ul.payment_methods li > label,
html body.woocommerce-checkout #wfacp-e-form #payment ul.payment_methods li > label {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 18px 20px !important;
    cursor: pointer !important;
    background: #fff !important;
    height: 56px !important;
    min-height: 56px !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    color: #333 !important;
    border: 2px solid transparent !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    position: relative !important;
    width: 100% !important;
}

/* 🔥 选中状态蓝色边框 - 覆盖FunnelKit */
html body #wfacp-e-form #payment ul.payment_methods li input[type="radio"]:checked + label,
html body .wfacp-template-container #payment ul.payment_methods li input[type="radio"]:checked + label,
html body.woocommerce-checkout #wfacp-e-form #payment ul.payment_methods li input[type="radio"]:checked + label {
    border: 2px solid #1773b0 !important;
    border-radius: 4px !important;
    background: #fff !important;
}

/* 🔥 隐藏原生radio */
html body #wfacp-e-form #payment ul.payment_methods li input[type="radio"],
html body .wfacp-template-container #payment ul.payment_methods li input[type="radio"] {
    position: absolute !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    pointer-events: none !important;
}

/* 🔥 Payment Box - 覆盖FunnelKit */
html body #wfacp-e-form #payment div.payment_box,
html body .wfacp-template-container #payment div.payment_box,
html body #wfacp-e-form #payment div.payment_box.payment_method_clean_payment_gateway,
html body .wfacp-template-container #payment div.payment_box.payment_method_clean_payment_gateway {
    display: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-top: 1px solid #e6e6e6 !important;
}

/* 🔥 强制 cpg-payment-form-container 背景色 */
html body #wfacp-e-form #payment div.payment_box #cpg-payment-form-container,
html body .wfacp-template-container #payment div.payment_box #cpg-payment-form-container,
html body #wfacp-e-form #payment .payment_box.payment_method_clean_payment_gateway #cpg-payment-form-container,
html body .wfacp-template-container #payment .payment_box.payment_method_clean_payment_gateway #cpg-payment-form-container,
html body #payment div.payment_box #cpg-payment-form-container {
    background: #fafafa !important;
    padding: 16px !important;
}

html body #wfacp-e-form #payment ul.payment_methods li input[type="radio"]:checked ~ div.payment_box,
html body .wfacp-template-container #payment ul.payment_methods li input[type="radio"]:checked ~ div.payment_box {
    display: block !important;
}

/* 🔥 隐藏箭头 */
html body #wfacp-e-form #payment div.payment_box::before,
html body #wfacp-e-form #payment div.payment_box::after,
html body .wfacp-template-container #payment div.payment_box::before,
html body .wfacp-template-container #payment div.payment_box::after {
    display: none !important;
    content: none !important;
}

/* 🔥 Force container padding (WooCommerce/FunnelKit override) */
body #cpg-payment-form-container,
body.woocommerce-checkout #cpg-payment-form-container,
#wfacp-e-form #cpg-payment-form-container,
html body #wfacp-e-form #cpg-payment-form-container,
html body .wfacp-template-container #cpg-payment-form-container {
    padding: 16px !important;
    background: #fafafa !important;
    margin: 0 !important;
}

/* 🔥 Force reset form field margins (WooCommerce/FunnelKit override) */
body #cpg-payment-form-container .card-form,
body #cpg-payment-form-container .card-form .form-field,
body #cpg-payment-form-container .card-form .form-row,
body.woocommerce-checkout #cpg-payment-form-container .card-form,
body.woocommerce-checkout #cpg-payment-form-container .form-field,
body.woocommerce-checkout #cpg-payment-form-container .form-row,
#wfacp-e-form #cpg-payment-form-container .card-form,
#wfacp-e-form #cpg-payment-form-container .form-field,
#wfacp-e-form #cpg-payment-form-container .form-row {
    margin: 0 !important;
    padding: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* 🔥 Ensure proper gap in card form */
body #cpg-payment-form-container .card-form {
    gap: 10px !important;
}

/* 🔥 Force input height and remove any extra spacing */
body #cpg-payment-form-container .form-input,
body.woocommerce-checkout #cpg-payment-form-container .form-input,
#wfacp-e-form #cpg-payment-form-container .form-input {
    margin: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    height: 48px !important;
    min-height: 48px !important;
    padding: 14px 40px 14px 12px !important;
}

/* ==================== Responsive ==================== */

@media (max-width: 480px) {
    #cpg-payment-form-container .form-row,
    .card-form .form-row {
        grid-template-columns: 1fr;
    }
    
    #cpg-payment-form-container .form-input,
    .card-form .form-input {
        font-size: 16px;
    }
}

