/**
 * Phone Verification Styles
 * 
 * Custom modal and UI styling for phone verification flow.
 * 
 * @package PhoneVerification
 * @version 1.0.0
 */

/* =============================================================================
   INTL-TEL-INPUT FLAG OVERRIDES
   The flag paths need to be absolute. These are set dynamically via inline CSS.
   ============================================================================= */

.iti__flag-container {
    z-index: 99999 !important;
}

.iti--separate-dial-code .iti__selected-flag {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Ensure dropdown is visible */
.iti__country-list {
    z-index: 999999 !important;
    max-height: 200px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* =============================================================================
   PHONE INPUT CONTAINER
   ============================================================================= */

.gdlr-phone-verification-wrapper {
    position: relative;
}

.gdlr-phone-input-container {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-top: 5px;
}

.gdlr-phone-input-container.disabled {
    opacity: 0.8;
    pointer-events: none;
}

/* Phone input field */
#gdlr-phone-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    padding-left: 90px !important; /* Space for country selector */
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 15px;
    transition: border-color 0.2s ease;
    width: 100%;
}

#gdlr-phone-input:focus {
    outline: none;
    border-color: #c9a961;
    box-shadow: 0 0 0 2px rgba(201, 169, 97, 0.1);
}

#gdlr-phone-input:read-only {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

/* Verify button */
#gdlr-verify-phone-btn {
    flex-shrink: 0;
    padding: 10px 20px;
    background-color: #c9a961;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

#gdlr-verify-phone-btn:hover {
    background-color: #b8954d;
}

#gdlr-verify-phone-btn:disabled,
#gdlr-verify-phone-btn.loading {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Phone status area */
.gdlr-phone-status {
    margin-top: 8px;
    min-height: 24px;
    display: none;
}

.gdlr-phone-verification-wrapper.verified .gdlr-phone-status {
    display: block;
}

/* Verified badge - hidden by default, shown via JS when verified */
.gdlr-phone-verified-badge {
    display: none !important;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background-color: #d4edda;
    color: #155724;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* When wrapper has verified class, show the badge */
.gdlr-phone-verification-wrapper.verified .gdlr-phone-verified-badge {
    display: inline-flex !important;
}

.gdlr-phone-verified-badge i,
.gdlr-phone-verified-badge .fa {
    color: #28a745;
}

/* Field error message */
.gdlr-phone-field-error {
    margin-top: 8px;
    padding: 8px 12px;
    background-color: #f8d7da;
    color: #721c24;
    border-radius: 4px;
    font-size: 13px;
}

/* Verified state */
.gdlr-phone-verification-wrapper.verified #gdlr-verify-phone-btn {
    display: none;
}

/* =============================================================================
   INTL-TEL-INPUT OVERRIDES
   ============================================================================= */

.iti {
    flex: 1;
    width: 100%;
}

.iti__flag-container {
    padding: 0;
}

.iti__selected-flag {
    padding: 0 10px;
    background-color: #f8f9fa;
    border-right: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
}

.iti__selected-dial-code {
    margin-left: 8px;
    font-size: 14px;
    color: #333;
}

.iti__country-list {
    z-index: 100000;
    max-height: 250px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.iti__country {
    padding: 10px 12px;
}

.iti__country:hover {
    background-color: #f5f5f5;
}

.iti__country.iti__highlight {
    background-color: #e8f4fd;
}

/* =============================================================================
   MODAL OVERLAY
   ============================================================================= */

.gdlr-phone-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s ease, visibility 0.1s ease;
    padding: 20px;
}

.gdlr-phone-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* =============================================================================
   MODAL CONTAINER
   ============================================================================= */

.gdlr-phone-modal {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 2px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.1s ease;
    overflow: hidden;
}

.gdlr-phone-modal-overlay.active .gdlr-phone-modal {
    transform: translateY(0) scale(1);
}

/* Close button */
.gdlr-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gdlr-modal-close:hover {
    background: #eee;
    color: #333;
}

/* Modal content */
.gdlr-modal-content {
    padding: 40px 32px;
    text-align: center;
}

/* Modal icon */
.gdlr-modal-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, #c9a961 0%, #d4b875 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gdlr-modal-icon svg {
    color: #fff;
}

/* Modal title */
.gdlr-modal-title {
    margin: 0 0 12px;
    font-size: 24px;
    font-weight: 600;
    color: #1a1a1a;
}

/* Modal subtitle */
.gdlr-modal-subtitle {
    margin: 0 0 32px;
    font-size: 15px;
    color: #666;
    line-height: 1.5;
}

