/* Contenedor principal del mapa y buscador */
.mapa-container {
    position: relative;
    margin-bottom: 20px;
}

/* Ocultar el trigger del popup */
#popup-trigger-hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
}

/* Estilos del formulario de búsqueda */
.address-search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: stretch;
}

/* Wrapper del input con autocomplete */
.search-input-wrapper {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.address-search-form input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
    height: 50px;
}

.address-search-form input[type="text"]:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

/* Lista de autocomplete */
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 400px;
    overflow-y: auto;
    z-index: 10000;
    display: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.autocomplete-results li {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    transition: background-color 0.2s;
}

.autocomplete-results li:last-child {
    border-bottom: none;
}

.autocomplete-header {
    background: #f5f5f5 !important;
    font-weight: 600;
    font-size: 12px;
    color: #666;
    cursor: default !important;
    padding: 8px 12px !important;
    letter-spacing: 0.5px;
}

.autocomplete-place:hover,
.autocomplete-doctor:hover {
    background-color: #f5f5f5;
}

.autocomplete-place:active,
.autocomplete-doctor:active {
    background-color: #e8f4f8;
}

.address-search-form .distance-select {
    flex: 0 0 100px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
    height: 50px;
}

.address-search-form .distance-select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

#address-search-form button,
form#address-search-form button[type="submit"],
.address-search-form > button,
.address-search-form button[type="submit"] {
    flex: 0 0 180px;
    padding: 10px 24px !important;
    border: none !important;
    background-color: #0073aa !important;
    color: white !important;
    cursor: pointer;
    border-radius: 4px !important;
    font-size: 14px !important;
    font-weight: 500;
    height: 50px;
    white-space: nowrap;
}

#address-search-form button:hover,
form#address-search-form button[type="submit"]:hover,
.address-search-form > button:hover,
.address-search-form button[type="submit"]:hover {
    background-color: #005a87 !important;
    border-radius: 4px !important;
}

#address-search-form button:active,
form#address-search-form button[type="submit"]:active,
.address-search-form > button:active,
.address-search-form button[type="submit"]:active {
    background-color: #004670 !important;
    border-radius: 4px !important;
}

/* Wrapper de contenido: lista + mapa */
.mapa-content-wrapper {
    display: flex;
    gap: 20px;
    align-items: stretch;
    height: calc(100vh - 200px);
    min-height: 500px;
}

/* Contenedor de la lista de doctores */
.doctors-list-container {
    flex: 0 0 400px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    height: 100%;
}

.doctors-list-header {
    padding: 15px;
    border-bottom: 1px solid #ddd;
    background: #f9f9f9;
    flex-shrink: 0;
}

.header-title-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.doctors-list-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.doctors-list-header .info-btn,
button.info-btn {
    min-width: 24px !important;
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    background-color: #CBF2FE !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    padding: 0 !important;
    flex-shrink: 0;
    position: relative;
    overflow: visible !important;
}

.doctors-list-header .info-btn:before,
.doctors-list-header .info-btn:after,
button.info-btn:before,
button.info-btn:after {
    display: none !important;
    content: none !important;
}

.doctors-list-header .info-btn:hover,
button.info-btn:hover {
    background-color: #B0E8F9 !important;
}

.doctors-list-header .info-btn svg,
button.info-btn svg {
    color: #001d57 !important;
    stroke: #001d57 !important;
    fill: none !important;
    width: 14px !important;
    height: 14px !important;
}

.sort-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.sort-btn {
    padding: 8px 16px;
    background: #001d57;
    border: 1px solid #001d57;
    border-radius: 4px !important;
    cursor: pointer;
    font-size: 12px;
    color: #ffffff !important;
    white-space: nowrap;
}

.sort-btn:hover {
    background: #002d77;
    border-color: #002d77;
    color: #ffffff !important;
    border-radius: 4px !important;
}

.sort-btn.active {
    background: #0073aa;
    border-color: #0073aa;
    font-weight: 500;
    color: #ffffff !important;
}

