/* ============================================================
   SIMA INTERCAMBIOS MAP - FRONTEND STYLES
   Plugin: sima-intercambios-map | v1.1.0
   Nota: Se usan !important en el panel para evitar conflictos
   con el CSS del tema WordPress (Bootstrap incluido).
   ============================================================ */

.sima-cyber-map-wrapper {
    --cyan: #00f0ff;
    --magenta: #ff00aa;
    position: relative !important;
    width: 100% !important;
    background-color: #0a0e17 !important;
    color: #fff !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    overflow: hidden !important;
    padding-bottom: 20px !important;
    font-family: inherit !important;
    box-sizing: border-box !important;
}

.sima-cyber-map-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, transparent 30%, #05070a 100%);
    pointer-events: none;
    z-index: 5;
}

/* Header */
.cyber-header {
    width: 100%;
    text-align: center;
    padding: 40px 0 20px;
    position: relative;
    z-index: 10;
}

.cyber-header h2 {
    font-size: 2rem !important;
    margin: 0 !important;
    color: #fff !important;
    letter-spacing: 3px !important;
    text-shadow: 0 0 20px rgba(0, 240, 255, 0.5) !important;
    line-height: 1.2 !important;
}

.cyber-counter-box {
    display: inline-block;
    margin-top: 12px;
    font-size: 1.3rem;
    color: var(--cyan);
    border: 1px solid var(--cyan);
    padding: 4px 18px;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.3) inset, 0 0 15px rgba(0, 240, 255, 0.3);
    background: rgba(0, 240, 255, 0.05);
    backdrop-filter: blur(5px);
}

/* Container Root */
.sima-map-root {
    width: 95%;
    max-width: 1300px;
    margin: 20px auto 30px;
    position: relative;
    height: 65vh;
    min-height: 480px;
    border: 1px solid rgba(0, 240, 255, 0.25);
    border-radius: 8px;
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.15);
    z-index: 20;
    overflow: hidden;
}

#sima-leaflet-map {
    width: 100%;
    height: 100%;
    background: #0a0e17;
}

.leaflet-container {
    background: #0a0e17 !important;
}

.leaflet-attribution-flag {
    display: none !important;
}

.leaflet-control-attribution {
    font-size: 0.65rem;
    opacity: 0.6;
    background: rgba(0, 0, 0, 0.6) !important;
    color: #aaa !important;
}

.leaflet-control-attribution a {
    color: #aaa !important;
}

.leaflet-control-zoom {
    border: 1px solid rgba(0, 240, 255, 0.4) !important;
    background: rgba(10, 14, 23, 0.9) !important;
}

.leaflet-control-zoom a {
    color: #00f0ff !important;
    background: transparent !important;
    border-bottom: 1px solid rgba(0, 240, 255, 0.3) !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(0, 240, 255, 0.15) !important;
}

/* Legend */
.sima-legend {
    position: absolute;
    bottom: 24px;
    left: 16px;
    background: rgba(10, 14, 23, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 12px 16px;
    border-radius: 6px;
    z-index: 800;
    pointer-events: none;
    backdrop-filter: blur(6px);
}

.sima-legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.82rem;
    color: #fff;
}

.sima-legend-row:last-child {
    margin-bottom: 0;
}

.sima-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sl-mix {
    background: linear-gradient(135deg, #00f0ff, #ff00aa);
    box-shadow: 0 0 8px #fff;
}

/* Panel Overlay */
.sima-panel {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    width: 330px !important;
    height: 100% !important;
    background: rgba(8, 12, 20, 0.97) !important;
    border-left: 1px solid rgba(0, 240, 255, 0.3) !important;
    z-index: 900 !important;
    display: flex !important;
    flex-direction: column !important;
    opacity: 0;
    pointer-events: none;
    transform: translateX(30px);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(12px);
    box-sizing: border-box !important;
}

.sima-panel.open {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateX(0) !important;
}

.sp-header {
    padding: 16px 14px 12px;
    border-bottom: 1px solid rgba(0, 240, 255, 0.2);
    flex-shrink: 0;
    position: relative;
}

.sp-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    background: none;
    border: 1px solid rgba(0, 240, 255, 0.35);
    color: #00f0ff;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    border-radius: 3px;
}

.sp-close:hover {
    background: rgba(0, 240, 255, 0.15);
}

.sp-country {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 0 30px 4px 0;
    line-height: 1.2;
}

