/**
 * Estilos para el Mapa Interactivo de Granada
 * Versión: 2.1.0 (30/05/2025)
 */

/* Contenedor principal del mapa */
.mapa-interactivo-tc-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    /* QUITADO: overflow: hidden para que el autocompletado no se corte */
}

/* Mapa principal */
.mapitc-mapa-wrap {
    width: 100%;
    min-height: 400px;
    position: relative;
    order: 2;
}

.mapitc-mapa {
    width: 100%;
    height: 100%;
    min-height: 400px;
    border-radius: 8px;
    position: relative;
    background-color: #f5f5f5;
}

#mapitc-loading-overlay {
    position: absolute;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.45), transparent);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 5;
    border-radius: 0 0 8px 8px;
    pointer-events: none;
    padding: 12px;
}

#mapitc-loading-overlay .mapitc-loading-card {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    text-align: center;
    width: 100%;
    max-width: 420px;
    margin-bottom: 8px;
}

#mapitc-loading-overlay .mapitc-loading-text {
    margin: 0 0 8px 0;
    color: #495057;
    font-size: 14px;
}

#mapitc-loading-overlay .mapitc-loading-text::after {
    content: '';
    display: inline-block;
    width: 1.2em;
    text-align: left;
    animation: mapitc-dots 1.2s steps(4, end) infinite;
}

#mapitc-loading-overlay .mapitc-progress {
    margin-top: 4px;
}

#mapitc-loading-overlay .mapitc-progress-track {
    width: 100%;
    height: 10px;
    background: #e9ecef;
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

#mapitc-loading-overlay .mapitc-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #005a87, #007cba, #4db2e6, #007cba, #005a87);
    background-size: 200% 100%;
    border-radius: 999px;
    transition: width 0.45s ease;
    position: relative;
    overflow: hidden;
    animation: mapitc-progress-flow 1.4s linear infinite;
}

#mapitc-loading-overlay .mapitc-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    animation: mapitc-progress-shine 1.1s ease-in-out infinite;
}

#mapitc-loading-overlay .mapitc-progress-track::after {
    content: '';
    position: absolute;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    animation: mapitc-progress-track-shine 1.6s ease-in-out infinite;
    pointer-events: none;
}

#mapitc-loading-overlay .mapitc-progress-label {
    margin-top: 6px;
    font-size: 12px;
    color: #6c757d;
    font-weight: 600;
}

@keyframes mapitc-progress-flow {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes mapitc-progress-shine {
    0% { left: -40%; }
    100% { left: 120%; }
}

@keyframes mapitc-progress-track-shine {
    0% { left: -50%; }
    100% { left: 120%; }
}

@keyframes mapitc-dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

.mapitc-admin-geo-notice {
    margin: 10px 0 0;
    padding: 10px 14px;
    background: #fff8e5;
    border: 1px solid #dba617;
    border-radius: 6px;
    color: #3c434a;
    font-size: 13px;
    line-height: 1.45;
}

.mapitc-admin-geo-notice a {
    color: #007cba;
    font-weight: 600;
}

.mapitc-adv-marker {
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
    transform: translateY(-2px);
}

/* Buscador después del mapa */
.mapitc-buscador {
    padding: 15px;
    background-color: #ffffff;
    border-top: 1px solid #e9ecef;
    order: 3; /* Forzar que el buscador esté al final */
}

/* Estados de carga y error del mapa */
.mapitc-map-loading,
.mapitc-map-error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    text-align: center;
}

.mapitc-map-error {
    background-color: #fee;
    border-color: #fcc;
}

.mapitc-no-markers {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    text-align: center;
    max-width: 300px;
}

/* Leyenda de zonas */
.mapitc-leyenda-zonas {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.mapitc-leyenda-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #495057;
}

