/**
 * OTP Phone Verification — Modern Popup Styles
 * Brand color: #2b6777
 */

/* ============================================================
   RESET — Prevent theme from breaking popup elements
   ============================================================ */
#otp-overlay *,
#otp-overlay *::before,
#otp-overlay *::after {
    box-sizing: border-box;
}

/* ============================================================
   OVERLAY
   ============================================================ */
#otp-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: otpFadeIn 0.35s ease;
}

@keyframes otpFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================
   MODAL BOX
   ============================================================ */
.otp-modal {
    background: #ffffff;
    border-radius: 24px;
    width: 440px;
    max-width: 92vw;
    max-height: 95vh;
    overflow-y: auto;
    padding: 44px 40px 32px;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.03),
        0 24px 64px -16px rgba(0, 0, 0, 0.25),
        0 8px 20px -8px rgba(0, 0, 0, 0.1);
    text-align: center;
    animation: otpSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    position: relative;
}

@keyframes otpSlideUp {
    from { transform: translateY(40px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ============================================================
   ICON (Emoji)
   ============================================================ */
.otp-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #e8f4f6 0%, #d0ecf0 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    box-shadow: 0 4px 12px rgba(43, 103, 119, 0.15);
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
.otp-modal h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 8px;
    color: #0f172a;
    letter-spacing: -0.3px;
    line-height: 1.3;
}

.otp-modal p {
    font-size: 14.5px;
    color: #64748b;
    margin: 0 0 28px;
    line-height: 1.6;
}

.otp-modal p strong {
    color: #2b6777;
    font-weight: 600;
}

/* ============================================================
   PHONE INPUT GROUP
   ============================================================ */
.otp-phone-input-wrap {
    display: flex;
    align-items: stretch;
    gap: 0;
    margin-bottom: 24px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    background: #f8fafc;
    overflow: visible;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.otp-phone-input-wrap:focus-within {
    border-color: #2b6777;
    box-shadow: 0 0 0 4px rgba(43, 103, 119, 0.1);
    background: #fff;
}

/* ============================================================
   SELECT2 OVERRIDES — Country Dropdown inside popup
   ============================================================ */

/* The Select2 container sitting inside the phone row */
.otp-phone-input-wrap .select2-container {
    flex-shrink: 0;
    min-width: 130px !important;
    max-width: 160px !important;
    border-right: 2px solid #e2e8f0;
}

.otp-phone-input-wrap .select2-container--default .select2-selection--single {
    border: none !important;
    border-radius: 12px 0 0 12px !important;
    background: transparent !important;
    height: 100% !important;
    min-height: 50px;
    display: flex !important;
    align-items: center !important;
    padding: 0 8px 0 14px !important;
    cursor: pointer;
}

.otp-phone-input-wrap .select2-container--default .select2-selection--single .select2-selection__rendered {
    padding: 0 !important;
    line-height: normal !important;
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    font-family: 'Poppins', sans-serif;
}

.otp-phone-input-wrap .select2-container--default .select2-selection--single .select2-selection__arrow {
    top: 50% !important;
    transform: translateY(-50%);
    right: 6px !important;
    height: auto !important;
}

.otp-phone-input-wrap .select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #64748b transparent transparent transparent !important;
    border-width: 5px 4px 0 4px !important;
}

.otp-phone-input-wrap .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent #2b6777 transparent !important;
    border-width: 0 4px 5px 4px !important;
}

/* Selected display — flag + code */
.otp-s2-selected {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    letter-spacing: 0.2px;
}

/* Dropdown panel that opens */
.otp-select2-dropdown.select2-dropdown {
    border: 1px solid #e2e8f0 !important;
    border-radius: 14px !important;
    box-shadow: 0 12px 40px -8px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.06) !important;
    overflow: hidden;
    margin-top: 6px;
    z-index: 1000001 !important;
}

.otp-select2-dropdown .select2-search--dropdown {
    padding: 12px 12px 8px !important;
    border-bottom: 1px solid #f1f5f9;
}

.otp-select2-dropdown .select2-search__field {
    border: 2px solid #e2e8f0 !important;
    border-radius: 10px !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
    font-family: 'Poppins', sans-serif !important;
    color: #0f172a !important;
    background: #f8fafc !important;
    outline: none !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.otp-select2-dropdown .select2-search__field:focus {
    border-color: #2b6777 !important;
    box-shadow: 0 0 0 3px rgba(43, 103, 119, 0.1) !important;
    background: #fff !important;
}

.otp-select2-dropdown .select2-results__options {
    max-height: 260px !important;
    padding: 4px 0 !important;
}

.otp-select2-dropdown .select2-results__options::-webkit-scrollbar {
    width: 6px;
}

.otp-select2-dropdown .select2-results__options::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Optgroup headers */
.otp-select2-dropdown .select2-results__group {
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #2b6777 !important;
    padding: 10px 14px 4px !important;
    font-family: 'Poppins', sans-serif;
}

/* Individual options */
.otp-select2-dropdown .select2-results__option {
    padding: 9px 14px !important;
    font-size: 14px !important;
    font-family: 'Poppins', sans-serif !important;
    color: #334155 !important;
    transition: background 0.15s ease;
}

.otp-select2-dropdown .select2-results__option--highlighted[aria-selected] {
    background: #e8f4f6 !important;
    color: #2b6777 !important;
}

.otp-select2-dropdown .select2-results__option[aria-selected="true"] {
    background: #f0f9fa !important;
    color: #2b6777 !important;
    font-weight: 600;
}

/* Option text formatting */
.otp-s2-option {
    font-size: 14px;
    display: inline-block;
}

.otp-phone-input {
    flex: 1;
    padding: 14px 16px;
    border: none !important;
    border-radius: 0 !important;
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
    background: transparent;
    color: #0f172a;
    outline: none;
    letter-spacing: 0.5px;
}

.otp-phone-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

/* ============================================================
   OTP CODE DIGIT INPUTS
   ============================================================ */
.otp-code-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 24px;
}

