/* Phone Number Validation Styles */

.phone-input {
    position: relative;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Validation states */
.phone-input.phone-valid {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

.phone-input.phone-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.phone-input.phone-partial {
    border-color: #ffc107;
    box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.25);
}

/* Validation icons */
.phone-input.phone-valid::after {
    content: '\f00c';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #28a745;
    pointer-events: none;
}

.phone-input.phone-invalid::after {
    content: '\f00d';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #dc3545;
    pointer-events: none;
}

.phone-input.phone-partial::after {
    content: '\f071';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #ffc107;
    pointer-events: none;
}

/* Validation messages */
.phone-validation-message {
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.phone-validation-message.show {
    display: block;
}

/* Format hints */
.phone-format-hint {
    font-size: 0.8rem;
    margin-top: 0.25rem;
    color: #6c757d;
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.phone-format-hint.show {
    display: block;
}

.phone-format-hint i {
    opacity: 0.7;
}

/* Input focus states */
.phone-input:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.phone-input:focus.phone-valid {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

.phone-input:focus.phone-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.phone-input:focus.phone-partial {
    border-color: #ffc107;
    box-shadow: 0 0 0 0.2rem rgba(255, 193, 7, 0.25);
}

/* Country code suggestions */
.phone-country-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.phone-country-suggestion {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    display: flex;
    align-items: center;
    transition: background-color 0.15s ease-in-out;
}

.phone-country-suggestion:hover {
    background-color: #f8f9fa;
}

.phone-country-suggestion:last-child {
    border-bottom: none;
}

.phone-country-flag {
    width: 20px;
    height: 15px;
    margin-right: 0.5rem;
    border-radius: 2px;
}

.phone-country-code {
    font-weight: 600;
    color: #495057;
    margin-right: 0.5rem;
}

.phone-country-name {
    color: #6c757d;
    font-size: 0.875rem;
}

/* Form group enhancements */
.form-group.phone-input-group {
    position: relative;
}

.form-group.phone-input-group .form-control {
    padding-right: 2.5rem;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .phone-format-hint {
        font-size: 0.75rem;
    }
    
    .phone-validation-message {
        font-size: 0.8rem;
    }
}

/* Animation keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-2px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(2px);
    }
}

/* Error shake animation */
.phone-input.shake {
    animation: shake 0.5s ease-in-out;
}

/* Loading state */
.phone-input.loading {
    background-image: url("data:image/svg+xml,%3csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M10 3.5a6.5 6.5 0 1 0 6.5 6.5h-2a4.5 4.5 0 1 1-4.5-4.5V3.5z' fill='%23007bff'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px 16px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .phone-country-suggestions {
        background: #343a40;
        border-color: #495057;
    }
    
    .phone-country-suggestion {
        border-bottom-color: #495057;
        color: #f8f9fa;
    }
    
    .phone-country-suggestion:hover {
        background-color: #495057;
    }
    
    .phone-country-code {
        color: #f8f9fa;
    }
    
    .phone-country-name {
        color: #adb5bd;
    }
}

/* Integration with Bootstrap validation */
.was-validated .phone-input:valid,
.phone-input.is-valid {
    border-color: #28a745;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='m2.3 6.73.94-.94 1.38 1.38 3.72-3.72.94.94-4.66 4.66z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.was-validated .phone-input:invalid,
.phone-input.is-invalid {
    border-color: #dc3545;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23dc3545' viewBox='0 0 12 12'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 4.6 2.4 2.4m0-2.4L5.8 7'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}