.gdlr-phone-display {
    display: block;
    font-weight: 600;
    color: #333;
    margin-top: 4px;
    font-size: 16px;
}

/* =============================================================================
   OTP INPUT BOXES
   ============================================================================= */

.gdlr-otp-container {
    margin-bottom: 24px;
}

.gdlr-otp-inputs {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap; /* allow wrapping on narrow screens */
}

.gdlr-otp-input {
        width: 30px;
    height: 38px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    border: 2px solid #ddd !important;
    border-radius: 10px;
    background: #fafafa;
    transition: all 0.2s ease;
    caret-color: #c9a961;
}

.gdlr-otp-input:focus {
    outline: none;
    border-color: #c9a961;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(201, 169, 97, 0.15);
}

.gdlr-otp-input::-webkit-outer-spin-button,
.gdlr-otp-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.gdlr-otp-input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Shake animation for errors */
.gdlr-otp-inputs.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Error state for OTP inputs */
.gdlr-otp-inputs.error .gdlr-otp-input {
    border-color: #dc3545;
    background: #fff5f5;
}

/* =============================================================================
   MODAL ERROR MESSAGE
   ============================================================================= */

.gdlr-modal-error {
    margin-bottom: 20px;
    padding: 12px 16px;
    background-color: #f8d7da;
    color: #721c24;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
}

/* =============================================================================
   VERIFY CODE BUTTON
   ============================================================================= */

.gdlr-verify-code-btn {
    width: 60%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #c9a961 0%, #b8954d 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(201, 169, 97, 0.3);
}

.gdlr-verify-code-btn:hover {
    background: linear-gradient(135deg, #b8954d 0%, #a78540 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(201, 169, 97, 0.4);
}

.gdlr-verify-code-btn:active {
    transform: translateY(0);
}

.gdlr-verify-code-btn:disabled,
.gdlr-verify-code-btn.loading {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* =============================================================================
   RESEND SECTION
   ============================================================================= */

.gdlr-resend-container {
    margin-top: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.gdlr-resend-btn {
    padding: 8px 16px;
    background: transparent;
    color: #c9a961;
    border: 1px solid #c9a961;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.gdlr-resend-btn:hover:not(:disabled) {
    background: #c9a961;
    color: #fff;
}

.gdlr-resend-btn:disabled {
    color: #999;
    border-color: #ddd;
    cursor: not-allowed;
}

.gdlr-countdown {
    font-size: 13px;
    color: #888;
    font-weight: 500;
}

.gdlr-retries-left {
    font-size: 12px;
    color: #999;
}

/* =============================================================================
   RESPONSIVE STYLES
   ============================================================================= */

@media (max-width: 1100px) {
    .gdlr-phone-input-container {
        flex-wrap: wrap;
    }

    #gdlr-phone-input {
        flex: 1 1 100%;
    }

    #gdlr-verify-phone-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .gdlr-phone-input-container {
        flex-direction: column;
    }

    #gdlr-verify-phone-btn {
        width: 100%;
    }

    .gdlr-phone-modal {
        max-width: 100%;
        border-radius: 12px;
    }

    .gdlr-modal-content {
        padding: 32px 24px;
    }

    .gdlr-modal-content {
        padding: 24px 16px;
    }

    .gdlr-otp-inputs {
        gap: 4px;
        justify-content: center;
    }

    .gdlr-otp-input {
        width: 24px;
        height: 32px;
        font-size: 18px;
    }

    .gdlr-modal-title {
        font-size: 20px;
    }

    .gdlr-modal-icon {
        width: 64px;
        height: 64px;
    }

    .gdlr-modal-icon svg {
        width: 48px;
        height: 48px;
    }
}

@media (max-width: 360px) {
    .gdlr-modal-content {
        padding: 20px 12px;
    }

    .gdlr-otp-inputs {
        gap: 3px;
    }

    .gdlr-otp-input {
                width: 24px;
        height: 32px;
        font-size: 16px;
    }
}

/* =============================================================================
   LOADING SPINNER (for buttons)
   ============================================================================= */

.gdlr-verify-phone-btn.loading,
.gdlr-verify-code-btn.loading {
    position: relative;
    color: transparent !important;
}

.gdlr-verify-phone-btn.loading::after,
.gdlr-verify-code-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =============================================================================
   SUCCESS ANIMATION
   ============================================================================= */

.gdlr-verification-success {
    animation: successPop 0.4s ease;
}

@keyframes successPop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}