.mapitc-color-muestra {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.mapitc-leyenda-texto {
    font-weight: 500;
}

/* Leyenda de tipos de post */
.mapitc-leyenda-tipos {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 15px;
    background-color: #ffffff;
    border-bottom: 1px solid #e9ecef;
}

.mapitc-leyenda-tipos .mapitc-leyenda-item {
    font-size: 14px;
}

.mapitc-icono-resource,
.mapitc-icono-visit,
.mapitc-icono-experiencia,
.mapitc-icono-pueblo {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* Buscador */
.mapitc-buscador {
    padding: 15px;
    background-color: #ffffff;
    border-bottom: 1px solid #e9ecef;
}

.mapitc-buscador-container {
    position: relative;
    max-width: 400px;
    margin: 0;/* auto;*/
    z-index: 1000; /* Asegurar contexto de stacking */
}

.mapitc-buscador-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.mapitc-input-busqueda {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    background-color: #fff;
}

.mapitc-input-busqueda:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

/* Resultados de búsqueda */
.mapitc-resultados-busqueda {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e9ecef;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 9999; /* Z-index muy alto para estar encima de todo */
    display: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.mapitc-resultados-busqueda.visible {
    display: block;
}

.mapitc-resultado-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f4;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
}

.mapitc-resultado-item:hover {
    background-color: #f8f9fa;
}

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

.mapitc-resultado-icono {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* Ventana de información */
.mapitc-info-window {
    max-width: 250px;
    padding: 5px;
}

.mapitc-info-title-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.mapitc-info-title-link:hover {
    text-decoration: none;
}

.mapitc-info-title-link:hover .mapitc-info-title {
    color: #007cba;
    cursor: pointer;
}

.mapitc-info-title {
    font-weight: 600;
    font-size: 16px;
    color: #212529;
    margin-bottom: 5px;
    line-height: 1.3;
    transition: color 0.2s ease;
}

.mapitc-info-type {
    color: #6c757d;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.mapitc-info-link {
    display: inline-block;
    color: #007cba;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 8px;
    border: 1px solid #007cba;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin-top: 5px;
}

.mapitc-info-link:hover {
    background-color: #007cba;
    color: white;
    text-decoration: none;
}

/* Sección de Debug */
.mapitc-debug-section {
    margin-top: 20px;
    padding: 20px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.mapitc-debug-section h3 {
    margin: 0 0 20px 0;
    color: #495057;
    font-size: 18px;
    font-weight: 600;
}

.mapitc-debug-tipo {
    margin-bottom: 25px;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mapitc-debug-tipo h4 {
    margin: 0;
    padding: 15px 20px;
    background-color: #007cba;
    color: white;
    font-size: 16px;
    font-weight: 500;
}

.mapitc-debug-table-container {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.mapitc-debug-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: white;
}

.mapitc-debug-table th {
    background-color: #f8f9fa;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 10;
}

.mapitc-debug-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: top;
    word-break: break-word;
    max-width: 200px;
}

.mapitc-debug-table tr:hover {
    background-color: #f8f9fa;
}

.mapitc-debug-id-link {
    color: #007cba;
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.mapitc-debug-id-link:hover {
    text-decoration: underline;
}

.mapitc-debug-coordinates {
    font-family: 'Courier New', monospace;
    background-color: #f8f9fa;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 11px;
    color: #198754;
    font-weight: 500;
}

.mapitc-debug-maps-link {
    color: #dc3545;
    text-decoration: none;
    font-size: 11px;
}

.mapitc-debug-maps-link:hover {
    text-decoration: underline;
}

.mapitc-debug-empty {
    color: #6c757d;
    font-style: italic;
    font-size: 11px;
}

.mapitc-debug-table code {
    background-color: #f8f9fa;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 11px;
    color: #e83e8c;
    display: block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Botones de debug */
.mapitc-debug-toggle-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    margin: 10px;
}

.mapitc-debug-toggle-btn:hover {
    background-color: #545b62;
}

/* Responsive */
@media (max-width: 768px) {
    .mapitc-leyenda-zonas,
    .mapitc-leyenda-tipos {
        padding: 10px;
        gap: 10px;
    }

    .mapitc-leyenda-item {
        font-size: 12px;
    }

    .mapitc-buscador {
        padding: 10px;
    }

    .mapitc-buscador-container {
        max-width: 100%;
    }

    .mapitc-debug-section {
        padding: 15px;
        margin-top: 15px;
    }

    .mapitc-debug-table-container {
        font-size: 11px;
    }

    .mapitc-debug-table th,
    .mapitc-debug-table td {
        padding: 8px 4px;
    }

    .mapitc-debug-table td {
        max-width: 120px;
    }

    /* Hacer la tabla más legible en móvil */
    .mapitc-debug-table {
        font-size: 11px;
    }

    /* Ocultar algunas columnas menos importantes en móvil */
    .mapitc-debug-table th:nth-child(4),
    .mapitc-debug-table td:nth-child(4) {
        display: none;
    }
}

@media (max-width: 480px) {
    .mapa-interactivo-tc-container {
        border-radius: 0;
    }

    .mapitc-mapa {
        border-radius: 0;
        min-height: 350px;
    }

    .mapitc-mapa-wrap {
        border-radius: 0;
        min-height: 350px;
    }

    .mapitc-leyenda-zonas,
    .mapitc-leyenda-tipos {
        flex-direction: column;
        gap: 8px;
    }

    .mapitc-info-window {
        max-width: 200px;
    }

    .mapitc-debug-section {
        padding: 10px;
    }

    .mapitc-debug-tipo h4 {
        padding: 10px 15px;
        font-size: 14px;
    }
}

/* Animaciones y transiciones */
.mapitc-leyenda-item,
.mapitc-resultado-item {
    transition: all 0.2s ease;
}

.mapitc-resultados-busqueda {
    animation: slideDown 0.2s ease;
}

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

/* Mejoras para accesibilidad */
.mapitc-input-busqueda:focus,
.mapitc-debug-id-link:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.mapitc-resultado-item:focus {
    background-color: #e3f2fd;
    outline: 2px solid #007cba;
    outline-offset: -2px;
}

/* Estilos para el estado de carga */
.mapitc-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(248, 249, 250, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.mapitc-loading p {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 0;
    font-weight: 500;
    color: #495057;
}

/* Personalización de Google Maps InfoWindow */
.gm-style .gm-style-iw-c {
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.gm-style .gm-style-iw-t::after {
    background: white !important;
}

/* Ocultar elementos de UI innecesarios de Google Maps en móvil */
@media (max-width: 480px) {
    .gmnoprint [title="Toggle fullscreen view"] {
        display: none !important;
    }
    
    .gmnoprint [title="Show street map"] {
        display: none !important;
    }
}