/* 
 * International Phone Number Input Component
 * Includes country code selector with flags
 * Author: Corvanta Development Team
 */

.phone-input-wrapper {
    display: flex;
    gap: 12px;
    width: 100%;
    align-items: stretch;
    box-sizing: border-box;
}

.country-code-select {
    flex: 0 0 auto;
    min-width: 115px;
    max-width: 135px;
    padding: 12px 16px;
    font-size: 15px;
    font-family: inherit;
    color: #1a202c;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a5568' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px;
    padding-right: 2.25rem;
    box-sizing: border-box;
}

.country-code-select:hover {
    border-color: #cbd5e0;
    background-color: white;
}

.country-code-select:focus {
    outline: none;
    border-color: #2563eb;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.country-code-select option {
    padding: 8px;
    font-size: 15px;
    background: white;
    color: #1a202c;
}

.phone-number-input {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    font-size: 15px;
    font-family: inherit;
    color: #1a202c;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.phone-number-input::placeholder {
    color: #a0aec0;
}

.phone-number-input:hover {
    border-color: #cbd5e0;
    background-color: white;
}

.phone-number-input:focus {
    outline: none;
    border-color: #2563eb;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Error state */
.phone-input-wrapper.has-error .country-code-select,
.phone-input-wrapper.has-error .phone-number-input {
    border-color: #ef4444;
    background: #fef2f2;
}

.phone-input-wrapper.has-error .country-code-select:focus,
.phone-input-wrapper.has-error .phone-number-input:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Success state */
.phone-input-wrapper.has-success .country-code-select,
.phone-input-wrapper.has-success .phone-number-input {
    border-color: #10b981;
    background: #f0fdf4;
}

.phone-input-wrapper.has-success .country-code-select:focus,
.phone-input-wrapper.has-success .phone-number-input:focus {
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .phone-input-wrapper {
        gap: 10px;
    }
    
    .country-code-select {
        min-width: 105px;
        max-width: 115px;
        padding: 11px 14px;
        font-size: 14px;
        padding-right: 2rem;
    }
    
    .phone-number-input {
        padding: 11px 14px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .phone-input-wrapper {
        gap: 8px;
    }
    
    .country-code-select {
        min-width: 95px;
        max-width: 105px;
        padding: 10px 12px;
        font-size: 13px;
        background-size: 9px;
        padding-right: 1.9rem;
    }
    
    .phone-number-input {
        padding: 10px 12px;
        font-size: 13px;
    }
}

@media (max-width: 375px) {
    .phone-input-wrapper {
        gap: 6px;
    }
    
    .country-code-select {
        min-width: 85px;
        max-width: 95px;
        padding: 10px 10px;
        font-size: 13px;
        background-size: 8px;
        background-position: right 8px center;
        padding-right: 1.75rem;
    }
    
    .phone-number-input {
        padding: 10px 10px;
        font-size: 13px;
    }
}

/* For Bootstrap integration */
.form-control.country-code-select,
.form-control.phone-number-input {
    height: auto;
}

/* Invalid feedback styling */
.phone-input-wrapper + .invalid-feedback,
.phone-input-wrapper + .form-error {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: #e74c3c;
}

/* Success state (optional) */
.phone-input-wrapper.is-valid .country-code-select,
.phone-input-wrapper.is-valid .phone-number-input {
    border-color: #27ae60;
}

.phone-input-wrapper.is-valid .country-code-select:focus,
.phone-input-wrapper.is-valid .phone-number-input:focus {
    box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.15);
}

/* Loading state */
.phone-input-wrapper.is-loading .country-code-select,
.phone-input-wrapper.is-loading .phone-number-input {
    opacity: 0.6;
    pointer-events: none;
}

/* Dark theme support (optional) */
@media (prefers-color-scheme: dark) {
    .country-code-select,
    .phone-number-input {
        background-color: #2c3e50;
        color: #ecf0f1;
        border-color: #34495e;
    }
    
    .country-code-select:hover,
    .phone-number-input:hover {
        border-color: #5dade2;
    }
    
    .phone-number-input::placeholder {
        color: #95a5a6;
    }
}
