/* =========================================================
   BASE Y ESTRUCTURA GENERAL
========================================================= */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    direction: ltr !important;
    text-align: left !important;
}

#map {
    position: fixed;
    inset: 0;
    z-index: 1;
}

/* =========================================================
   BOTÓN MENÚ
========================================================= */
.hud-button-left {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 10;
    background: #222;
    color: #fff;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.2s;
}

.hud-button-left:hover {
    background: #333;
}

/* =========================================================
   PANEL IZQUIERDO (MENÚ)
========================================================= */
.left-menu-panel {
    position: fixed;
    top: 50px;
    left: 12px;
    z-index: 9;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 8px 12px;
    min-width: 180px;
    display: none;
    text-align: left !important;
}

.left-menu-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.left-menu-panel li {
    padding: 8px 6px;
    cursor: pointer;
    color: #fff;
    font-size: 15px;
    text-align: left !important;
    transition: background 0.2s;
}

.left-menu-panel li:hover {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* =========================================================
   PANEL DE SECCIONES
========================================================= */
.section-panel {
    position: fixed;
    top: 80px;
    left: 12px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #444;
    z-index: 11;
    min-width: 260px;
    text-align: left !important;
}

#sectionPanelClose {
    float: right;
    font-size: 18px;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
}

/* =========================================================
   PANEL DERECHO Y TARJETAS DE ACTIVIDAD
========================================================= */
.right-panel {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 340px;
    max-height: 80vh;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid #555;
    border-radius: 8px;
    padding: 8px;
    z-index: 9;
    display: none;
    box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.4);
    color: #fff;
    text-align: left !important;
    direction: ltr !important;
}

.right-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.panel-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #fff;
}

.right-panel-content {
    overflow-y: auto;
    max-height: 70vh;
    text-align: left !important;
}

.activity-block {
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid #666;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.5);
    font-size: 15px;
    color: #fff;
    position: relative;
    text-align: left !important;
    direction: ltr !important;
    line-height: 1.4;
}

.activity-block a {
    color: #4da6ff;
    text-decoration: underline;
}

.activity-time {
    font-size: 0.85em;
    color: #aaa;
    float: right;
    font-weight: normal;
}

.activity-footer {
    margin-top: 10px;
    text-align: right;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 8px;
}

.activity-delete-btn {
    background: #c62828;
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.2s;
}

.activity-delete-btn:hover {
    background: #b71c1c;
}

/* =========================================================
   FICHA FLOTANTE DE NODO
========================================================= */
.node-card {
    position: absolute;
    background: rgba(255, 255, 255, 0.92);
    color: #000;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    padding: 10px 12px 14px 12px;
    min-width: 220px;
    max-width: 260px;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transform: translateY(5px);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
    text-align: left !important;
    direction: ltr !important;
}

.node-card-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.node-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.node-card-title {
    font-weight: 600;
    font-size: 14px;
}

.node-card-close-btn {
    background: transparent;
    border: none;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
}

.node-card-close-btn:hover {
    color: #000;
}

.node-card-body {
    font-size: 13px;
    line-height: 1.4;
    text-align: left !important;
}

.node-card-body div {
    margin-bottom: 3px;
}

.node-card-body a {
    color: #0066cc;
    text-decoration: none;
}

.node-card-body a:hover {
    text-decoration: underline;
}

.node-card-triangle {
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(255, 255, 255, 0.92);
    margin: 4px auto 0 auto;
}

/* =========================================================
   PANEL NODOS CENTRADO Y PANELES FLOTANTES
========================================================= */
.nodes-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 480px;
    max-width: 90vw;
    max-height: 80vh;
    background: rgba(0, 0, 0, 0.90);
    border: 1px solid #666;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.6);
    color: #fff;
    z-index: 20;
    overflow-y: auto;
    text-align: left !important;
}

.nodes-panel-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    float: right;
    cursor: pointer;
}

#nodesPanelContent {
    margin-top: 10px;
    font-size: 15px;
    text-align: left !important;
}

.node-list-item {
    padding: 8px;
    margin: 6px 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #555;
    border-radius: 6px;
    cursor: pointer;
    text-align: left !important;
}

