/**
 * Geodata Widgets Stylesheet
 * Clean, modern styling for country and city Select2 widgets
 */

/* ============================================
   Custom Select2 Theme: geodata
   ============================================ */

.select2-container--geodata .select2-selection--single {
    height: 44px;
    border: 1.5px solid #e1e8ed;
    border-radius: 8px;
    background: #ffffff;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.select2-container--geodata .select2-selection--single:hover {
    border-color: #c1d0db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.select2-container--geodata.select2-container--focus .select2-selection--single,
.select2-container--geodata.select2-container--open .select2-selection--single {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1),
                0 2px 4px rgba(0, 0, 0, 0.06);
    outline: none;
}

/* Selection box: position clear (x) on the right so it never shifts content */
.select2-container--geodata .select2-selection--single {
    position: relative;
}

.select2-container--geodata .select2-selection--single .select2-selection__clear {
    position: absolute;
    right: 44px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    z-index: 1;
}

.select2-container--geodata .select2-selection--single .select2-selection__rendered {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    color: #1f2937;
    line-height: 1;
    padding-left: 16px;
    padding-right: 52px;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    min-width: 0;
    height: 100%;
}

/* Selection content (icon + text) - properly aligned */
.select2-container--geodata .select2-selection__rendered .geodata-country-selection,
.select2-container--geodata .select2-selection__rendered .geodata-city-selection {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    text-align: left;
    gap: 8px;
}

.select2-container--geodata .select2-selection--single .select2-selection__placeholder {
    color: #9ca3af;
    font-weight: 400;
}

.select2-container--geodata .select2-selection--single .select2-selection__arrow {
    height: 42px;
    width: 40px;
    right: 4px;
}

.select2-container--geodata .select2-selection--single .select2-selection__arrow b {
    border-color: #6b7280 transparent transparent transparent;
    border-style: solid;
    border-width: 6px 5px 0 5px;
    height: 0;
    left: 50%;
    margin-left: -5px;
    margin-top: -3px;
    position: absolute;
    top: 50%;
    width: 0;
}

.select2-container--geodata.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent #6b7280 transparent;
    border-width: 0 5px 6px 5px;
}

/* Disabled state */
.select2-container--geodata.select2-container--disabled .select2-selection--single,
.select2-container--geodata.geodata-city-requires-country .select2-selection--single {
    background-color: #f9fafb;
    border-color: #e5e7eb;
    cursor: not-allowed;
    opacity: 0.6;
}

/* City widget: no interaction until country is selected */
.select2-container--geodata.geodata-city-requires-country {
    pointer-events: none;
}

/* ============================================
   Dropdown Styling
   ============================================ */

.select2-container--geodata .select2-dropdown {
    border: 1.5px solid #e1e8ed;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1),
                0 4px 10px rgba(0, 0, 0, 0.05);
    margin-top: 4px;
}

.select2-container--geodata .select2-search--dropdown {
    padding: 12px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.select2-container--geodata .select2-search--dropdown .select2-search__field {
    border: 1.5px solid #e1e8ed;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
}

.select2-container--geodata .select2-search--dropdown .select2-search__field:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.select2-container--geodata .select2-results__options {
    max-height: 320px;
    padding: 4px 4px 4px 8px;
}

.select2-container--geodata .select2-results__option {
    padding: 12px 14px 12px 16px;
    border-radius: 6px;
    margin-bottom: 2px;
    transition: all 0.15s ease;
    cursor: pointer;
    text-align: left;
}

/* Align dropdown result content (flag/icon + text) with selection box */
.select2-container--geodata .select2-results__option .geodata-country-result,
.select2-container--geodata .select2-results__option .geodata-city-result {
    text-align: left;
    justify-content: flex-start;
}

.select2-container--geodata .select2-results__option:hover,
.select2-container--geodata .select2-results__option--highlighted {
    background-color: #f0f7ff;
    color: #1e40af;
}

.select2-container--geodata .select2-results__option[aria-selected=true] {
    background-color: #eff6ff;
    color: #1e40af;
    font-weight: 500;
}

.select2-container--geodata .select2-results__option[aria-disabled=true] {
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.5;
}

.select2-container--geodata .select2-results__message {
    padding: 20px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* Loading spinner */
.select2-container--geodata .select2-results__option--loading {
    padding: 20px;
    text-align: center;
    color: #3b82f6;
}

/* ============================================
   Country Result Formatting
   ============================================ */

.geodata-country-result {
    display: flex;
    align-items: center;
    gap: 10px;
}

.geodata-country-flag {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

.geodata-country-name {
    flex: 1;
    font-weight: 500;
    color: #1f2937;
}

.geodata-country-code {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* ============================================
   Country Selection Formatting
   ============================================ */

.geodata-country-selection {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.geodata-country-selection .geodata-country-flag {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin: 0;
    padding: 0;
}

.geodata-country-selection .geodata-country-name {
    font-weight: 500;
    color: #1f2937;
    flex: 1;
    min-width: 0;
}

/* ============================================
   City Result Formatting
   ============================================ */

.geodata-city-result {
    display: flex;
    align-items: center;
    gap: 10px;
}

.geodata-city-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.7;
}

.geodata-city-name {
    font-weight: 500;
    color: #1f2937;
}

.geodata-city-region {
    font-size: 13px;
    color: #6b7280;
    margin-left: auto;
    font-weight: 400;
}

/* ============================================
   City Selection Formatting
   ============================================ */

.geodata-city-selection {
    display: flex;
    align-items: center;
    gap: 8px;
}

.geodata-city-selection .geodata-city-icon {
    font-size: 14px;
}

.geodata-city-selection .geodata-city-name {
    font-weight: 500;
    color: #1f2937;
}

/* ============================================
   Form Field Container Styling
   ============================================ */

.geodata-field-group {
    margin-bottom: 20px;
}

.geodata-field-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #374151;
}

.geodata-field-group .helptext {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
}

.geodata-field-group .errorlist {
    margin: 6px 0 0 0;
    padding: 0;
    list-style: none;
}

.geodata-field-group .errorlist li {
    color: #dc2626;
    font-size: 13px;
    font-weight: 500;
    margin-top: 4px;
}

/* Error state */
.geodata-field-group.has-error .select2-container--geodata .select2-selection--single {
    border-color: #dc2626;
}

.geodata-field-group.has-error .select2-container--geodata .select2-selection--single:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 640px) {
    .select2-container--geodata .select2-selection--single {
        height: 48px;
    }
    
    .select2-container--geodata .select2-selection--single .select2-selection__rendered {
        line-height: 45px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .geodata-country-code {
        display: none; /* Hide on mobile for cleaner look */
    }
    
    .geodata-city-region {
        font-size: 12px;
    }
}

/* Dark mode disabled so country/city dropdowns match the (light) registration form
   on all devices. To re-enable, use an opt-in class e.g. body.theme-dark and
   scope these rules under .theme-dark .select2-container--geodata */

/* ============================================
   Animations
   ============================================ */

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.select2-container--geodata.select2-container--open .select2-dropdown {
    animation: slideDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Accessibility
   ============================================ */

.select2-container--geodata .select2-selection--single:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .select2-container--geodata .select2-selection--single {
        border-width: 2px;
    }
    
    .select2-container--geodata.select2-container--focus .select2-selection--single {
        border-width: 3px;
    }
}
