/* --- OBSERVABILITY THEME --- */

/* 1. Layout & Containers */
#observability-content {
    width: 95%;
    max-width: 1400px;
    margin: 0 auto;
    padding-bottom: 4rem;
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.obs-section {
    width: 100%;
    position: relative;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.section-header h2 {
    font-family: 'Share Tech Mono', monospace;
    color: #f5c842;
    margin: 0;
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.glass-panel {
    background: rgba(10, 10, 10, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.centered-warning {
    max-width: 500px;
    margin: 4rem auto;
    text-align: center;
}

/* 2. SECTION 1: LOCAL HUD */
.hud-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.hud-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: transform 0.2s, border-color 0.2s;
    min-height: 140px;
}

.hud-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
}

.hud-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #aaa;
}

.hud-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Share Tech Mono', monospace;
    color: #fff;
    margin: 0.5rem 0;
}

.hud-label {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
}

/* 3. SECTION 2: THE PATH (Metro Map) */

/* --- SECTION 2: THE PATH (Rejilla Responsiva) --- */

/* 1. Ocultar los iconos antiguos del HTML estático (ahora los inyectamos por JS) */
.trace-start-icon,
.trace-end-icon {
    display: none !important;
}

/* 2. Contenedor Flexible */
.trace-scroll-wrapper {
    background: rgba(0, 0, 0, 0.3);
    padding: 6rem 8rem 6rem 2rem;
    overflow: visible;
}

.trace-track {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    /* CLAVE: 130px de separación vertical para que las etiquetas no choquen */
    gap: 130px 40px;
    padding: 20px 0;
    width: 100%;
}

/* --- TARJETA DEL NODO (HOP) --- */
.hop-item {
    position: relative;
    width: 140px;
    /* Ancho base */
    height: 20px;
    /* Altura ficticia pequeña, todo flota alrededor del punto */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

/* --- PUNTOS (DOTS) --- */
.hop-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #222;
    border: 3px solid #555;
    z-index: 10;
    /* Siempre encima de la línea */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    /* Flex para centrar iconos dentro (Casa/AWS) */
    display: flex;
    align-items: center;
    justify-content: center;
}

.hop-item.ok .hop-dot {
    background: #1cb495;
    border-color: #fff;
    box-shadow: 0 0 15px #1cb495;
}

.hop-item.timeout .hop-dot {
    background: #ff3e4d;
    border-color: #fff;
    box-shadow: 0 0 15px #ff3e4d;
}

/* Iconos START / END */
.hop-dot.icon-dot {
    width: 40px;
    height: 40px;
    border: 2px solid #f5c842;
    background: #000;
    color: #f5c842;
    font-size: 1.2rem;
    z-index: 15;
}

.hop-dot.aws-dot {
    border-color: #ff9900;
    color: #ff9900;
}

/* 5. Líneas Conectoras */
.hop-line {
    position: absolute;
    top: 50%;
    left: 50%;
    /* Cálculo: Cubre la mitad del item (70px) + el gap (40px) + solape */
    width: 120px;
    height: 2px;
    background: #444;
    z-index: 0;
    transform: translateY(-50%);
    pointer-events: none;
}

/* Ocultar línea en el último elemento (AWS) */
.hop-item.end-node .hop-line {
    display: none;
}

.hop-item.end-node .hop-bottom-info strong {
    font-size: 1rem;
    color: #ff9900;
}

/* Ocultar línea si es el último elemento de una fila visualmente es complejo en CSS puro,
   pero con justify-content: center se disimula bien. */

.hop-line.dashed {
    background: transparent;
    border-top: 2px dashed #ff3e4d;
    height: 0;
}

.hop-line.active {
    background: #1cb495;
    box-shadow: 0 0 5px rgba(28, 180, 149, 0.4);
}

/* Latencia flotante */
.hop-latency {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    padding: 1px 5px;
    font-size: 0.7rem;
    color: #aaa;
    border: 1px solid #333;
    border-radius: 4px;
    white-space: nowrap;
}