.sp-total {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Tabs */
.sp-tabs {
    display: flex !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    flex-shrink: 0 !important;
    overflow-x: auto !important;
    min-height: 40px !important;
    background: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    /* Hide scrollbar */
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.sp-tabs::-webkit-scrollbar { 
    display: none; 
}

.sp-tab {
    flex: 1 !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    padding: 10px 4px !important;
    font-size: 0.65rem !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    cursor: pointer !important;
    color: rgba(255, 255, 255, 0.45) !important;
    transition: color 0.2s, border-color 0.2s !important;
    white-space: normal !important;
    line-height: 1.1 !important;
    box-shadow: none !important;
    outline: none !important;
    display: inline-block !important;
    text-align: center !important;
}

.sp-tab:hover {
    color: rgba(255, 255, 255, 0.85) !important;
    background-color: rgba(255,255,255,0.04) !important;
}

.sp-tab.active {
    color: #00f0ff !important;
    border-bottom-color: #00f0ff !important;
    background-color: transparent !important;
}

/* Tab Panels & List */
.sp-body {
    /* La altura la asigna JS dinámicamente al abrir el panel */
    display: block !important;
    overflow: hidden !important;
    position: relative !important;
    /* fallback por si JS tarda */
    min-height: 200px;
}

.sp-list-wrap {
    /* Mostrado / ocultado con display:block|none via JS */
    display: none !important;
    overflow-y: auto !important;
    height: 100% !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(0, 240, 255, 0.3) transparent !important;
    background: transparent !important;
    -webkit-overflow-scrolling: touch !important;
}

.sp-list-wrap.active {
    /* El JS también lo fuerza, pero mantenemos la clase como respaldo */
    display: block !important;
}

.sp-list-wrap::-webkit-scrollbar {
    width: 4px;
}

.sp-list-wrap::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.3);
    border-radius: 2px;
}

.sp-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.sp-item {
    padding: 12px 14px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    transition: background 0.15s !important;
    background: transparent !important;
}

.sp-item:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

.sp-city {
    font-size: 0.68rem !important;
    color: rgba(255, 255, 255, 0.45) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 4px !important;
    display: block !important;
    /* Pequeño badge de ciudad */
    background: rgba(0, 240, 255, 0.08) !important;
    border-left: 2px solid rgba(0, 240, 255, 0.4) !important;
    padding: 2px 6px !important;
    border-radius: 0 3px 3px 0 !important;
    width: fit-content !important;
}

.sp-uni {
    font-size: 0.85rem !important;
    color: #e0e0e0 !important;
    line-height: 1.4 !important;
    text-decoration: none !important;
    display: block !important;
    margin-top: 4px !important;
}

.sp-uni:hover {
    text-decoration: underline !important;
    color: #00f0ff !important;
}

.sp-empty {
    padding: 30px 14px !important;
    color: rgba(255, 255, 255, 0.4) !important;
    font-size: 0.82rem !important;
    text-align: center !important;
    font-style: italic !important;
}

/* Country Labels */
.sima-country-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    text-shadow: 0 2px 4px rgba(0,0,0,0.95), 0 0 4px rgba(0,0,0,0.95);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 2px 4px;
    border-radius: 4px;
}

.sima-country-label:hover {
    color: #fff;
    text-shadow: 0 0 8px #00f0ff, 0 0 12px #00f0ff;
    transform: scale(1.1);
    z-index: 1000 !important;
}

/* Hover Tooltip Global */
.sima-htip {
    position: fixed;
    background: rgba(8, 12, 20, 0.95) !important;
    border: 1px solid #00f0ff !important;
    padding: 10px 14px !important;
    border-radius: 5px !important;
    color: #fff !important;
    font-size: 0.85rem !important;
    pointer-events: none !important;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 999999 !important;
    white-space: nowrap;
    font-family: inherit;
    box-shadow: 0 0 18px rgba(0, 240, 255, 0.35);
    backdrop-filter: blur(6px);
}

