/* PescaWiki — Visor de mapa */

.mapa-wrapper {
    position: relative;
    display: flex;
    height: calc(100vh - 70px);
    width: 100%;
    overflow: hidden;
    background: #0a3d62;
}

.mapa-sidebar {
    width: 340px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfe 100%);
    box-shadow: 4px 0 20px rgba(10, 61, 98, 0.15);
    overflow-y: auto;
    transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    flex-shrink: 0;
}
.mapa-sidebar.collapsed { margin-left: -340px; }

.sidebar-header {
    padding: 20px;
    background: linear-gradient(135deg, #0a3d62, #1e88e5);
    color: white;
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; z-index: 5;
}
.sidebar-header h2 { font-size: 18px; font-weight: 700; }

.sidebar-toggle {
    background: rgba(255, 255, 255, 0.15); border: none;
    color: white; width: 32px; height: 32px;
    border-radius: 8px; cursor: pointer; transition: background 0.2s;
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, 0.3); }

.sidebar-section { padding: 16px 20px; border-bottom: 1px solid rgba(10, 61, 98, 0.08); }

.sidebar-label {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 13px; font-weight: 700; color: #0a3d62;
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.stats-badge {
    background: #1e88e5; color: white;
    padding: 2px 8px; border-radius: 10px;
    font-size: 11px; text-transform: none;
}

.sidebar-select {
    width: 100%; padding: 10px 12px;
    border: 2px solid #e3f2fd; border-radius: 10px;
    font-size: 14px; background: white; cursor: pointer;
    font-family: inherit; transition: border 0.2s;
}
.sidebar-select:focus { outline: none; border-color: #1e88e5; }

.legend-list { max-height: 340px; overflow-y: auto; padding-right: 4px; }
.legend-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: 10px; cursor: pointer;
    transition: all 0.2s; margin-bottom: 4px;
    border: 2px solid transparent;
}
.legend-item:hover { background: #f0f7ff; transform: translateX(3px); }
.legend-item.active { background: #e3f2fd; border-color: #1e88e5; }

.legend-dot {
    width: 14px; height: 14px; border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px white, 0 2px 6px rgba(0, 0, 0, 0.15);
}

.legend-info { flex: 1; min-width: 0; }
.legend-name { font-size: 13px; font-weight: 600; color: #1a1a1a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-sci { font-size: 11px; color: #5a6c7d; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-habitat { font-size: 10px; padding: 3px 8px; border-radius: 6px; font-weight: 600; }
.legend-empty, .legend-loading { text-align: center; padding: 20px; color: #5a6c7d; font-size: 13px; }

.style-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.style-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 10px 6px;
    border: 2px solid #e3f2fd; background: white;
    border-radius: 10px; cursor: pointer;
    font-size: 12px; font-weight: 600; color: #0a3d62;
    transition: all 0.2s; font-family: inherit;
}
.style-btn:hover { border-color: #64b5f6; transform: translateY(-2px); }
.style-btn.active {
    border-color: #1e88e5;
    background: linear-gradient(135deg, #1e88e5, #0a3d62);
    color: white;
    box-shadow: 0 4px 12px rgba(30, 136, 229, 0.3);
}
.style-icon { font-size: 20px; }

.sidebar-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px;
    background: linear-gradient(135deg, #e3f2fd, #f0f7ff);
    border-radius: 10px;
}
.stat-icon { font-size: 20px; }
.stat-value { font-size: 18px; font-weight: 700; color: #0a3d62; line-height: 1; }
.stat-label { font-size: 10px; color: #5a6c7d; text-transform: uppercase; }

.mapa-container { flex: 1; position: relative; overflow: hidden; }
#map { width: 100%; height: 100%; }

.map-controls-overlay {
    position: absolute; top: 15px; left: 15px;
    display: flex; flex-direction: column; gap: 8px; z-index: 5;
}
.map-control-btn {
    width: 40px; height: 40px; border: none;
    border-radius: 10px; background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer; font-size: 18px;
    transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.map-control-btn:hover { background: #1e88e5; color: white; transform: translateY(-2px); }

.map-hover-info {
    position: absolute; bottom: 30px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(10, 61, 98, 0.95); color: white;
    padding: 10px 20px; border-radius: 12px;
    font-size: 13px;
    opacity: 0; transition: all 0.25s;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px); z-index: 5;
}
.map-hover-info.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.hover-title { font-weight: 700; }
.hover-sub { font-size: 11px; opacity: 0.85; margin-top: 2px; }

.custom-popup .mapboxgl-popup-content {
    padding: 0 !important;
    border-radius: 14px !important;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3) !important;
}
.custom-popup .mapboxgl-popup-close-button {
    color: white !important;
    font-size: 22px !important;
    padding: 8px 12px !important;
    z-index: 2;
}

.map-popup { font-family: 'Poppins', sans-serif; }
.popup-header { padding: 18px 20px; color: white; }
.popup-header h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.popup-header small { font-size: 12px; opacity: 0.95; }
.popup-body { padding: 16px 20px; max-height: 300px; overflow-y: auto; }
.popup-body p { font-size: 13px; color: #333; margin-bottom: 8px; line-height: 1.5; }
.popup-img { width: 100%; height: 140px; object-fit: cover; border-radius: 8px; margin-bottom: 10px; }

.popup-section h4 {
    font-size: 12px; text-transform: uppercase;
    color: #0a3d62; margin: 12px 0 8px;
    letter-spacing: 0.5px;
}
.popup-especie {
    background: #f8fbfe; padding: 8px 12px;
    border-left: 3px solid #1e88e5;
    border-radius: 6px; margin-bottom: 6px;
    font-size: 12px;
}
.popup-especie strong { display: block; color: #0a3d62; }
.popup-especie small { color: #5a6c7d; font-style: italic; }
.popup-badge {
    display: inline-block; margin-top: 4px;
    padding: 2px 8px; background: #e3f2fd;
    color: #1e88e5; border-radius: 4px;
    font-size: 10px; font-weight: 600;
}
.popup-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.popup-chip {
    display: inline-block; padding: 4px 10px;
    border-radius: 12px; font-size: 11px;
    font-weight: 600; border: 1px solid;
}
.verified-badge {
    background: #43a047; color: white;
    padding: 2px 8px; border-radius: 10px;
    font-size: 10px; margin-left: 6px;
}
.popup-empty { color: #5a6c7d; font-style: italic; font-size: 12px; }

@media (max-width: 768px) {
    .mapa-wrapper { flex-direction: column; height: calc(100vh - 60px); }
    .mapa-sidebar { width: 100%; max-height: 45vh; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15); }
    .mapa-sidebar.collapsed { margin-left: 0; margin-top: -45vh; }
    .map-controls-overlay { top: 10px; left: 10px; }
}

/* ==================== POPUP ESPECIE DESTACADA RESPONSIVE ==================== */
@media (max-width: 768px) {
    .map-popup .popup-body { padding: 12px 14px; max-height: 50vh; }
    .ped-img { height: 130px; }
    .popup-header { padding: 14px 16px; }
    .popup-header h3 { font-size: 15px; }
}
