/**
 * Country Code Selector Styles for TextMe SMS Integration
 *
 * @package TextMe_SMS
 * @since 2.0.0
 */

/* Phone Number Input Group */
.textme-phone-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
}

.textme-phone-input-group.disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* Country Code Selector */
.textme-country-selector {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.textme-country-selector:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

.textme-country-selector:hover {
    border-color: #999;
}

/* Select2 Country Selector */
.textme-country-selector {
    flex-shrink: 0;
    width: auto;
    min-width: 80px;
    max-width: 100px;
}

/* Select2 Custom Styling */
.select2-container--default .select2-selection--single {
    height: 38px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    transition: border-color 0.2s ease;
}

.select2-container--default .select2-selection--single:hover {
    border-color: #999;
}

.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
    outline: none;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
    padding-left: 12px;
    padding-right: 20px;
    font-size: 14px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
    right: 8px;
}

/* Select2 Dropdown */
.select2-dropdown {
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.select2-container--default .select2-results__option {
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.4;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #0073aa;
    color: #fff;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: #f0f6ff;
    color: #0073aa;
}

/* Select2 Search */
.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 14px;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 1px #0073aa;
}

/* Select2 Option Templates */
.textme-select2-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.textme-select2-flag {
    font-size: 16px;
    line-height: 1;
}

.textme-select2-text {
    flex: 1;
}

/* Phone Number Input */
.textme-phone-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
    transition: border-color 0.2s ease;
}

.textme-phone-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

.textme-phone-input:hover {
    border-color: #999;
}

.textme-phone-input::placeholder {
    color: #999;
}

/* Full Width Phone Input (when country selector is hidden) */
.textme-phone-input.full-width {
    width: 100%;
    max-width: 300px;
}

/* International Toggle Message */
.textme-international-notice {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    font-style: italic;
}

.textme-international-notice.enabled {
    color: #0073aa;
}

/* Admin Specific Styles */
.textme-sms-admin .textme-phone-input-group {
    max-width: 500px;
}

.textme-sms-admin .textme-country-selector {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    min-width: 100px;
    max-width: 120px;
}

.textme-sms-admin .select2-container--default .select2-selection--single .select2-selection__rendered {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.textme-sms-admin .select2-container--default .select2-results__option {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.textme-sms-admin .textme-phone-input {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Frontend Styles */
.textme-login-form .textme-phone-input-group,
.textme-stock-notify-form .textme-phone-input-group,
.woocommerce .textme-phone-input-group {
    margin-bottom: 10px;
}

.textme-phone-input-group .select2{
    width: 100px !important;
}

.textme-login-form .textme-country-selector,
.textme-stock-notify-form .textme-country-selector,
.woocommerce .textme-country-selector {
    min-width: 70px;
    max-width: 90px;
}

.textme-login-form .select2-container--default .select2-selection--single,
.textme-stock-notify-form .select2-container--default .select2-selection--single,
.woocommerce .select2-container--default .select2-selection--single {
    border-color: #ccc;
    height: 42px;
}

.textme-login-form .select2-container--default .select2-selection--single .select2-selection__rendered,
.textme-stock-notify-form .select2-container--default .select2-selection--single .select2-selection__rendered,
.woocommerce .select2-container--default .select2-selection--single .select2-selection__rendered {
    font-size: 16px;
    line-height: 40px;
}

.textme-login-form .select2-container--default .select2-selection--single .select2-selection__arrow,
.textme-stock-notify-form .select2-container--default .select2-selection--single .select2-selection__arrow,
.woocommerce .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px;
}

.textme-login-form .textme-phone-input,
.textme-stock-notify-form .textme-phone-input,
.woocommerce .textme-phone-input {
    border-color: #ccc;
    font-size: 16px;
    padding: 10px 12px;
}

/* Responsive Design */
@media (max-width: 600px) {
    .textme-phone-input-group {
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
    }
    
    .textme-country-selector {
        min-width: auto;
        max-width: none;
        width: 100%;
    }
    
    .textme-phone-input {
        width: 100%;
    }
    
    /* Select2 responsive adjustments */
    .select2-container {
        width: 100% !important;
    }
    
    .select2-dropdown {
        max-height: 200px;
    }
}

/* Loading State */
.textme-phone-input-group.loading {
    position: relative;
}

.textme-phone-input-group.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 10px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid #ddd;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: textme-spinner 0.8s linear infinite;
}

@keyframes textme-spinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error State */
.textme-phone-input-group.error .textme-country-selector,
.textme-phone-input-group.error .textme-phone-input {
    border-color: #dc3545;
}

.textme-phone-input-group.error .select2-container--default .select2-selection--single {
    border-color: #dc3545;
}

.textme-phone-input-group.error .textme-international-notice {
    color: #dc3545;
}

/* Success State */
.textme-phone-input-group.success .textme-country-selector,
.textme-phone-input-group.success .textme-phone-input {
    border-color: #28a745;
}

.textme-phone-input-group.success .select2-container--default .select2-selection--single {
    border-color: #28a745;
}

.textme-phone-input-group.success .textme-international-notice {
    color: #28a745;
}

/* Print Styles */
@media print {
    .textme-country-selector,
    .textme-phone-input {
        border: 1px solid #000 !important;
        background: transparent !important;
    }
}
