/*
 * CF7 Email OTP Verification
 *
 * Selectors are scoped under ".wpcf7 form" so they outrank most theme styles.
 * Brand colours are the original palette: blue #13AFF0 and orange #EF7F1A.
 */

/* ---------- Wrapper card ---------- */

.wpcf7 form .cf7otp-wrapper {
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-sizing: border-box;
    max-width: 100%;
    margin: 18px 0 8px;
    padding: 18px 20px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
    color: #334155;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
}

.wpcf7 form .cf7otp-wrapper ,
.wpcf7 form .cf7otp-wrapper ::before,
.wpcf7 form .cf7otp-wrapper ::after {
    box-sizing: border-box;
}

.wpcf7 form .cf7otp-wrapper .cf7otp-captcha-row,
.wpcf7 form .cf7otp-wrapper .cf7otp-otp-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* ---------- Captcha ---------- */

.wpcf7 form .cf7otp-wrapper .cf7otp-captcha-img {
    display: block;
    width: 200px;
    height: 60px;
    max-width: 100%;
    margin: 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f6f8fb;
    object-fit: contain;
    transition: opacity 0.2s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.wpcf7 form .cf7otp-wrapper button.cf7otp-captcha-refresh {
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #0075FF;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.wpcf7 form .cf7otp-wrapper button.cf7otp-captcha-refresh:hover {
    background: #0075FF;
    border-color: #0075FF;
    color: #ffffff;
}

/* Captcha states. A loading or failed image is always visible, never blank. */
.wpcf7 form .cf7otp-wrapper .cf7otp-captcha-img.is-loading {
    opacity: 0.45;
}

.wpcf7 form .cf7otp-wrapper .cf7otp-captcha-img.is-error {
    opacity: 1;
    background: #FFF3E6;
    border-color: #EF7F1A;
    min-height: 60px;
    /* Some browsers show the alt text here. The status line under the form always carries the message. */
    color: #8A4B0F;
    font-size: 13px;
    line-height: 60px;
    text-align: center;
}

/* ---------- Inputs ---------- */

.wpcf7 form .cf7otp-wrapper input[type="text"].cf7otp-captcha-input,
.wpcf7 form .cf7otp-wrapper input[type="text"].cf7otp-otp-input {
    height: 44px;
    margin: 0;
    padding: 0 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #0f172a;
    font-family: inherit;
    font-weight: 600;
    text-align: center;
    box-shadow: none;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Captcha: letter-spaced caps, sized for six characters. */
.wpcf7 form .cf7otp-wrapper input[type="text"].cf7otp-captcha-input {
    width: 170px;
    max-width: 100%;
    flex: 0 1 170px;
    font-size: 18px;
    letter-spacing: 6px;
}

/* OTP: monospaced, tabular digits, big and easy to read. */
.wpcf7 form .cf7otp-wrapper input[type="text"].cf7otp-otp-input {
    width: 190px;
    max-width: 100%;
    flex: 0 1 190px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 8px;
    text-indent: 8px; /* balances the trailing letter-spacing so the digits look centred */
}

.wpcf7 form .cf7otp-wrapper input[type="text"].cf7otp-captcha-input:focus,
.wpcf7 form .cf7otp-wrapper input[type="text"].cf7otp-otp-input:focus {
    border-color: #0075FF;
    box-shadow: 0 0 0 3px rgba(19, 175, 240, 0.18);
}

.wpcf7 form .cf7otp-wrapper input[type="text"]:disabled {
    background: #f1f5f9;
    color: #64748b;
}

/* ---------- Buttons ---------- */

.wpcf7 form .cf7otp-wrapper button.cf7otp-send-btn,
.wpcf7 form .cf7otp-wrapper button.cf7otp-verify-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 150px;
    height: 44px;
    align-self: flex-start; /* natural width on desktop; the card is a flex column */
    margin: 0;
    padding: 0 20px;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.05s ease;
}

.wpcf7 form .cf7otp-wrapper button.cf7otp-send-btn {
    background: #0075FF;
}

.wpcf7 form .cf7otp-wrapper button.cf7otp-send-btn:hover:not(:disabled) {
    background: #0e96d1;
}

.wpcf7 form .cf7otp-wrapper button.cf7otp-verify-btn {
    background: #EF7F1A;
}

.wpcf7 form .cf7otp-wrapper button.cf7otp-verify-btn:hover:not(:disabled) {
    background: #d46c12;
}

.wpcf7 form .cf7otp-wrapper button:active:not(:disabled) {
    transform: translateY(1px);
}

.wpcf7 form .cf7otp-wrapper button:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
}

/* ---------- Focus (keyboard users) ---------- */

.wpcf7 form .cf7otp-wrapper button:focus-visible {
    outline: 2px solid #0075FF;
    outline-offset: 2px;
}

/* ---------- Notes and status ---------- */

.wpcf7 form .cf7otp-wrapper .cf7otp-note {
    margin: 0;
    color: #64748b;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.wpcf7 form .cf7otp-wrapper .cf7otp-note:empty {
    display: none;
}

.wpcf7 form .cf7otp-wrapper .cf7otp-status {
    margin: 0;
    padding: 12px 14px;
    border-left: 4px solid #0075FF;
    border-radius: 6px;
    background: #f8fafc;
    color: #334155;
    font-size: 14px;
    line-height: 1.5;
}

.wpcf7 form .cf7otp-wrapper .cf7otp-status:empty {
    display: none;
}

.wpcf7 form .cf7otp-wrapper .cf7otp-status.success {
    background: #f0fdf4;
    border-left-color: #22c55e;
    color: #15803d;
}

.wpcf7 form .cf7otp-wrapper .cf7otp-status.error {
    background: #fef2f2;
    border-left-color: #ef4444;
    color: #b91c1c;
}

.wpcf7 form .cf7otp-wrapper .cf7otp-status.warning {
    background: #fffbe2;
    border-left-color: #EF7F1A;
    color: #b45309;
}

/* Submit button locked until the email is verified. */
.wpcf7 form input[type="submit"].cf7otp-disabled,
.wpcf7 form input[type="submit"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- Phones ---------- */

@media (max-width: 576px) {
    .wpcf7 form .cf7otp-wrapper {
        padding: 16px;
    }

    .wpcf7 form .cf7otp-wrapper .cf7otp-captcha-row,
    .wpcf7 form .cf7otp-wrapper .cf7otp-otp-row {
        flex-direction: column;
        align-items: stretch;
    }

    .wpcf7 form .cf7otp-wrapper .cf7otp-captcha-row {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .wpcf7 form .cf7otp-wrapper input[type="text"].cf7otp-captcha-input,
    .wpcf7 form .cf7otp-wrapper input[type="text"].cf7otp-otp-input {
        width: 100%;
        max-width: 100%;
        flex: 1 1 100%;
    }

    .wpcf7 form .cf7otp-wrapper button.cf7otp-send-btn,
    .wpcf7 form .cf7otp-wrapper button.cf7otp-verify-btn {
        width: 100%;
        align-self: stretch;
    }
}