/* --- ETIQUETAS SUPERIORES (IP / BADGE / TIMEOUT) --- */
.hop-top-info {
    position: absolute;
    bottom: 35px;
    /* Empuja hacia arriba desde el punto */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column-reverse;
    /* Crece hacia arriba */
    align-items: center;
    gap: 4px;
    width: 200px;
    /* Ancho generoso para textos largos */
    pointer-events: none;
    z-index: 20;
}

.ip-label {
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #fff;
    white-space: nowrap;
}

.bgp-badge {
    background-color: #f5c842;
    color: #000;
    font-weight: 800;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.8);
}

/* --- ETIQUETAS INFERIORES (ASN / PAÍS) --- */
.hop-bottom-info {
    position: absolute;
    top: 35px;
    /* Empuja hacia abajo desde el punto */
    left: 50%;
    transform: translateX(-50%);

    width: 160px;
    /* Limitamos ancho para forzar salto de línea o puntos suspensivos */
    text-align: center;
    z-index: 20;
}

.hop-bottom-info strong {
    display: block;
    font-size: 0.75rem;
    color: #eee;
    margin-bottom: 2px;

    /* TRUCO: Puntos suspensivos si es muy largo */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hop-bottom-info .country-label {
    font-size: 0.7rem;
    color: #888;
}

/* --- TRACE STATS BAR (Recuperado) --- */

.stats-bar {
    display: flex;
    /* Esto pone los elementos en fila horizontal */
    justify-content: space-around;
    /* Espacio equitativo entre ellos */
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.2rem;
    background: rgba(0, 0, 0, 0.4);
    /* Fondo semitransparente */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.stat-item .label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.stat-item .value {
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Share Tech Mono', monospace;
    color: #fff;
}

/* Colores específicos para valores */
.stat-item .value.sla-excellent {
    color: #1cb495;
    text-shadow: 0 0 10px rgba(28, 180, 149, 0.4);
}

.stat-item .value.sla-critical {
    color: #ff3e4d;
    text-shadow: 0 0 10px rgba(255, 62, 77, 0.4);
}

/* 4. SECTION 3: GLOBAL STATUS (AWS Tree) */

.aws-tree-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Root Node */
.tree-root {
    z-index: 2;
    margin-bottom: 20px;
}

.aws-node {
    background: linear-gradient(135deg, #232f3e, #131921);
    border: 1px solid #ff9900;
    /* AWS Orange */
    border-radius: 12px;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 0 20px rgba(255, 153, 0, 0.3);
    position: relative;
}

.aws-node i {
    font-size: 2.5rem;
    color: #fff;
}

.aws-node .node-label {
    color: #fff;
    font-weight: bold;
    text-align: left;
    line-height: 1.2;
}

.aws-node .node-label small {
    color: #aaa;
    font-weight: normal;
}

.led-indicator {
    width: 10px;
    height: 10px;
    background: #1cb495;
    border-radius: 50%;
    box-shadow: 0 0 5px #1cb495;
    animation: blink 2s infinite;
    position: absolute;
    top: 10px;
    right: 10px;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Tree Branches (The Circuit) */
.tree-branches {
    width: 80%;
    height: 40px;
    position: relative;
    margin-bottom: 20px;
}

/* Vertical line from AWS */
.branch-line-vertical {
    position: absolute;
    top: 0;
    left: 50%;
    height: 100%;
    width: 2px;
    background: linear-gradient(to bottom, #ff9900, rgba(255, 255, 255, 0.3));
    z-index: 1;
}

/* Horizontal line (The Bus) */
.branch-line-horizontal {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.3);
}

/* Services Grid */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    width: 100%;
}

.service-card {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 1rem;
    padding-top: 1.5rem;
    text-align: center;
    position: relative;
    transition: all 0.3s;
}

/* Vertical connector to card */
.service-card::before {
    content: '';
    position: absolute;
    top: -22px;
    /* Connect to horizontal bus */
    left: 50%;
    width: 1px;
    height: 22px;
    background: rgba(255, 255, 255, 0.3);
}

.service-card .svc-name {
    font-weight: bold;
    color: #fff;
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.service-card .svc-metric {
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.1rem;
}

/* SLA Status Colors */
.sla-excellent {
    color: #1cb495;
    border-color: #1cb495;
    box-shadow: 0 0 5px rgba(28, 180, 149, 0.2);
}

.sla-good {
    color: #3498db;
    border-color: #3498db;
}

.sla-warning {
    color: #f5c842;
    border-color: #f5c842;
}

.sla-critical {
    color: #ff3e4d;
    border-color: #ff3e4d;
    box-shadow: 0 0 10px rgba(255, 62, 77, 0.2);
}

/* Utility */
.fade-in {
    animation: fadeIn 0.8s ease-out forwards;
    opacity: 0;
}

.delay-1 {
    animation-delay: 0.3s;
}

.delay-2 {
    animation-delay: 0.6s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile */
@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tree-branches {
        width: 95%;
    }
}

/* --- UTILITY & DYNAMIC CLASSES (No Inline Styles) --- */

/* Text Utilities */
.text-muted {
    color: #aaa;
}

.text-critical {
    color: #ff3e4d;
}

.text-warning {
    color: #f5c842;
}

/* Icon Colors */
.icon-stable {
    color: #1cb495;
}

.icon-unstable {
    color: #ff3e4d;
}

/* Status Borders */
.border-critical {
    border-color: #ff3e4d !important;
}

/* Specific Component Styles */
.trace-error-msg {
    color: #ff3e4d;
    padding: 1rem;
    text-align: center;
    font-family: 'Share Tech Mono', monospace;
}

.packet-loss-indicator {
    color: #ff3e4d;
    font-size: 0.7rem;
    margin-top: 4px;
}

/* Visibility Helpers */
.hidden {
    display: none !important;
}

.flex-visible {
    display: flex !important;
}

/* Estilos para Grupos en Sección 3 */
.group-header {
    grid-column: 1 / -1;
    /* Ocupa todo el ancho */
    color: #888;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 1rem;
    padding-bottom: 0.2rem;
    margin-bottom: 0.5rem;
    font-family: 'Share Tech Mono', monospace;
}

.svc-type-tag {
    position: absolute;
    top: 5px;
    right: 8px;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1px 4px;
    border-radius: 3px;
    text-transform: uppercase;
    font-family: 'Share Tech Mono', monospace;
    letter-spacing: 1px;
}

/* --- SECURITY SCAN MODULE --- */

/* Botón de Escaneo */
.scan-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #1cb495;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 1px;
}

.scan-btn:hover:not(:disabled) {
    background: rgba(28, 180, 149, 0.2);
    border-color: #1cb495;
    box-shadow: 0 0 10px rgba(28, 180, 149, 0.3);
}

.scan-btn:disabled {
    opacity: 0.7;
    cursor: wait;
    border-color: transparent;
}

/* Lista de Puertos (Resultados) */
.ports-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 150px;
    /* Scroll si son muchos */
    overflow-y: auto;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.75rem;
}

/* Scrollbar fina para la lista */
.ports-list::-webkit-scrollbar {
    width: 4px;
}

.ports-list::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 2px;
}

.port-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 6px;
    border-radius: 3px;
}

