/* ESTILOS BÁSICOS DEL SELECTOR EN CABECERA */
.country_selector {
    margin: 1rem;
}

.country_selector .expand-more {
    cursor: pointer;
    text-decoration: none;
}

.country_selector .expand-more::selection {
    background: none;
}

#index .header-top .country-selector a.expand-more:not(.btn):not(.nav-link),
#index .header-top .language-selector-new a.expand-more:not(.btn):not(.nav-link),
#index .country-tag,
#index .language-tag {
    color: #ffffff;    
}

.header-top .country-selector a.expand-more:not(.btn):not(.nav-link) {
    padding-right: 1rem;
}

/* ESTILOS DEL MODAL */
#countryModal {
    z-index: 10000;
}

.modal-backdrop {
    z-index: 9999 !important;
}

#countryModal .modal-dialog {
    margin: 10vh auto;
    max-width: 500px;
}

#countryModal .modal-content {
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

#countryModal .modal-body {
    padding: 20px;
    max-height: 80vh;
}

#countryModal .modal-title {
    text-align: center;
    width: 100%;
    font-size: 1.5rem;
    font-weight: 600;
}

/* ESTILOS DEL BOTÓN DE GUARDAR */
#saveCountry {
    background-color: #000;
    color: #fff;
    padding: 10px 30px;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    min-width: 170px;
    transition: all 0.2s;
}

#saveCountry:hover {
    background-color: #333;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Estilos para el spinner dentro del botón */
#saveCountry .spinner-border {
    margin-right: 8px;
    vertical-align: middle;
    width: 1rem;
    height: 1rem;
    display: inline-block;
}

/* ESTILOS DEL SPINNER */
#loadingSpinner {
    display: none;
    margin: 30px auto;
}

/* ESTILOS DEL CONTENEDOR DE SELECTOR */
.country-selector-container {
    max-width: 450px;
    margin: 0 auto;
    padding: 15px;
}

/* ESTILOS PARA EL MODO GRID */
.zones-container {
    margin-top: 20px;
}

.zone-block {
    margin-bottom: 30px;
}

.zone-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid #dee2e6;
    color: #333;
}

.country-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.country-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 5px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.country-item:hover {
    background-color: #f8f9fa;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.1rem rgba(0,123,255,.15);
}

.country-item.active {
    background-color: #f0f7ff;
    border-color: #007bff;
}

.flag-wrapper {
    width: 60px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    overflow: hidden;
}

.country-flag {
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.country-name {
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 2.4rem;
}

/* ESTILOS PARA SELECT2 */
/* Contenedor principal */
.select2-container {
    width: 100% !important;
    margin-bottom: 15px;
    position: relative;
}

/* Estilo del selector visible */
.select2-container .select2-selection--single {
    height: 45px !important;
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 45px !important;
    padding-left: 12px !important;
    color: #333 !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 45px !important;
}

/* Dropdown y opciones */
.select2-dropdown {
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2) !important;
    background-color: white !important;
    z-index: 20000 !important; /* Por encima del modal */
}

.select2-results {
    padding: 0 !important;
}

.select2-results__options {
    max-height: 350px !important;
    overflow-y: auto !important;
}

.select2-results__option {
    padding: 10px 15px !important;
    line-height: 1.4 !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #f0f7ff !important;
    color: #333 !important;
}

/* Campo de búsqueda */
.select2-search--dropdown {
    padding: 10px !important;
    background-color: #f9f9f9 !important;
    border-bottom: 1px solid #eee !important;
}

.select2-search--dropdown .select2-search__field {
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
    padding: 8px 10px !important;
    height: 40px !important;
    font-size: 15px !important;
    width: 100% !important;
}

/* Estilos específicos para las banderas */
.country-flag {
    vertical-align: middle;
    width: 20px;
    height: 15px;
    margin-right: 8px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.1);
    object-fit: cover;
}

/* Estilos para países desactivados */
.inactive-country-item {
    opacity: 0.7;
    border: 1px dashed #e0e0e0;
}

.inactive-country-item:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    box-shadow: none;
}

.inactive-label {
    display: block;
    font-size: 0.7rem;
    color: #6c757d;
    font-style: italic;
    margin-top: 2px;
}

.inactive-zone .zone-title {
    color: #6c757d;
    border-bottom: 1px dashed #dee2e6;
}

/* Estilos para opciones inactivas en Select2 */
.select2-results__option .inactive-country {
    color: #6c757d;
    font-style: italic;
}

optgroup[label="Países desactivados"] {
    color: #6c757d;
    font-style: italic;
}

/* RESPONSIVE */
@media (max-width: 767.98px) {
    .country-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }
    
    .flag-wrapper {
        width: 50px;
        height: 35px;
    }
    
    .select2-dropdown {
        max-width: 100% !important;
        width: 100% !important;
    }
}

@media (max-width: 575.98px) {
    #countryModal .modal-dialog {
        margin: 5vh auto;
        max-width: 95%;
    }
    
    .country-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 5px;
    }
    
    .country-item {
        padding: 8px 3px;
    }
    
    .flag-wrapper {
        width: 40px;
        height: 30px;
    }
    
    .country-name {
        font-size: 0.7rem;
    }
    
    .select2-search--dropdown .select2-search__field {
        font-size: 16px !important; /* Evita zoom en iOS */
    }
}