/* Country Phone Selector Styles */
.country-phone-selector {
    position: relative;
}

.country-dropdown-container {
    position: relative;
    z-index: 1000;
}

.country-selector-btn {
    border-radius: 0.375rem 0 0 0.375rem !important;
    border-right: none !important;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    justify-content: space-between;
    background: white;
    color: #495057;
    border: 1px solid #ced4da;
    padding: 0.375rem 0.75rem;
    height: calc(2.25rem + 2px);
}

.country-selector-btn:hover {
    background-color: #f8f9fa;
    border-color: #adb5bd;
    color: #495057;
}

.country-selector-btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    border-color: #86b7fe;
}

/* Dark Theme Support */
[data-bs-theme=dark] .country-selector-btn {
    background-color: #1e1e1e;
    color: #7c8fac;
    border-color: #313131;
}

[data-bs-theme=dark] .country-selector-btn:hover {
    background-color: #465670;
    border-color: #333f55;
    color: #eaeff4;
}

[data-bs-theme=dark] .country-selector-btn:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.country-selector-btn .flag-icon {
    width: 20px;
    height: 15px;
    flex-shrink: 0;
}

.country-code {
    font-weight: 500;
    min-width: 35px;
    text-align: left;
}

.country-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1050;
    display: none;
    min-width: 280px;
}

.country-dropdown.show {
    display: block;
    animation: dropdownFadeIn 0.15s ease-out;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.country-search-container {
    padding: 0.5rem;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.country-search {
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    width: 100%;
    box-sizing: border-box;
}

.country-search:focus {
    outline: none;
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Dark Theme for Dropdown */
[data-bs-theme=dark] .country-dropdown {
    background: #202936;
    border-color: #333f55;
    box-shadow: rgba(145, 158, 171, 0.3) 0px 0px 2px 0px, rgba(145, 158, 171, 0.02) 0px 12px 24px -4px;
}

[data-bs-theme=dark] .country-search-container {
    background: #202936;
    border-bottom-color: #333f55;
}

[data-bs-theme=dark] .country-search {
    background-color: #1e1e1e;
    border-color: #313131;
    color: #7c8fac;
}

[data-bs-theme=dark] .country-search:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.country-list {
    max-height: 240px;
    overflow-y: auto;
}

.country-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.15s ease;
    gap: 12px;
}

.country-item:hover {
    background-color: #f8f9fa;
}

.country-item:last-child {
    border-bottom: none;
}

.country-item.selected {
    background-color: #e7f3ff;
    color: #0066cc;
}

/* Dark Theme for Country Items */
[data-bs-theme=dark] .country-item {
    border-bottom-color: #333f55;
    color: #7c8fac;
}

[data-bs-theme=dark] .country-item:hover {
    background-color: #333f55;
    color: #eaeff4;
}

[data-bs-theme=dark] .country-item.selected {
    background-color: #465670;
    color: #86b7fe;
}

.country-item .flag-icon {
    width: 24px;
    height: 18px;
    flex-shrink: 0;
}

.country-details {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
}

.country-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.country-dial-code {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 500;
    margin-left: auto;
    flex-shrink: 0;
}

/* Phone input adjustments */
.country-phone-selector .input-group {
    display: flex !important;
    flex-wrap: nowrap !important;
}

.country-phone-selector .form-control[name="tel"] {
    border-radius: 0 0.375rem 0.375rem 0 !important;
    border-left: none !important;
    padding-left: 1rem;
    margin-left: -1px !important;
}

.country-phone-selector .form-control[name="tel"]:focus {
    border-left: none !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    z-index: 3;
}

/* Dark Theme for Country Dial Code and Phone Input */
[data-bs-theme=dark] .country-dial-code {
    color: #7c8fac;
}

[data-bs-theme=dark] .country-phone-selector .form-control[name="tel"] {
    background-color: #1e1e1e;
    border-color: #313131;
    color: #7c8fac;
}

[data-bs-theme=dark] .country-phone-selector .form-control[name="tel"]:focus {
    border-color: #313131;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Additional border fixes for seamless connection */
.country-phone-selector .country-dropdown-container {
    flex-shrink: 0;
}

.country-phone-selector .country-selector-btn {
    border-right: 1px solid #ced4da !important;
}

[data-bs-theme=dark] .country-phone-selector .country-selector-btn {
    border-right: 1px solid #313131 !important;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .country-dropdown {
        min-width: 100%;
        left: 0;
        right: 0;
    }
    
    .country-selector-btn {
        min-width: 80px;
    }
    
    .country-code {
        min-width: 30px;
        font-size: 0.85rem;
    }
    
    .country-name {
        font-size: 0.85rem;
    }
}

/* Custom scrollbar */
.country-list::-webkit-scrollbar {
    width: 6px;
}

.country-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.country-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.country-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Loading state */
.country-list.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #6c757d;
}

/* No results state */
.no-results {
    padding: 1rem;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Error state */
.error-state {
    padding: 1rem;
    text-align: center;
    color: #dc3545;
}

/* Dark Theme for States */
[data-bs-theme=dark] .no-results {
    color: #7c8fac;
}

[data-bs-theme=dark] .error-state {
    color: #ff6b6b;
}

[data-bs-theme=dark] .country-list.loading {
    color: #7c8fac;
}