.port-item.port-open {
    background: rgba(255, 62, 77, 0.15);
    border-left: 2px solid #ff3e4d;
}

.port-item.port-stealth {
    border-left: 2px solid #1cb495;
}

.port-item .p-id {
    font-weight: bold;
    color: #fff;
    width: 30px;
}

.port-item .p-name {
    flex-grow: 1;
    color: #aaa;
    text-align: left;
}

.port-item .p-status {
    font-weight: bold;
}

/* Colores de texto en lista */
.port-open .p-status {
    color: #ff3e4d;
}

/* Rojo */
.port-stealth .p-status {
    color: #1cb495;
}

/* Verde */
.port-closed .p-status {
    color: #666;
}



/* --- IP IDENTITY HEADER (CORREGIDO) --- */

.ip-identity-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 1.5rem;
}

/* Usamos el selector padre para centrar SOLO la cabecera */
.ip-identity-container .ip-row {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Centrado horizontal */
    gap: 15px;
}

/* Usamos el selector padre para dar tamaño fijo SOLO a las etiquetas de la cabecera */
.ip-identity-container .ip-label {
    /* Estilo tipo "Botón/Tag" */
    color: #ccc;
    font-size: 0.8rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-family: 'Share Tech Mono', monospace;

    /* Caja */
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 4px;
    line-height: 1;

    /* Dimensiones fijas solo para cabecera */
    min-width: 160px;
    text-align: center;
    display: block;
}

