/* ================================================================
   Mapa Turístico — Santa Rosa de Calamuchita
   Estilos
   ================================================================ */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
        Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    background: rgb(249, 250, 236);
}

/* ================================================================
   MAPA
   ================================================================ */
#map {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background: rgb(249, 250, 236);
}

.leaflet-container {
    background: rgb(249, 250, 236);
}

/* ================================================================
   CLUSTERS DE MARCADORES
   ================================================================ */
.marker-cluster-small {
    background-color: rgba(231, 76, 60, 0.2);
}

.marker-cluster-small div {
    background-color: rgba(231, 76, 60, 0.5);
    color: #fff;
    font-weight: 600;
}

.marker-cluster-medium {
    background-color: rgba(231, 76, 60, 0.25);
}

.marker-cluster-medium div {
    background-color: rgba(231, 76, 60, 0.6);
    color: #fff;
    font-weight: 600;
}

.marker-cluster-large {
    background-color: rgba(231, 76, 60, 0.3);
}

.marker-cluster-large div {
    background-color: rgba(231, 76, 60, 0.7);
    color: #fff;
    font-weight: 600;
}

.mapa-con-sidebar #map {
    right: 320px;
}

/* ================================================================
   LOADING
   ================================================================ */
#loading {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgb(249, 250, 236);
    color: #555;
    font-size: 18px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(0, 0, 0, 0.08);
    border-top-color: #e74c3c;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-error {
    text-align: center;
    padding: 24px;
    max-width: 400px;
}

.loading-error .error-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.loading-error code {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    font-size: 14px;
}

/* ================================================================
   SIDEBAR TOGGLE (flotante)
   ================================================================ */
.sidebar-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1002;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a2e;
    transition: transform 0.2s, opacity 0.3s;
    user-select: none;
}

.sidebar-toggle:hover {
    transform: scale(1.1);
}

.sidebar-toggle:active {
    transform: scale(0.95);
}

.sidebar-toggle--oculto {
    opacity: 0;
    pointer-events: none;
}

/* ================================================================
   SIDEBAR
   ================================================================ */
#sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    z-index: 1000;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.18);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

#sidebar.sidebar--abierta {
    transform: translateX(0);
}

/* Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 12px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
}

.sidebar-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f5f5f5;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666666;
    transition: background 0.2s;
}

.sidebar-close:hover {
    background: #e8e8e8;
}

/* Body */
.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
}

/* Footer */
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.sidebar-ayuda {
    font-size: 12px;
    color: #999;
    font-style: italic;
}

/* Scrollbar */
.sidebar-body::-webkit-scrollbar {
    width: 6px;
}

.sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

/* ================================================================
   LISTA DE PUNTOS DE INTERÉS
   ================================================================ */
.poi-lista {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.poi-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    border: 2px solid transparent;
    user-select: none;
}

.poi-item:hover {
    background: #f8f8f8;
    transform: translateX(-3px);
}

.poi-item--activo {
    background: #fef2f2;
    border-color: #e74c3c;
}

.poi-item-emoji {
    font-size: 22px;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 50%;
}

.poi-item-texto {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.poi-item-nombre {
    font-weight: 600;
    font-size: 14px;
    color: #1a1a2e;
}

.poi-item-categoria {
    font-size: 11px;
    color: #aaa;
    text-transform: capitalize;
}

/* ================================================================
   MARCADORES PERSONALIZADOS
   ================================================================ */
.marcador-icono {
    background: none !important;
    border: none !important;
}

.marcador-pin {
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 3px solid #e74c3c;
    transition: transform 0.2s;
    cursor: pointer;
}

.marcador-pin:hover {
    transform: scale(1.12);
}

/* ================================================================
   POPUPS
   ================================================================ */
.popup-img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
    display: block;
    margin: -12px -16px 8px;
}

.popup-contenido strong {
    display: block;
    font-size: 15px;
    margin-bottom: 6px;
    color: #1a1a2e;
}

.popup-contenido p {
    font-size: 13px;
    color: #555;
    line-height: 1.45;
    margin: 0;
}

.popup-contenido .popup-categoria {
    display: inline-block;
    font-size: 11px;
    color: #e74c3c;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 4px;
}

.leaflet-popup-content {
    margin: 12px 16px;
}

/* ================================================================
   COORDENADAS
   ================================================================ */
.coords-display {
    position: fixed;
    bottom: 8px;
    left: 8px;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    color: #ccc;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    padding: 4px 10px;
    border-radius: 4px;
    pointer-events: none;
    user-select: none;
    backdrop-filter: blur(4px);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 600px) {
    #sidebar {
        width: 280px;
    }

    .mapa-con-sidebar #map {
        right: 280px;
    }

    .sidebar-toggle {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 380px) {
    #sidebar {
        width: 100%;
    }
}