/* =============================================================================
   Accept.Blue ACH — Checkout Styles
   Covers: Classic checkout, Blocks checkout, My Account / Payment Methods
   ============================================================================= */

/* ─── Design tokens ──────────────────────────────────────────────────────── */
:root {
    --ab-blue:          #1a56db;
    --ab-blue-light:    #e8f0fe;
    --ab-blue-focus:    rgba(26, 86, 219, 0.18);
    --ab-border:        #d1d5db;
    --ab-border-hover:  #9ca3af;
    --ab-bg:            #ffffff;
    --ab-bg-subtle:     #f9fafb;
    --ab-text:          #111827;
    --ab-text-muted:    #6b7280;
    --ab-label:         #374151;
    --ab-radius:        8px;
    --ab-radius-sm:     5px;
    --ab-shadow-focus:  0 0 0 3px var(--ab-blue-focus);
    --ab-warning-bg:    #fffbeb;
    --ab-warning-border:#f59e0b;
    --ab-warning-text:  #92400e;
    --ab-success-bg:    #f0fdf4;
    --ab-success-border:#22c55e;
    --ab-success-text:  #166534;
    --ab-transition:    0.18s ease;
}

/* ─── Sandbox / Test-mode notice ─────────────────────────────────────────── */

.acceptblue-testmode,
.acceptblue-ach-sandbox-notice {
    display: flex;
    flex-direction: column;
    gap: 3px;
    background: var(--ab-warning-bg);
    border: 1px dashed var(--ab-warning-border);
    border-radius: var(--ab-radius);
    color: var(--ab-warning-text);
    font-size: 12.5px;
    line-height: 1.55;
    padding: 11px 14px;
    margin-bottom: 16px;
}

.acceptblue-testmode strong,
.acceptblue-ach-sandbox-notice strong {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #b45309;
    margin-bottom: 4px;
}

.acceptblue-testmode p,
.acceptblue-ach-sandbox-notice p {
    margin: 0;
}

.acceptblue-testmode p strong,
.acceptblue-ach-sandbox-notice p strong {
    display: inline;
    font-size: inherit;
    text-transform: none;
    letter-spacing: normal;
    color: inherit;
    margin-bottom: 0;
    font-weight: 600;
}

/* ─── Classic checkout — fieldset ────────────────────────────────────────── */

fieldset.wc-ach-form {
    border: none;
    border-top: 1px solid var(--ab-border);
    padding: 16px 0 4px;
    margin: 8px 0 0;
    background: transparent;
}

/* ─── Blocks wrapper ─────────────────────────────────────────────────────── */

.acceptblue-ach-block-wrapper {
    margin-top: 10px;
}

/* ─── Saved payment method list (Blocks) ─────────────────────────────────── */

.acceptblue-ach-saved-methods {
    margin-bottom: 14px;
}

.acceptblue-ach-saved-methods > p {
    font-size: 13px;
    font-weight: 600;
    color: var(--ab-label);
    margin: 0 0 8px;
}

.acceptblue-ach-saved-method {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: var(--ab-text);
    background: var(--ab-bg-subtle);
    border: 1px solid var(--ab-border);
    border-radius: var(--ab-radius-sm);
    padding: 9px 12px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: border-color var(--ab-transition), background var(--ab-transition);
}

.acceptblue-ach-saved-method:hover {
    border-color: var(--ab-blue);
    background: var(--ab-blue-light);
}

.acceptblue-ach-saved-method input[type="radio"] {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    accent-color: var(--ab-blue);
    margin: 0;
    padding: 0;
    cursor: pointer;
}

/* Highlight the selected saved method row */
.acceptblue-ach-saved-method:has(input[type="radio"]:checked) {
    border-color: var(--ab-blue);
    background: var(--ab-blue-light);
}

/* ─── New account form (Blocks) ──────────────────────────────────────────── */

.acceptblue-ach-new-form {
    border-top: 1px solid var(--ab-border);
    padding-top: 14px;
    margin-top: 4px;
}

/* When there are no saved methods, remove top border */
.acceptblue-ach-block-wrapper:not(:has(.acceptblue-ach-saved-methods)) .acceptblue-ach-new-form {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

/* ─── Form rows ──────────────────────────────────────────────────────────── */

.wc-ach-form .form-row,
.acceptblue-ach-new-form .form-row {
    margin: 0 0 12px;
    padding: 0;
}

.wc-ach-form .form-row label,
.acceptblue-ach-new-form .form-row label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--ab-label);
    margin-bottom: 4px;
    line-height: 1.4;
}

