/* ============================================================
   DuckSignal — Estilos do Mapa (map.css)
   Layout full-viewport, sidebar de filtros, marcadores animados
   ============================================================ */

/* ---- Container do mapa — ocupa toda a viewport ---- */
.map-wrapper {
    display: flex;
    width: 100%;
    height: calc(100vh - var(--navbar-height));
    position: relative;
    overflow: hidden;
}

.map-container {
    flex: 1;
    height: 100%;
    z-index: 1;
}

#map {
    width: 100%;
    height: 100%;
}

/* ---- Sidebar de filtros ---- */
.map-sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: rgba(15, 21, 37, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 1.25rem;
    z-index: 2;
    transition: transform 0.3s ease, width 0.3s ease;
    flex-shrink: 0;
}

.map-sidebar.collapsed {
    transform: translateX(100%);
    width: 0;
    padding: 0;
    border: none;
    overflow: hidden;
}

/* Botão para togglear sidebar */
.sidebar-toggle {
    position: absolute;
    top: 1rem;
    right: calc(var(--sidebar-width) + 0.75rem);
    z-index: 10;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.sidebar-toggle:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.map-sidebar.collapsed~.sidebar-toggle {
    right: 0.75rem;
}

/* Seções da sidebar */
.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section-title {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color);
}

/* Filtros com checkboxes customizados */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.filter-item:hover {
    background: var(--accent-dim);
}

.filter-item input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.filter-item input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.filter-item input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--bg-primary);
    font-size: 10px;
    font-weight: 700;
}

.filter-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex: 1;
}

.filter-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.1rem 0.4rem;
    border-radius: 50px;
}

/* ---- Marcadores customizados no mapa ---- */
.repeater-marker {
    position: relative;
}

.marker-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

.marker-dot.online {
    background: var(--success);
}

.marker-dot.offline {
    background: var(--danger);
}

.marker-dot.unknown {
    background: var(--warning);
}

.marker-dot.has-traffic {
    background: var(--success);
}

/* Pulso animado para repetidoras com tráfego ativo */
.marker-dot.has-traffic::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--success);
    animation: marker-pulse 2s ease-out infinite;
}

@keyframes marker-pulse {
    0% {
        width: 14px;
        height: 14px;
        opacity: 0.8;
    }

    100% {
        width: 40px;
        height: 40px;
        opacity: 0;
    }
}

/* ---- Popup customizado do Leaflet ---- */
.leaflet-popup-content-wrapper {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0 !important;
}

.leaflet-popup-tip {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    min-width: 260px;
}

.popup-content {
    padding: 1rem;
}

.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.popup-callsign {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
}

.popup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    font-size: 0.83rem;
}

.popup-row-label {
    color: var(--text-muted);
}

.popup-row-value {
    color: var(--text-primary);
    font-weight: 500;
}

.popup-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.popup-actions .btn {
    flex: 1;
    font-size: 0.75rem;
    padding: 0.4rem 0.6rem;
    justify-content: center;
}

/* ---- Círculo de cobertura ---- */
.coverage-circle {
    fill: var(--accent);
    fill-opacity: 0.08;
    stroke: var(--accent);
    stroke-opacity: 0.3;
    stroke-width: 2;
}

/* ---- TraceRoute — Linhas animadas pulsantes ---- */
.traceroute-path {
    stroke: var(--accent);
    stroke-width: 3;
    fill: none;
    stroke-dasharray: 12 8;
    animation: trace-flow 1.5s linear infinite;
    filter: drop-shadow(0 0 4px var(--accent));
}

@keyframes trace-flow {
    to {
        stroke-dashoffset: -40;
    }
}

/* Efeitos de cyberataque para traceroute */
.trace-glow-line {
    stroke: var(--accent);
    stroke-width: 2;
    fill: none;
    opacity: 0.6;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: trace-draw 2s ease forwards;
}

@keyframes trace-draw {
    to {
        stroke-dashoffset: 0;
    }
}

/* Painel de rota no traceroute */
.route-panel {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 10;
    width: 350px;
    max-height: calc(100vh - var(--navbar-height) - 2rem);
    overflow-y: auto;
    background: rgba(15, 21, 37, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.route-panel-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.route-panel-header h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 1rem;
}

.route-panel-body {
    padding: 1rem 1.25rem;
}

/* Steps da rota */
.route-step {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    position: relative;
}

.route-step:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 11px;
    top: 2.5rem;
    bottom: -0.5rem;
    width: 2px;
    background: linear-gradient(to bottom, var(--accent), var(--accent-dim));
}

.route-step-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-dim);
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
    z-index: 1;
}

.route-step-info {
    flex: 1;
}

.route-step-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.route-step-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.route-step-tag {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 4px;
    margin-top: 0.3rem;
}

.route-step-tag.rf {
    background: rgba(0, 212, 255, 0.15);
    color: var(--accent);
}

.route-step-tag.ip {
    background: rgba(99, 102, 241, 0.15);
    color: var(--info);
}

.route-step-tag.uhf {
    background: rgba(0, 255, 136, 0.15);
    color: var(--success);
}

.route-step-tag.vhf {
    background: rgba(255, 170, 0, 0.15);
    color: var(--warning);
}

/* ---- Satellite info sidebar ---- */
.satellite-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.satellite-item {
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.satellite-item:hover {
    border-color: var(--border-accent);
    background: var(--accent-dim);
}

.satellite-item.active {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.satellite-name {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.satellite-freq {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ---- Responsivo para mapa ---- */
@media (max-width: 768px) {
    .map-sidebar {
        position: absolute;
        top: 0;
        right: 0;
        width: 85%;
        max-width: 320px;
        transform: translateX(100%);
    }

    .map-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        right: 0.75rem;
    }

    .map-sidebar.open~.sidebar-toggle {
        right: calc(85% + 0.75rem);
    }

    .route-panel {
        width: calc(100% - 2rem);
        max-width: none;
    }

    .leaflet-popup-content {
        min-width: 220px;
    }
}