.results-count {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.doctors-list {
    flex: 1 1 auto;
    overflow-y: scroll;
    overflow-x: hidden;
    min-height: 0;
}

.no-results {
    padding: 30px 15px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.doctor-item {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.doctor-item:last-child {
    border-bottom: none;
}

.doctor-item:hover {
    background-color: #f5f9ff;
}

.doctor-item.highlighted {
    background-color: #e3f2fd;
    border-left: 3px solid #0073aa;
    padding-left: 12px;
}

.doctor-item h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #0073aa;
}

.doctor-item p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

/* Botones de contacto */
.contact-buttons {
    display: flex;
    gap: 8px;
    margin: 0;
    flex-wrap: wrap;
    align-items: center;
}

.contact-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border-radius: 8px;
    background-color: #f5f5f5;
    text-decoration: none;
    border: 1px solid #e0e0e0;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    transition: background-color 0.2s, border-color 0.2s;
}

.contact-btn:hover {
    background-color: #001d57;
    border-color: #001d57;
}

.email-btn, .whatsapp-btn {
    width: 38px;
    padding: 0 !important;
    flex-shrink: 0;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.whatsapp-btn svg {
    width: 20px;
    height: 20px;
}

.feature-btn {
    display: none !important;
}

.feature-badge {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 8px;
    background-color: #f5f5f5;
    border: 1px solid #e0e0e0;
    flex-shrink: 0;
}

/* Badge de categoría clickeable con efecto hover */
.category-badge-clickable {
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}

.category-badge-clickable:hover {
    background-color: #001d57;
    border-color: #001d57;
    transform: scale(1.05);
}

.category-image {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

/* Paginación */
.pagination {
    padding: 15px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: center;
    gap: 10px;
    background: #f9f9f9;
    flex-shrink: 0;
}

#pagination .pagination-btn,
.pagination .pagination-btn,
button.pagination-btn {
    padding: 10px 24px !important;
    border: none !important;
    background-color: #0073aa !important;
    color: white !important;
    cursor: pointer;
    border-radius: 4px !important;
    font-size: 14px !important;
    font-weight: 500;
}

#pagination .pagination-btn:hover:not(:disabled),
.pagination .pagination-btn:hover:not(:disabled),
button.pagination-btn:hover:not(:disabled) {
    background-color: #005a87 !important;
    border-radius: 4px !important;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #ccc;
}

/* Wrapper del mapa */
.map-wrapper {
    flex: 1;
    position: relative;
    min-width: 0;
    height: 100%;
}

/* Estilos del loader */
#map-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    font-weight: 500;
}

/* Contenedor del mapa */
#mapid {
    height: 100%;
    width: 100%;
    border-radius: 4px;
}

/* Estilos personalizados para InfoWindow de Google Maps */
.gm-style .gm-style-iw-c {
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
    background-color: #001d57;
}

.gm-style .gm-style-iw-d {
    overflow: hidden !important;
    padding: 0 !important; /* Eliminar padding superior excesivo de Google Maps */
}

.gm-style .gm-style-iw-t::after {
    background: #001d57;
}

/* Botón de cerrar del InfoWindow - OCULTAR completamente */
.gm-style .gm-style-iw-tc,
button.gm-ui-hover-effect {
    display: none !important; /* Ocultar el botón de Google Maps */
}

/* Botón de cerrar personalizado */
.custom-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    line-height: 1;
    font-weight: 300;
}

.custom-close-btn:hover {
    opacity: 0.7;
}

.custom-popup {
    padding: 16px 20px;
    background-color: #001d57;
}

.custom-popup h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.custom-popup .popup-address {
    margin: 0;
    font-size: 14px;
    font-weight: 400;
    color: #ffffff;
    line-height: 1.4;
}

/* Popup de ubicación del usuario */
.user-location-popup {
    position: relative;
    padding: 16px 40px 16px 24px; /* Más padding a la derecha para el botón */
    text-align: center;
    background-color: #001d57;
}

.user-location-popup b {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
}

.user-location-popup .custom-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white; /* Blanco porque el fondo del popup es azul */
    font-size: 24px;
    line-height: 1;
    font-weight: 300;
}

.user-location-popup .custom-close-btn:hover {
    opacity: 0.7;
}

/* ============================================
   ESTILOS PARA CONTROLES DE GOOGLE MAPS
   ============================================ */

/* Contenedor de controles de Google Maps */
#mapid .gm-bundled-control {
    margin: 10px !important;
}

/* Botones de Zoom y Fullscreen */
#mapid .gm-control-active,
#mapid button.gm-control-active {
    background-color: #ffffff !important;
    border: none !important;
    border-radius: 2px !important;
    box-shadow: rgba(0, 0, 0, 0.3) 0px 1px 4px -1px !important;
}

#mapid .gm-control-active:hover,
#mapid button.gm-control-active:hover {
    background-color: #f8f8f8 !important;
}

/* Iconos en AZUL #001d57 */
#mapid .gm-control-active img,
#mapid button.gm-control-active img,
#mapid .gm-control-active svg,
#mapid button.gm-control-active svg,
#mapid .gm-control-active > span,
#mapid button.gm-control-active > span {
    filter: invert(8%) sepia(96%) saturate(4592%) hue-rotate(222deg) brightness(95%) contrast(107%) !important;
}

/* Botón Fullscreen específico */
#mapid button[title*="pantalla completa"],
#mapid button[title*="Pantalla completa"],
#mapid button[title*="fullscreen"],
#mapid button[title*="Fullscreen"] {
    background-color: #ffffff !important;
    border: none !important;
}

