/* Phone Verification Styles */
.phone-verification-container {
    width: 100%;
}

.phone-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* Enhanced country code wrapper */
.country-code-wrapper {
    position: relative;
    min-width: 200px;
    flex-shrink: 0;
}

.country-code-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.country-code-select:hover {
    border-color: #0073aa;
}

/* Enhanced select styling for grouped options */
.country-code-select optgroup {
    font-weight: bold;
    font-size: 13px;
    color: #0073aa;
    background: #f8f9fa;
    padding: 8px 4px 4px 4px;
}

.country-code-select option {
    padding: 6px 8px;
    font-size: 14px;
    background: white;
    color: #333;
}

.country-code-select option:hover {
    background: #f0f8ff;
}

.phone-number-input {
    flex: 1;
    min-width: 120px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* Readonly styles for logged-in users */
.phone-number-input[readonly] {
    background-color: #f9f9f9;
    color: #333;
    border-color: #ccc;
    cursor: default;
}

.country-code-select:disabled {
    background-color: #f9f9f9;
    color: #333;
    border-color: #ccc;
    cursor: default;
}

.logged-in-phone-notice {
    font-size: 13px;
    color: #155724;
    margin-top: 8px;
    padding: 8px 12px;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    border-left: 4px solid #28a745;
}

.verify-phone-btn, .verify-otp-btn {
    background: #0073aa;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.verify-phone-btn:hover, .verify-otp-btn:hover {
    background: #005a87;
}

.verify-phone-btn:disabled, .verify-otp-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.verify-phone-btn.verified {
    background: #46b450;
}

.verify-phone-btn.verified:hover {
    background: #46b450;
}

.otp-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
    padding: 12px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 2px dashed #0073aa;
    flex-wrap: wrap;
}

.otp-input {
    width: 80px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 2px;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    flex-shrink: 0;
}

.otp-input:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 5px rgba(0,115,170,0.3);
}

.otp-timer {
    font-size: 12px;
    color: #666;
    margin-left: 10px;
    white-space: nowrap;
}

.verification-status {
    margin-top: 10px;
}

.success-message {
    color: #46b450;
    background: #f0f8ff;
    padding: 8px 12px;
    border-radius: 4px;
    border-left: 3px solid #46b450;
    font-size: 14px;
}

.error-message {
    color: #dc3232;
    background: #fef7f7;
    padding: 8px 12px;
    border-radius: 4px;
    border-left: 3px solid #dc3232;
    font-size: 14px;
}

.verified-message {
    color: #46b450;
    background: #f7fcf7;
    padding: 8px 12px;
    border-radius: 4px;
    border-left: 3px solid #46b450;
    font-size: 14px;
    font-weight: bold;
}

/* Arabic RTL Support */
body.rtl .phone-input-group {
    direction: rtl;
}

body.rtl .country-code-select {
    text-align: right;
}

body.rtl .otp-input-group {
    direction: rtl;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .phone-input-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .country-code-wrapper {
        min-width: 100%;
        margin-bottom: 8px;
    }
    
    .country-code-select {
        min-width: 100%;
    }
    
    .phone-number-input {
        min-width: 100%;
        margin-bottom: 8px;
    }
    
    .verify-phone-btn, .verify-otp-btn {
        min-width: 100%;
        justify-content: center;
        padding: 12px;
        font-size: 16px;
    }
    
    .otp-input-group {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .otp-timer {
        margin-left: 0;
        margin-top: 8px;
    }
    
    .phone-format-hint {
        text-align: center;
    }
    
    .countries-info {
        margin-top: 12px;
        padding: 8px;
        background: #f8f9fa;
        border-radius: 4px;
    }
}

/* Tablet Responsive */
@media (max-width: 1024px) and (min-width: 769px) {
    .country-code-wrapper {
        min-width: 220px;
    }
    
    .phone-number-input {
        flex: 2;
    }
}

/* Loading Animation */
.btn-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Focus States */
.phone-number-input:focus,
.country-code-select:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 5px rgba(0,115,170,0.3);
}

/* Phone Format Hint */
.phone-format-hint {
    margin-top: 5px;
    margin-bottom: 8px;
}

.phone-format-hint small {
    color: #666;
    font-style: italic;
}

/* Countries Info */
.countries-info {
    margin-top: 8px;
    text-align: center;
}

.countries-info small {
    color: #0073aa;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Enhanced Status Messages */
.success-message,
.error-message,
.verified-message {
    border-radius: 6px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
}

.success-message::before {
    content: "✓";
    font-weight: bold;
    color: #46b450;
}

.error-message::before {
    content: "⚠";
    font-weight: bold;
    color: #dc3232;
}

.verified-message::before {
    content: "🎉";
    font-weight: bold;
}

/* Enhanced Country Selection */
.country-code-select.enhanced-select {
    background-image: url("data:image/svg+xml;charset=US-ASCII,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'><path fill='%23666' d='M2 0L0 2h4zm0 5L0 3h4z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
    padding-right: 32px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* Country Flag Emojis Support */
.country-code-select option {
    font-size: 14px;
    padding: 6px 8px;
    line-height: 1.4;
}

/* Loading State Improvements */
.verify-phone-btn.loading,
.verify-otp-btn.loading {
    position: relative;
    color: transparent;
}

.verify-phone-btn.loading::after,
.verify-otp-btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

/* Smooth Animations */
.otp-input-group {
    transition: all 0.3s ease;
}

.verification-status > div {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* High contrast for better accessibility */
@media (prefers-contrast: high) {
    .verify-phone-btn, .verify-otp-btn {
        border: 2px solid #000;
    }
    
    .otp-input {
        border-width: 2px;
    }
    
    .success-message, .error-message, .verified-message {
        border-left-width: 5px;
    }
}