.floating-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 70%;
    max-width: 900px;
    max-height: 80%;
    overflow-y: auto;
    background: rgba(20, 20, 20, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 0 25px rgba(0,0,0,0.45);
    color: white;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    text-align: left !important;
    direction: ltr !important;
}

.floating-panel.show {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.hidden {
    display: none;
}

.floating-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 15px;
}

.floating-panel-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 18px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.floating-panel-close:hover {
    background: rgba(255, 255, 255, 0.30);
}

.floating-panel-body {
    font-size: 15px;
    line-height: 1.4em;
    text-align: left !important;
}

#telemetryTable {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

#telemetryTable th,
#telemetryTable td {
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    text-align: left !important;
}

#telemetryTable th {
    background: rgba(255, 255, 255, 0.10);
    font-weight: bold;
}

#telemetryCards {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.telemetry-card {
    background: rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    padding: 15px;
    width: calc(50% - 15px);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
    text-align: left !important;
    box-sizing: border-box;
}

.telemetry-card h4 {
    margin-top: 0;
    margin-bottom: 10px;
}

.config-item {
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    text-align: left !important;
}

.traceroute-item {
    background: rgba(255, 255, 255, 0.10);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
    text-align: left !important;
}

.tr-item-header {
    font-size: 18px;
    margin-bottom: 10px;
}

.tr-item-body p {
    margin: 4px 0;
}

.tr-item-show {
    margin-top: 10px;
    width: 100%;
    padding: 8px;
    background: rgba(255, 255, 255, 0.20);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
}

.tr-item-show:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Scrollbar */
.floating-panel::-webkit-scrollbar,
.right-panel-content::-webkit-scrollbar,
.nodes-panel::-webkit-scrollbar {
    width: 8px;
}

.floating-panel::-webkit-scrollbar-thumb,
.right-panel-content::-webkit-scrollbar-thumb,
.nodes-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 10px;
}

.floating-panel::-webkit-scrollbar-track,
.right-panel-content::-webkit-scrollbar-track,
.nodes-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

/* =========================================================
   ANIMACIONES DE ONDA Y ENLACES MESH (CORREGIDO)
========================================================= */
.ripple-container.leaflet-div-icon {
    background: transparent !important;
    border: none !important;
}

.node-ripple-effect {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 230, 118, 0.4);
    border: 2px solid #00e676;
    animation: nodePulseWave 1.5s ease-out infinite;
    pointer-events: none;
}

@keyframes nodePulseWave {
    0% { transform: scale(0.2); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

.ripple {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid #00ffcc;
    animation: rippleAnim 1.2s ease-out infinite;
    pointer-events: none;
}

@keyframes rippleAnim {
    0%   { transform: scale(0.1); opacity: 1; }
    100% { transform: scale(2.0); opacity: 0; }
}

/* Animación del movimiento de guiones SVG */
@keyframes lineDashAnim {
    from {
        stroke-dashoffset: 40;
    }
    to {
        stroke-dashoffset: 0;
    }
}

/* Corrección de renderizado SVG para polilíneas Leaflet */
path.animated-mesh-link {
    stroke: #00ffcc !important;
    stroke-dasharray: 8, 8 !important;
    stroke-linecap: round !important;
    animation: lineDashAnim 1.2s linear infinite !important;
    filter: drop-shadow(0px 0px 4px rgba(0, 255, 200, 0.8));
    pointer-events: none;
}

path.animated-text-link {
    stroke: #ffcc00 !important;
    stroke-dasharray: 6, 6 !important;
    stroke-linecap: round !important;
    animation: lineDashAnim 0.6s linear infinite !important;
    filter: drop-shadow(0px 0px 8px rgba(255, 200, 0, 0.9));
    pointer-events: none;
}

.packet-pulse {
    background: transparent;
    border: none;
}

@media (max-width: 600px) {
    .telemetry-card { width: 100%; }
    .floating-panel { width: 90%; padding: 15px; }
    .right-panel { width: calc(100vw - 24px); }
}