.otp-digit {
    width: 50px;
    height: 58px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    color: #0f172a;
    background: #f8fafc;
    outline: none;
    transition: all 0.25s ease;
    -moz-appearance: textfield;
    appearance: textfield;
}

.otp-digit::-webkit-inner-spin-button,
.otp-digit::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.otp-digit:focus {
    border-color: #2b6777;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(43, 103, 119, 0.1);
    transform: translateY(-2px);
}

.otp-digit:not(:placeholder-shown) {
    border-color: #2b6777;
    background: #fff;
}

/* ============================================================
   PRIMARY BUTTON
   ============================================================ */
.otp-btn.otp-btn-primary {
    width: 100%;
    max-width: 250px;
    padding: 16px 24px !important;
    background: linear-gradient(135deg, #00AEFF 0%, #00AEFF 100%);
    color: #ffffff;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(43, 103, 119, 0.3);
    letter-spacing: 0.2px;
    position: relative;
    margin: 20px auto !important;
    overflow: hidden;
}

.otp-btn.otp-btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.otp-btn.otp-btn-primary:hover {
    background: linear-gradient(135deg, #00AEFF 0%, #00AEFF 100%);
    box-shadow: 0 6px 20px rgba(43, 103, 119, 0.4);
    transform: translateY(-1px);
}

.otp-btn.otp-btn-primary:hover::before {
    opacity: 1;
}

.otp-btn.otp-btn-primary:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(43, 103, 119, 0.3);
}

.otp-btn.otp-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============================================================
   BUTTON LOADING SPINNER
   ============================================================ */
.otp-btn-text {
    display: inline-block;
}

.otp-btn-loader {
    display: none;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    gap: 8px;
    align-items: center;
}

.otp-btn-loader::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: otpSpin 0.65s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes otpSpin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   LINK BUTTONS (Resend, Change Number)
   ============================================================ */
.otp-btn-link {
    background: none;
    border: none;
    color: #2b6777;
    font-size: 13.5px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    padding: 4px 2px;
    transition: color 0.2s ease;
    text-decoration: none;
}

.otp-btn-link:hover {
    color: #1e4f5c;
    text-decoration: underline;
}

/* ============================================================
   RESEND WRAP & TIMER
   ============================================================ */
.otp-resend-wrap {
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    color: #94a3b8;
}

.otp-separator {
    color: #cbd5e1;
    font-weight: 300;
    user-select: none;
}

#otp-timer {
    font-size: 13px;
    color: #94a3b8;
}

#otp-countdown {
    font-weight: 700;
    color: #2b6777;
}

/* ============================================================
   ERROR MESSAGES
   ============================================================ */
.otp-error {
    display: none;
    background: #fef2f2;
    color: #dc2626;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 14px;
    border-radius: 10px;
    margin-top: 12px;
    text-align: center;
    border: 1px solid #fecaca;
    animation: otpFadeIn 0.2s ease;
}

/* ============================================================
   SHAKE ANIMATION (wrong code)
   ============================================================ */
.otp-shake {
    animation: otpShake 0.45s ease;
}

@keyframes otpShake {
    0%, 100% { transform: translateX(0); }
    15%      { transform: translateX(-10px); }
    30%      { transform: translateX(10px); }
    45%      { transform: translateX(-8px); }
    60%      { transform: translateX(8px); }
    75%      { transform: translateX(-4px); }
    90%      { transform: translateX(4px); }
}

/* ============================================================
   SUCCESS STEP
   ============================================================ */
#otp-step-success .otp-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    font-size: 34px;
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.2);
    animation: otpPop 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes otpPop {
    0%   { transform: scale(0.3); opacity: 0; }
    60%  { transform: scale(1.08); }
    100% { transform: scale(1); opacity: 1; }
}

#otp-step-success h2 {
    color: #166534;
}

#otp-step-success p {
    color: #16a34a;
    font-weight: 500;
}

/* ============================================================
   FOOTER / BRANDING
   ============================================================ */
.otp-footer {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.otp-logo {
    width: auto;
    height: 40px;
    object-fit: contain;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.otp-logo:hover {
    opacity: 1;
}

/* ============================================================
   STEP VISIBILITY
   ============================================================ */
.otp-step {
    display: none;
}

.otp-step.active {
    display: block;
    animation: otpStepIn 0.3s ease;
}

@keyframes otpStepIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
    .otp-modal {
        padding: 32px 24px 24px;
        border-radius: 20px;
        margin: 12px;
    }

    .otp-modal h2 {
        font-size: 20px;
    }

    .otp-modal p {
        font-size: 13.5px;
    }

    .otp-icon {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    .otp-phone-input-wrap .select2-container {
        min-width: 110px !important;
        max-width: 130px !important;
    }

    .otp-s2-selected {
        font-size: 13px;
    }

    .otp-select2-dropdown.select2-dropdown {
        width: 260px !important;
    }

    .otp-phone-input {
        padding: 12px 14px;
        font-size: 15px;
    }

    .otp-digit {
        width: 42px;
        height: 50px;
        font-size: 20px;
        border-radius: 12px;
    }

    .otp-code-inputs {
        gap: 6px;
    }

    .otp-btn.otp-btn-primary {
        padding: 14px 20px;
        font-size: 15px;
    }

    .otp-resend-wrap {
        flex-wrap: wrap;
        gap: 6px;
    }

    .otp-footer {
        margin-top: 20px;
        padding-top: 16px;
    }
}