.ip-value {
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.4rem;
    font-weight: bold;
    line-height: 1;
    margin-top: 2px;
}

/* Estados de color para las IPs */
.ip-value.loading {
    color: #aaa;
    font-style: italic;
    font-size: 1rem;
}

.ip-value.detected {
    cursor: pointer;
    border-bottom: 1px dotted rgba(28, 180, 149, 0.5);
    transition: all 0.2s ease;
}

.ip-value.detected:hover {
    color: #fff;
    text-shadow: 0 0 15px #1cb495;
    border-bottom: 1px solid #1cb495;
}

/* Verde Culi */
.ip-value.missing {
    color: #ff3e4d;
    opacity: 0.8;
}

/* Rojo suave */
.ip-value.v6-active {
    color: #3498db;
    text-shadow: 0 0 10px rgba(52, 152, 219, 0.4);
}

/* Azul para v6 */

/* Ajuste Mobile */
@media (max-width: 768px) {
    .ip-identity-container .ip-row {
        flex-direction: column;
        align-items: center;
        /* Centrado en móvil también */
        gap: 0.5rem;
    }

    .ip-identity-container .ip-label {
        min-width: auto;
        font-size: 0.75rem;
    }

    .ip-value {
        font-size: 1.1rem;
    }

    .trace-scroll-wrapper {
        padding: 6rem 1rem;
        /* Reducimos lateral en móvil */
        overflow-x: hidden;
        /* Cortamos la línea si sobresale en móvil para que no descuadre */
    }
}


/* --- MODAL STYLES (Portado de Syslog) --- */

.modal-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.ip-modal-card {
    background-color: #0a0a0a;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    border: 1px solid #1cb495;
    box-shadow: 0 0 30px rgba(28, 180, 149, 0.15);
    position: relative;
    margin: auto;
}

.close-modal {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 2100;
}

.close-modal:hover {
    color: #ff3e4d;
}

.ip-modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ip-modal-header h2 {
    color: #1cb495;
    font-family: 'Share Tech Mono', monospace;
    /* Adaptado al tema actual */
    font-size: 2rem;
    margin: 0;
    text-shadow: 0 0 10px rgba(28, 180, 149, 0.3);
}

.ip-badge {
    background: #333;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Share Tech Mono', monospace;
}

.ip-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.ip-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
}

.ip-section h3 {
    color: #f5c842;
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-bottom: 1rem;
    border-bottom: 1px dashed rgba(245, 200, 66, 0.3);
    padding-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Share Tech Mono', monospace;
}

.ip-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.6rem;
    font-size: 0.85rem;
    font-family: 'Roboto', sans-serif;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    padding-bottom: 4px;
}

.ip-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.ip-label {
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ip-value-modal {
    color: #fff;
    font-weight: 500;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

.peers-header {
    margin-top: 10px;
    margin-bottom: 5px;
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
    border-bottom: 1px solid #333;
    font-family: 'Share Tech Mono', monospace;
    letter-spacing: 1px;
}

.peer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
    font-size: 0.8rem;
}

.peer-asn {
    color: #888;
    font-family: 'Share Tech Mono', monospace;
}

.peer-asn i {
    margin-right: 5px;
    color: #555;
}

.peer-name {
    color: #f5c842;
    /* Amarillo CULI */
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
    font-family: 'Roboto', sans-serif;
}