/* ==========================================================
   Panthea Medicare - Form Validation Styles
   ========================================================== */

/* ----------------------------------------------------------
   FIX 1: Bootstrap's default is-invalid/is-valid adds a 
   background-image warning/check icon that collides with 
   theme's <i> icons. Kill it everywhere.
   ---------------------------------------------------------- */
.form-control.is-invalid,
.form-control.is-valid,
.form-select.is-invalid,
.form-select.is-valid,
input.is-invalid,
input.is-valid,
select.is-invalid,
select.is-valid,
textarea.is-invalid,
textarea.is-valid {
    background-image: none !important;
    padding-right: 45px !important;
}

/* ----------------------------------------------------------
   FIX 2a: index.php wraps inputs in <div class="input-wrap">
   which breaks theme's icon positioning (theme targets 
   .form-group > i directly). Restore positioning here.
   ---------------------------------------------------------- */
.input-wrap {
    position: relative;
    display: block;
}

.input-wrap > i.fal,
.input-wrap > i.far,
.input-wrap > i.fas {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    font-size: 16px;
    color: #6c757d;
    z-index: 2;
    pointer-events: none;
    margin: 0 !important;
}

/* FIX 2a-ii: Selects inside .input-wrap need appearance:none too 
   (theme only applies it to .form-group > select). Without this, 
   browser's native dropdown arrow shows alongside our chevron icon. */
.input-wrap > select.form-select,
.input-wrap > select {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: none !important;
}

/* FIX 2b: Keep theme icons in place when validation changes */
.form-group .fal,
.form-group .far,
.form-group .fas {
    z-index: 2;
    pointer-events: none;
}

/* Invalid state: icon stays, just tint red */
.form-control.is-invalid ~ i.fal,
.form-control.is-invalid ~ i.far,
.form-control.is-invalid ~ i.fas,
.form-select.is-invalid ~ i.fal,
.form-select.is-invalid ~ i.far,
.form-select.is-invalid ~ i.fas {
    color: #d93025 !important;
}

.form-control.is-valid ~ i.fal,
.form-control.is-valid ~ i.far,
.form-control.is-valid ~ i.fas,
.form-select.is-valid ~ i.fal,
.form-select.is-valid ~ i.far,
.form-select.is-valid ~ i.fas {
    color: #1e8e3e !important;
}

/* ----------------------------------------------------------
   FIX 3: Hide theme's stale .invalid-feedback divs 
   (index.php has them hardcoded, we replace with .pm-error-msg)
   ---------------------------------------------------------- */
.invalid-feedback {
    display: none !important;
}

/* ----------------------------------------------------------
   Custom error message under each field
   ---------------------------------------------------------- */
.pm-error-msg {
    display: none;
    color: #d93025;
    font-size: 13px;
    margin-top: 6px;
    margin-left: 4px;
    line-height: 1.4;
    font-weight: 500;
}

/* Error for radio/checkbox group */
.pm-group-error {
    display: none;
    color: #d93025;
    font-size: 13px;
    margin-top: 8px;
    font-weight: 500;
    width: 100%;
}

/* ----------------------------------------------------------
   Invalid/Valid border styles
   ---------------------------------------------------------- */
.form-control.is-invalid,
.form-select.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: #d93025 !important;
    background-color: #fff8f8;
    box-shadow: 0 0 0 2px rgba(217, 48, 37, 0.08);
}

.form-control.is-valid,
.form-select.is-valid,
input.is-valid,
select.is-valid,
textarea.is-valid {
    border-color: #1e8e3e !important;
}

input[type="file"].is-invalid {
    border-color: #d93025 !important;
}

/* ----------------------------------------------------------
   Top-of-form alert
   ---------------------------------------------------------- */
.pm-form-alert {
    display: none;
    background: #fff5f5;
    color: #d93025;
    border: 1px solid #f5c6c6;
    border-left: 4px solid #d93025;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.pm-form-alert[data-type="success"] {
    background: #f1f8f4;
    color: #1e8e3e;
    border-color: #b7e0c4;
    border-left-color: #1e8e3e;
}

button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* ==========================================================
   OTP MODAL
   ========================================================== */
.pm-no-scroll {
    overflow: hidden;
}

.pm-otp-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity .2s ease;
}

.pm-otp-overlay.is-open {
    display: flex;
    opacity: 1;
}

.pm-otp-modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 440px;
    padding: 32px 28px 26px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
    text-align: center;
    position: relative;
    transform: translateY(20px) scale(0.97);
    transition: transform .25s ease;
    font-family: inherit;
}

.pm-otp-overlay.is-open .pm-otp-modal {
    transform: translateY(0) scale(1);
}

.pm-otp-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: 0;
    font-size: 28px;
    line-height: 1;
    color: #888;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: background .15s, color .15s;
}

.pm-otp-close:hover {
    background: #f1f3f5;
    color: #333;
}

.pm-otp-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #e8f0fe;
    color: #2c7be5;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.pm-otp-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px;
    color: #1a1a1a;
}

.pm-otp-sub {
    font-size: 14px;
    color: #555;
    line-height: 1.55;
    margin: 0 0 20px;
}

.pm-otp-sub b {
    color: #2c7be5;
    word-break: break-all;
}

.pm-otp-alert {
    display: none;
    background: #fff5f5;
    color: #d93025;
    border: 1px solid #f5c6c6;
    border-left: 4px solid #d93025;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    text-align: left;
    margin-bottom: 16px;
    font-weight: 500;
}

.pm-otp-alert[data-type="success"] {
    background: #f1f8f4;
    color: #1e8e3e;
    border-color: #b7e0c4;
    border-left-color: #1e8e3e;
}

.pm-otp-input-wrap {
    margin: 0 0 18px;
}

.pm-otp-input {
    width: 100%;
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 12px;
    padding: 14px 12px;
    border: 2px solid #d8dfe7;
    border-radius: 10px;
    color: #1a1a1a;
    background: #f8fafc;
    outline: none;
    transition: border-color .15s, background .15s;
    font-family: 'Courier New', monospace;
}

.pm-otp-input:focus {
    border-color: #2c7be5;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(44, 123, 229, 0.12);
}

.pm-otp-input::placeholder {
    color: #c8d0d8;
    letter-spacing: 12px;
}

.pm-otp-verify-btn {
    width: 100%;
    background: #2c7be5;
    color: #fff;
    border: 0;
    padding: 13px 18px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .05s;
}

.pm-otp-verify-btn:hover:not(:disabled) {
    background: #1f63c4;
}

.pm-otp-verify-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.pm-otp-resend {
    margin-top: 16px;
    font-size: 13px;
    color: #555;
}

.pm-otp-resend-btn {
    background: transparent;
    border: 0;
    color: #2c7be5;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 6px;
    font-size: 13px;
}

.pm-otp-resend-btn:disabled {
    color: #999;
    cursor: not-allowed;
}

.pm-otp-resend-btn:hover:not(:disabled) {
    text-decoration: underline;
}

@media (max-width: 480px) {
    .pm-otp-modal {
        padding: 26px 20px 22px;
    }
    .pm-otp-input {
        font-size: 22px;
        letter-spacing: 8px;
    }
    .pm-otp-input::placeholder {
        letter-spacing: 8px;
    }
}