/* Botones de Zoom específicos */
#mapid button[title*="Ampliar"],
#mapid button[title*="Reducir"],
#mapid button[title*="Zoom in"],
#mapid button[title*="Zoom out"] {
    background-color: #ffffff !important;
    border: none !important;
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */

/* Padding lateral en mobile y reorganización del formulario */
@media (max-width: 992px) {
    .mapa-container {
        padding: 0 20px;
    }
    
    /* Reorganizar el formulario de búsqueda en mobile */
    .address-search-form {
        flex-direction: column;
        gap: 12px;
    }
    
    /* Input de búsqueda ocupa todo el ancho */
    .search-input-wrapper {
        width: 100%;
        flex: 1 1 100%;
    }
    
    .address-search-form input[type="text"] {
        width: 100%;
        height: 48px;
        font-size: 16px; /* Evita zoom en iOS */
    }
    
    /* Contenedor para selector de distancia y botón */
    .address-search-form .distance-select {
        flex: 1 1 auto;
        width: 100%;
        height: 48px;
        font-size: 16px;
        appearance: none;
        -webkit-appearance: none;
        -moz-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='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 12px;
        padding-right: 36px;
    }
    
    /* Ajustar el dropdown del select para que tenga el mismo ancho */
    .address-search-form .distance-select option {
        font-size: 16px;
    }
    
    /* Botón de búsqueda */
    #address-search-form button,
    form#address-search-form button[type="submit"],
    .address-search-form > button,
    .address-search-form button[type="submit"] {
        width: 100%;
        flex: 1 1 auto;
        height: 48px;
    }
    
    /* Ajustar altura del contenedor principal */
    .mapa-content-wrapper {
        flex-direction: column;
        height: auto;
        min-height: auto;
    }
    
    /* Lista de doctores más compacta */
    .doctors-list-container {
        flex: 0 0 auto;
    }
    
    .doctors-list {
        max-height: 400px;
        min-height: 300px;
        height: 300px;
    }
    
    /* Mapa con altura fija en mobile */
    .map-wrapper {
        height: 450px;
        min-height: 450px;
        flex: 0 0 450px;
    }
    
    #mapid {
        height: 450px !important;
        min-height: 450px !important;
    }
    
    /* Botones de ordenamiento más pequeños */
    .sort-buttons {
        flex-wrap: wrap;
    }
    
    .sort-btn {
        font-size: 11px;
        padding: 6px 12px;
    }
    
    /* Header más compacto */
    .doctors-list-header {
        padding: 12px;
    }
    
    .doctors-list-header h3 {
        font-size: 16px;
    }
    
    /* Items de doctores más compactos */
    .doctor-item {
        padding: 12px;
    }
    
    .doctor-item h4 {
        font-size: 15px;
    }
    
    .doctor-item p {
        font-size: 12px;
    }
    
    /* Botones de contacto más pequeños */
    .contact-buttons {
        gap: 6px;
    }
    
    .contact-btn,
    .feature-badge {
        width: 34px;
        height: 34px;
        min-width: 34px;
    }
    
    .category-image {
        width: 24px;
        height: 24px;
    }
    
    /* Ocultar controles de zoom en mobile (se usa pinch-to-zoom) */
    #mapid .gm-bundled-control {
        display: none !important;
    }
    
    /* Mantener solo el botón de fullscreen visible */
    #mapid button[title*="pantalla completa"],
    #mapid button[title*="Pantalla completa"],
    #mapid button[title*="fullscreen"],
    #mapid button[title*="Fullscreen"] {
        display: block !important;
        visibility: visible !important;
    }
}

/* Para pantallas MUY pequeñas (menos de 400px) */
@media (max-width: 400px) {
    .mapa-container {
        padding: 0 15px;
    }
    
    .sort-btn {
        font-size: 10px;
        padding: 5px 10px;
    }
    
    .contact-btn,
    .feature-badge {
        width: 30px;
        height: 30px;
        min-width: 30px;
    }
    
    .category-image {
        width: 20px;
        height: 20px;
    }
}

/* Estilos para nombre y dirección en autocomplete de doctores */
.autocomplete-doctor .doctor-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.autocomplete-doctor .doctor-address-autocomplete {
    font-size: 12px;
    color: #666;
    line-height: 1.3;
}

/* Estilos para el historial de búsquedas */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clear-history-btn {
    background: none;
    border: none;
    color: #0073aa;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    transition: background-color 0.2s;
    font-weight: 500;
}

.clear-history-btn:hover {
    background-color: rgba(0, 115, 170, 0.1);
}

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #555;
}

.history-icon {
    font-size: 14px;
    opacity: 0.7;
}