/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
    --popup-primary: #3498db;
    --popup-primary-hover: #2980b9;
    --popup-text: #2c3e50;
    --popup-text-secondary: #7f8c8d;
    --popup-bg: #ffffff;
    --popup-shadow: rgba(0, 0, 0, 0.15);
    --popup-radius: 12px;
    --popup-transition: 0.3s ease;
}

/* ============================================
   MAPA - ESTILOS BASE
   ============================================ */
.custom-map-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
}

/* Loader mientras carga el mapa */
.custom-map-container.loading {
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-map-container.loading::after {
    content: '🔄 Cargando mapa...';
    font-size: 14px;
    color: #666;
    background: white;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

#custom-map,
#custom-map-category,
#custom-map-attractions {
    width: 100% !important;
    height: 100% !important;
    min-height: 400px;
}

/* ============================================
   FILTROS DEL MAPA
   ============================================ */
.map-filters {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 250px;
    max-height: 80%;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.map-filters:hover {
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.2);
}

.map-filters h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-filters h4 .filter-icon {
    font-size: 16px;
}

.map-filters label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    cursor: pointer;
    color: #444;
    transition: color 0.2s;
    padding: 4px 8px;
    border-radius: 6px;
}

.map-filters label:hover {
    background: #f0f4f8;
    color: #2c3e50;
}

.map-filters label input[type="checkbox"] {
    margin-right: 8px;
    accent-color: #3498db;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.map-filters .filter-count {
    margin-top: 12px;
    font-size: 12px;
    color: #7f8c8d;
    border-top: 1px solid #e0e0e0;
    padding-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-filters .filter-count .count-number {
    font-weight: 700;
    color: #3498db;
    font-size: 14px;
}

/* Scrollbar del panel de filtros */
.map-filters::-webkit-scrollbar {
    width: 4px;
}

.map-filters::-webkit-scrollbar-track {
    background: transparent;
}

.map-filters::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.map-filters::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ============================================
   POPUPS - ESTILOS PARA LEAFLET
   ============================================ */

/* Contenedor del popup */
.leaflet-popup {
    animation: popupFadeIn 0.25s ease-out;
}

.leaflet-popup-content-wrapper {
    border-radius: var(--popup-radius) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18) !important;
    padding: 0 !important;
    overflow: hidden;
    min-width: 280px;
    max-width: 350px;
    background: var(--popup-bg) !important;
    background-color:white;
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    min-width: 280px !important;
}

/* Flecha del popup */
.leaflet-popup-tip {
    background: var(--popup-bg) !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
}