/* Responsive */
@media (max-width: 768px) {
    .sima-map-root {
        height: 70vh;
        min-height: 450px;
    }

    .sima-panel {
        width: 100%;
        height: 75%;
        top: auto;
        bottom: 0;
        opacity: 0;
        pointer-events: none;
        transform: translateY(40px);
        transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
        border-left: none;
        border-top: 2px solid rgba(0, 240, 255, 0.4);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -10px 30px rgba(0,0,0,0.7);
    }

    .sima-panel.open {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

    .sp-close {
        width: 32px;
        height: 32px;
        font-size: 16px;
        top: 12px;
        right: 12px;
    }

    .sima-htip {
        display: none !important;
    }
}

/* ============================================================
   LIGHT THEME OVERRIDES (.sima-theme-light)
   ============================================================ */
.sima-theme-light {
    background-color: #f8f9fa !important;
    color: #333 !important;
}
.sima-theme-light::after {
    background: radial-gradient(circle at center, transparent 30%, #e9ecef 100%);
}
.sima-theme-light .cyber-header h2 {
    color: #111 !important;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.1) !important;
}
.sima-theme-light .cyber-counter-box {
    color: #004b87;
    border: 1px solid #004b87;
    box-shadow: none;
    background: rgba(0, 75, 135, 0.05);
}
.sima-theme-light .sima-map-root {
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.05);
}
.sima-theme-light #sima-leaflet-map,
.sima-theme-light .leaflet-container {
    background: #f8f9fa !important;
}
.sima-theme-light .leaflet-control-zoom {
    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    background: rgba(255, 255, 255, 0.9) !important;
}
.sima-theme-light .leaflet-control-zoom a {
    color: #333 !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
}
.sima-theme-light .leaflet-control-zoom a:hover {
    background: rgba(0, 0, 0, 0.05) !important;
}
.sima-theme-light .sima-legend {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.sima-theme-light .sima-legend-row {
    color: #333;
}
.sima-theme-light .sima-panel {
    background: rgba(255, 255, 255, 0.97) !important;
    border-left: 1px solid rgba(0, 0, 0, 0.15) !important;
}
.sima-theme-light .sp-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
.sima-theme-light .sp-close {
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: #333;
}
.sima-theme-light .sp-close:hover {
    background: rgba(0, 0, 0, 0.05);
}
.sima-theme-light .sp-country {
    color: #111;
}
.sima-theme-light .sp-total {
    color: rgba(0, 0, 0, 0.6);
}
.sima-theme-light .sp-tabs {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
}
.sima-theme-light .sp-tab {
    color: rgba(0, 0, 0, 0.55) !important;
}
.sima-theme-light .sp-tab:hover {
    color: rgba(0, 0, 0, 0.95) !important;
    background-color: rgba(0,0,0,0.04) !important;
}
.sima-theme-light .sp-tab.active {
    color: #004b87 !important;
    border-bottom-color: #004b87 !important;
}
.sima-theme-light .sp-city {
    color: #555 !important;
}
.sima-theme-light .sp-uni {
    color: #222 !important;
}
.sima-theme-light .sp-uni:hover {
    color: #004b87 !important;
}
.sima-theme-light .sp-empty {
    color: rgba(0, 0, 0, 0.45) !important;
}
.sima-theme-light .sima-country-label {
    color: #222 !important;
    text-shadow: none !important;
    background: rgba(255, 255, 255, 0.85) !important;
    border: 1px solid rgba(0,0,0,0.1);
}
.sima-theme-light .sima-country-label:hover {
    background: #fff !important;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.sima-theme-light .sima-htip {
    background: rgba(255, 255, 255, 0.98) !important;
    color: #111 !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}
@media (max-width: 768px) {
    .sima-theme-light .sima-panel {
        border-top: 2px solid rgba(0, 0, 0, 0.1);
        box-shadow: 0 -5px 25px rgba(0,0,0,0.15);
    }
}

/* ============================================================
   CLUSTERS & SEARCH BOX
   ============================================================ */

/* Clusters */
.sima-cluster-icon {
    background: transparent !important;
    border: none !important;
}
.sima-cluster {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(0, 240, 255, 0.15);
    border: 2px solid #00f0ff;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 0 4px #000;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}
.sima-cluster:hover {
    background: rgba(0, 240, 255, 0.35);
    transform: scale(1.1);
}
.sima-theme-light .sima-cluster {
    background: rgba(0, 75, 135, 0.85);
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    color: #fff;
    text-shadow: none;
}
.sima-theme-light .sima-cluster:hover {
    background: rgba(0, 75, 135, 1);
}

/* Buscador Flotante */
.sima-search-container {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 800;
    display: flex;
    align-items: center;
    width: 280px;
    font-family: inherit;
}
.sima-search-container input {
    width: 100%;
    padding: 10px 35px 10px 15px;
    border-radius: 20px;
    border: 1px solid rgba(0, 240, 255, 0.5);
    background: rgba(8, 12, 20, 0.85);
    color: #fff;
    outline: none;
    backdrop-filter: blur(5px);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
    font-size: 0.85rem;
    transition: all 0.3s ease;
}
.sima-search-container input:focus {
    border-color: #00f0ff;
    box-shadow: 0 0 18px rgba(0, 240, 255, 0.4);
}
.sima-search-container input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}
.sima-search-container button {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: #00f0ff;
    cursor: pointer;
    padding: 0;
    width: 18px;
    height: 18px;
    pointer-events: none; /* Let clicks pass through if we want, or just visual */
}
.sima-search-results {
    position: absolute;
    top: 45px;
    left: 0;
    width: 100%;
    background: rgba(8, 12, 20, 0.95);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 220px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}
.sima-search-results li {
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    font-size: 0.8rem;
    color: #ccc;
    line-height: 1.3;
}
.sima-search-results li:last-child {
    border-bottom: none;
}
.sima-search-results li:hover {
    background: rgba(0, 240, 255, 0.15);
    color: #fff;
}
.sima-theme-light .sima-search-container input {
    border: 1px solid rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}
.sima-theme-light .sima-search-container input:focus {
    border-color: #004b87;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.sima-theme-light .sima-search-container input::placeholder {
    color: rgba(0, 0, 0, 0.4);
}
.sima-theme-light .sima-search-container button {
    color: #004b87;
}
.sima-theme-light .sima-search-results {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}
.sima-theme-light .sima-search-results li {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    color: #555;
}
.sima-theme-light .sima-search-results li:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #004b87;
}

@media (max-width: 768px) {
    .sima-search-container {
        width: 80%;
        left: 10%;
        top: 10px;
        right: auto;
    }
}