/* Required asterisk */
.wc-ach-form .form-row label .required,
.acceptblue-ach-new-form .form-row label .required {
    color: #ef4444;
    font-weight: 700;
    margin-left: 1px;
}

/* ─── Text inputs & select ───────────────────────────────────────────────── */

.wc-ach-form input.input-text,
.wc-ach-form select.select,
.acceptblue-ach-new-form input.input-text,
.acceptblue-ach-new-form select.select {
    display: block;
    width: 100%;
    padding: 8px 11px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ab-text);
    background: var(--ab-bg);
    border: 1px solid var(--ab-border);
    border-radius: var(--ab-radius-sm);
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: border-color var(--ab-transition), box-shadow var(--ab-transition);
    appearance: none;
    -webkit-appearance: none;
    line-height: 1.5;
}

.wc-ach-form input.input-text:hover,
.wc-ach-form select.select:hover,
.acceptblue-ach-new-form input.input-text:hover,
.acceptblue-ach-new-form select.select:hover {
    border-color: var(--ab-border-hover);
}

.wc-ach-form input.input-text:focus,
.wc-ach-form select.select:focus,
.acceptblue-ach-new-form input.input-text:focus,
.acceptblue-ach-new-form select.select:focus {
    outline: none;
    border-color: var(--ab-blue);
    box-shadow: var(--ab-shadow-focus);
}

/* Select arrow */
.wc-ach-form select.select,
.acceptblue-ach-new-form select.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 34px;
    cursor: pointer;
}

/* ─── Save payment method checkbox (Classic + Blocks) ───────────────────── */

.wc-ach-form .form-row label:has(input[type="checkbox"]),
.acceptblue-ach-new-form .form-row label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 400;
    color: var(--ab-text-muted);
    cursor: pointer;
    margin-bottom: 0;
}

.wc-ach-form .form-row input[type="checkbox"],
.acceptblue-ach-new-form .form-row input[type="checkbox"] {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    accent-color: var(--ab-blue);
    margin: 0;
    padding: 0;
    cursor: pointer;
}

/* ─── WooCommerce saved payment methods list (Classic tokenization UI) ─── */

/* Tighten up the WC-generated saved methods radio list */
#payment .payment_method_acceptblue_ach ul.woocommerce-SavedPaymentMethods {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
}

#payment .payment_method_acceptblue_ach .woocommerce-SavedPaymentMethods-saveNew {
    font-size: 13px;
    color: var(--ab-text-muted);
    margin-bottom: 10px;
}

/* ─── Blocks checkout alignment ──────────────────────────────────────────── */

.wc-block-components-payment-method-label {
    align-items: center;
}

/* ─── My Account — Payment Methods page ─────────────────────────────────── */

/* Badge shown next to saved ACH token (last4 + type) */
.acceptblue-ach-token-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--ab-text-muted);
}

.acceptblue-ach-token-badge::before {
    content: '';
    display: inline-block;
    width: 28px;
    height: 18px;
    background: var(--ab-bg-subtle);
    border: 1px solid var(--ab-border);
    border-radius: 3px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 18'%3E%3Crect width='28' height='18' rx='3' fill='%23f3f4f6'/%3E%3Cpath d='M2 7h24v3H2z' fill='%23d1d5db'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

/* ─── Admin order panel ──────────────────────────────────────────────────── */

.acceptblue-ach-order-panel {
    font-size: 12px;
}

.acceptblue-ach-order-panel td:first-child {
    color: var(--ab-text-muted);
    white-space: nowrap;
    padding-right: 8px;
}

/* ─── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    fieldset.wc-ach-form {
        padding: 14px 14px 10px;
    }

    .acceptblue-ach-saved-method {
        font-size: 13px;
        padding: 8px 10px;
    }

    .wc-ach-form input.input-text,
    .wc-ach-form select.select,
    .acceptblue-ach-new-form input.input-text,
    .acceptblue-ach-new-form select.select {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
}

/* ─── Dark mode ──────────────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
    :root {
        --ab-blue-light:    rgba(26, 86, 219, 0.15);
        --ab-border:        #374151;
        --ab-border-hover:  #6b7280;
        --ab-bg:            #1f2937;
        --ab-bg-subtle:     #111827;
        --ab-text:          #f9fafb;
        --ab-text-muted:    #9ca3af;
        --ab-label:         #e5e7eb;
        --ab-warning-bg:    rgba(245, 158, 11, 0.1);
        --ab-warning-border:#d97706;
        --ab-warning-text:  #fcd34d;
    }

    .wc-ach-form input.input-text,
    .wc-ach-form select.select,
    .acceptblue-ach-new-form input.input-text,
    .acceptblue-ach-new-form select.select {
        color-scheme: dark;
    }
}