/* Botón de cerrar */
.leaflet-popup-close-button {
    color: #666 !important;
    font-size: 20px !important;
    padding: 8px 12px !important;
    line-height: 1 !important;
    background: rgba(255, 255, 255, 0.95) !important;
    border-radius: 50% !important;
    margin: 8px !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    z-index: 10 !important;
    font-weight: 300 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.leaflet-popup-close-button:hover {
    background: #ffffff !important;
    color: #2c3e50 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    transform: rotate(90deg);
}

/* ============================================
   TARJETA DEL MARCADOR
   ============================================ */
.marker-popup-card {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    padding: 0;
    background: var(--popup-bg);
    border-radius: var(--popup-radius);
    overflow: hidden;
}

/* === IMAGEN === */
.marker-popup-image {
    width: 100%;
    height: 160px;
    overflow: hidden;
    background: #e8ecf0;
    position: relative;
}

.marker-popup-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.marker-popup-image img:hover {
    transform: scale(1.05);
}

/* Badge de categoría sobre la imagen */
.marker-popup-image .image-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Cabecera del popup */
.marker-popup-header {
    padding: 14px 18px 10px 18px;
    border-bottom: 3px solid var(--category-color, #3498db);
    background: #fafafa;
}

.marker-popup-header .marker-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--popup-text);
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.marker-popup-header .marker-title a {
    color: var(--popup-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.marker-popup-header .marker-title a:hover {
    color: var(--popup-primary);
}

.marker-popup-header .marker-category-badge {
    display: inline-block;
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    color: white;
    margin-top: 6px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    background: var(--category-color, #3498db);
}

/* ============================================
   CUERPO DEL POPUP
   ============================================ */
.marker-popup-body {
    padding: 12px 18px 14px 18px;
}

.marker-popup-body .marker-address {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: var(--popup-text-secondary);
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.marker-popup-body .marker-address .icon {
    flex-shrink: 0;
    margin-top: 1px;
    font-size: 13px;
}

.marker-popup-body .marker-description {
    font-size: 13px;
    color: #555;
    line-height: 1.5;
    margin: 0 0 10px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Precio (para rentals) */
.marker-popup-body .marker-price {
    display: inline-block;
    font-size: 17px;
    font-weight: 700;
    color: #e74c3c;
    margin: 0 0 6px 0;
}

.marker-popup-body .marker-price .per-night {
    font-size: 12px;
    font-weight: 400;
    color: #95a5a6;
}

/* ============================================
   FOOTER DEL POPUP
   ============================================ */
.marker-popup-footer {
    padding: 10px 18px 14px 18px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    background: #fafafa;
}

.marker-popup-footer .marker-source {
    font-size: 11px;
    color: #95a5a6;
    display: flex;
    align-items: center;
    gap: 5px;
}

.marker-popup-footer .marker-source .source-icon {
    font-size: 13px;
}

.marker-popup-footer .btn-ver-mas {
    display: inline-block;
    padding: 6px 18px;
    background: var(--popup-primary);
    color: white !important;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.marker-popup-footer .btn-ver-mas:hover {
    background: var(--popup-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(52, 152, 219, 0.35);
    color: white !important;
}

.marker-popup-footer .btn-ver-mas:active {
    transform: translateY(0);
    box-shadow: none;
}

/* ============================================
   CATEGORÍAS DE WORDPRESS EN EL POPUP
   ============================================ */
.marker-popup-wp-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 6px 0 4px 0;
}

.marker-popup-wp-categories .wp-cat-tag {
    display: inline-block;
    padding: 1px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 500;
    color: #555;
    background: #f0f0f0;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.marker-popup-wp-categories .wp-cat-tag:hover {
    background: #e8e8e8;
    border-color: #ccc;
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: translateY(-15px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* ============================================
   SCROLLBAR PARA POPUPS
   ============================================ */
.marker-popup-scroll {
    max-height: 400px;
    overflow-y: auto;
}

.marker-popup-scroll::-webkit-scrollbar {
    width: 4px;
}

.marker-popup-scroll::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 4px;
}

.marker-popup-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.marker-popup-scroll::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Firefox scrollbar */
.marker-popup-scroll {
    scrollbar-width: thin;
    scrollbar-color: #ccc #f5f5f5;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .custom-map-container,
    #custom-map,
    #custom-map-category,
    #custom-map-attractions {
        min-height: 300px !important;
    }
    
    .map-filters {
        max-width: 180px !important;
        font-size: 12px !important;
        padding: 12px !important;
        top: 8px;
        left: 8px;
    }
    
    .map-filters h4 {
        font-size: 12px !important;
        margin-bottom: 8px !important;
    }
    
    .map-filters label {
        font-size: 11px !important;
        margin-bottom: 4px !important;
        padding: 3px 6px !important;
    }
    
    .leaflet-popup-content-wrapper {
        min-width: 240px;
        max-width: 280px;
    }
    
    .leaflet-popup-content {
        min-width: 240px !important;
    }
}

@media (max-width: 480px) {
    .leaflet-popup-content-wrapper {
        min-width: 200px;
        max-width: 240px;
    }
    
    .leaflet-popup-content {
        min-width: 200px !important;
    }
    
    .marker-popup-image {
        height: 120px;
    }
    
    .marker-popup-header .marker-title {
        font-size: 14px;
    }
    
    .marker-popup-body .marker-price {
        font-size: 15px;
    }
    
    .marker-popup-body .marker-description {
        font-size: 12px;
    }
    
    .marker-popup-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 14px 12px 14px;
    }
    
    .marker-popup-footer .btn-ver-mas {
        text-align: center;
        padding: 8px 16px;
        width: 100%;
    }
    
    .map-filters {
        max-width: 150px !important;
        padding: 10px !important;
        top: 5px;
        left: 5px;
        font-size: 11px !important;
        max-height: 60% !important;
    }
}

/* ============================================
   DARK MODE (opcional)
   ============================================ */
@media (prefers-color-scheme: dark) {
    .map-filters {
        background: rgba(30, 30, 40, 0.95);
        backdrop-filter: blur(8px);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .map-filters h4 {
        color: #e8e8e8;
    }
    
    .map-filters label {
        color: #c0c0c0;
    }
    
    .map-filters label:hover {
        background: rgba(255, 255, 255, 0.05);
        color: #e8e8e8;
    }
    
    .map-filters .filter-count {
        border-top-color: #333;
        color: #888;
    }
    
    .leaflet-popup-content-wrapper {
        background: #2a2a3a !important;
    }
    
    .leaflet-popup-tip {
        background: #2a2a3a !important;
    }
    
    .marker-popup-card {
        background: #2a2a3a;
    }
    
    .marker-popup-header {
        background: #323246;
        border-bottom-color: var(--category-color, #3498db);
    }
    
    .marker-popup-header .marker-title {
        color: #e8e8e8;
    }
    
    .marker-popup-header .marker-title a {
        color: #e8e8e8;
    }
    
    .marker-popup-header .marker-title a:hover {
        color: #3498db;
    }
    
    .marker-popup-body .marker-description {
        color: #aaa;
    }
    
    .marker-popup-footer {
        background: #323246;
        border-top-color: #444;
    }
    
    .marker-popup-footer .marker-source {
        color: #888;
    }
    
    .marker-popup-wp-categories .wp-cat-tag {
        background: #444;
        color: #ccc;
        border-color: #555;
    }
    
    .marker-popup-wp-categories .wp-cat-tag:hover {
        background: #555;
    }
    
    .leaflet-popup-close-button {
        background: rgba(50, 50, 70, 0.95) !important;
        color: #aaa !important;
    }
    
    .leaflet-popup-close-button:hover {
        background: #3a3a5a !important;
        color: #fff !important;
    }
}