/* 1. Habilitar Scroll vertical */
html,
body {
    height: auto !important;
    overflow-y: auto !important;
    min-height: 100vh;
}

/* Contenedor principal */
#syslog-content {
    width: 95%;
    max-width: 1400px;
    margin: 0 auto 2rem auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-bottom: 4rem;
}

/* 1. CONTROLES */
.syslog-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1.5rem;
    padding: 1.5rem;
    justify-content: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.85rem;
    color: #f5c842;
    margin: 0;
    text-transform: uppercase;
    font-weight: 700;
}

.glass-input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    color: #fff;
    font-family: 'Roboto', sans-serif;
    outline: none;
    min-width: 220px;
    color-scheme: dark;
    /* Para que el calendario nativo sea oscuro */
}

/* Asegurar que el select tenga estilo consistente */
select.glass-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position-x: 100%;
    background-position-y: 5px;
    padding-right: 2rem;
    cursor: pointer;
}

select.glass-input option {
    background-color: #000;
    /* Fondo negro para las opciones desplegadas */
    color: #fff;
}

.action-btn {
    height: 40px;
    padding: 0 25px;
    background-color: #1cb495;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    margin-bottom: 2px;
    /* Ajuste visual base */
}

.action-btn:hover {
    background-color: #fff !important;
    color: #1cb495 !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

.action-btn:disabled {
    background-color: #555;
    cursor: not-allowed;
    color: #aaa;
}

/* 2. BARRA DE PROGRESO */
.loading-container {
    background: rgba(0, 0, 0, 0.6);
    border-radius: 12px;
    padding: 1rem 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.loading-text {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #1cb495;
    font-family: 'Courier New', monospace;
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #1cb495;
    width: 0%;
    transition: width 0.2s ease;
    box-shadow: 0 0 10px #1cb495;
}

/* 3. KPI CARDS */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.kpi-card {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    gap: 1rem;
    border-left: 4px solid transparent;
    /* Para el color específico */
}

.kpi-card.border-red {
    border-left-color: #ff3e4d;
}

.kpi-card.border-blue {
    border-left-color: #3498db;
}

.kpi-card.border-orange {
    border-left-color: #e67e22;
}

.kpi-card.border-purple {
    border-left-color: #9b59b6;
}

.kpi-icon {
    font-size: 2rem;
    opacity: 0.8;
}

.border-red .kpi-icon {
    color: #ff3e4d;
}

.border-blue .kpi-icon {
    color: #3498db;
}

.border-orange .kpi-icon {
    color: #e67e22;
}

.border-purple .kpi-icon {
    color: #9b59b6;
}

/* Ajuste al contenedor padre para permitir que el hijo se encoja */
.kpi-data {
    flex: 1;
    /* Ocupa el espacio restante */
    min-width: 0;
    /* CRUCIAL: Permite que el contenedor se encoja más allá del contenido */
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    /* Asegura que nada se salga */
}


.kpi-data h3 {
    font-size: 1.5rem;
    /* Reducimos un poco (de 1.8 a 1.5) para que quepan mejor los dominios */
    margin: 0;
    line-height: 1.2;
    color: #fff;
    font-family: 'Courier New', monospace;
    font-weight: 700;

    /* TRUCO PARA PUNTOS SUSPENSIVOS (...) */
    white-space: nowrap;
    /* Todo en una línea */
    overflow: hidden;
    /* Cortar lo que sobre */
    text-overflow: ellipsis;
    /* Añadir ... al final */
    width: 100%;
    /* Forzar ancho máximo disponible */
    display: block;
}

.kpi-data p {
    margin: 2px 0 0 0;
    font-size: 0.75rem;
    /* Un pelín más pequeño para equilibrar */
    color: #aaa;
    text-transform: uppercase;
    white-space: nowrap;
    /* Que la etiqueta tampoco se rompa */
}

/* 4. GRÁFICOS Y TABLAS (Layout) */
/* Contenedor general para filas */
.charts-row,
.tables-row {
    display: grid;
    gap: 1.5rem;
    width: 100%;
    margin-bottom: 1.5rem;
}

/* Fila de Gráficos: Izquierda ancho (2 partes), Derecha estrecho (1 parte) */
.charts-row {
    grid-template-columns: 2fr 1fr;
}

/* Fila de Tablas: 3 columnas exactamente iguales */
.tables-row {
    grid-template-columns: 1fr 1fr 1fr;
}

/* RESPONSIVE: Solo apilar si la pantalla es pequeña (móvil/tablet vertical) */
@media (max-width: 1000px) {
    .charts-row {
        grid-template-columns: 1fr;
        /* Uno debajo de otro */
    }

    .tables-row {
        grid-template-columns: 1fr;
        /* Uno debajo de otro */
    }
}

.chart-container,
.table-container {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.chart-container h3,
.table-container h3 {
    color: #f5c842;
    font-size: 1rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.canvas-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

/* 5. TABLAS ESTILO DATA */
.table-scroll {
    overflow-y: auto;
    max-height: 300px;
    scrollbar-width: thin;
    scrollbar-color: #1cb495 #222;
    /* SOLUCIÓN AL SCROLL HORIZONTAL */
    overflow-x: hidden;
    /* Forzamos que no haya scroll lateral */
    width: 100%;
    /* Aseguramos ancho */
    padding-right: 2px;
    /* Pequeño ajuste para evitar cortes visuales con la barra vertical */
}

table {
    width: 100%;
    table-layout: fixed;
    /* OBLIGATORIO para que el corte (...) funcione */
    border-collapse: collapse;
    font-size: 0.9rem;
}

table th {
    text-align: left;
    color: #aaa;
    font-weight: 600;
    /* CAMBIO: Reducir padding lateral (antes era 8px, ahora 8px 4px) */
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

table td {
    /* CAMBIO: Reducir padding lateral igual que en th */
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
}

table tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}

/* --- ANCHOS DE COLUMNA Y RECORTE --- */

/* Columna 1 (IP/Dominio): 60% del espacio */
table th:nth-child(1),
table td:nth-child(1) {
    width: 60%;
    /* Efecto puntos suspensivos (...) */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0;
    /* Truco vital para que el navegador respete el recorte */
}

/* Columnas 2 y 3 (Datos): 20% cada una y alineadas a la derecha */
table th:nth-child(2),
table td:nth-child(2),
table th:nth-child(3),
table td:nth-child(3) {
    width: 20%;
    text-align: right;
}

/* --- AJUSTES ESPECÍFICOS PARA LA TABLA 'Top Puertos' --- */

/* Aseguramos que tablePorts use table-layout: fixed igual que la otra */
#tablePorts {
    table-layout: fixed;
}

/* Columna 1: Puerto (un poco más ancha) */
#tablePorts th:nth-child(1),
#tablePorts td:nth-child(1) {
    width: 35%;
    /* Le damos más espacio al puerto */

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0;
}

/* Columna 2: Paquetes (más estrecha, alineada a la derecha) */
#tablePorts th:nth-child(2),
#tablePorts td:nth-child(2) {
    width: 25%;
    /* Un 25% para los números */
    text-align: right;
}

/* Columna 3: Servicio (la más ancha, con ellipsis) */
#tablePorts th:nth-child(3),
#tablePorts td:nth-child(3) {
    width: 40%;
    /* El resto del espacio para el texto del servicio */

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0;
    text-align: left;
    /* Alineación normal para texto */
}

/* Barra de porcentaje dentro de la tabla */
.percent-bar {
    display: inline-block;
    height: 4px;
    background: #ff3e4d;
    border-radius: 2px;
    margin-left: 8px;
    opacity: 0.7;
}

/* 6. TERMINAL DE LOGS */
.terminal-container {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    border: 1px solid #333;
}

.terminal-header {
    background: #1a1a1a;
    padding: 0.5rem 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #aaa;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.terminal-badge {
    background: #ff3e4d;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    animation: blink 2s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.terminal-body {
    background: #0a0a0a;
    height: 400px;
    overflow-y: auto;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #ccc;
}

.log-line {
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    padding-bottom: 2px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.log-line.block {
    border-left: 3px solid #ff3e4d;
    padding-left: 8px;
}

.log-line.pass {
    border-left: 3px solid #1cb495;
    padding-left: 8px;
}

.log-ts {
    color: #888;
    min-width: 140px;
}

.log-action {
    font-weight: bold;
    text-transform: uppercase;
}

.log-action.block {
    color: #ff3e4d;
}

.log-action.pass {
    color: #1cb495;
}

.log-ip {
    color: #f5c842;
}

.log-port {
    color: #3498db;
}

.log-proto {
    color: #9b59b6;
    font-size: 0.8em;
}

.log-meta {
    color: #666;
    font-size: 0.8em;
}

/* --- TOOLTIPS GLOBALES (Anti-Recorte) --- */

/* El texto que dispara el evento */
.tooltip-trigger {
    cursor: help;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.3);
    transition: color 0.2s;
}

.tooltip-trigger:hover {
    color: #fff !important;
    text-shadow: 0 0 5px currentColor;
}

/* La ventana flotante (Generada por JS en el body) */
#culi-tooltip {
    position: fixed;
    /* FIXED: Se sale de cualquier contenedor con scroll */
    z-index: 100000;
    /* Encima de todo, incluso del header */
    background: rgba(10, 10, 10, 0.98);
    border: 1px solid #1cb495;
    border-radius: 6px;
    padding: 10px 14px;
    color: #eee;
    font-size: 0.75rem;
    font-family: 'Roboto', sans-serif;
    line-height: 1.4;
    text-align: center;
    max-width: 240px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.9), 0 0 15px rgba(28, 180, 149, 0.2);
    pointer-events: none;
    /* El ratón lo atraviesa para no parpadear */

    /* Animación de entrada */
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#culi-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Triángulo decorativo (opcional) */
#culi-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    /* Abajo del todo */
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #1cb495 transparent transparent transparent;
}

/* --- ESTILOS MODAL IP INFO --- */

/* Fondo oscurecido (Overlay) */
.modal-overlay {
    display: none;
    /* Oculto por defecto */
    position: fixed;
    z-index: 2000;
    /* Encima de todo */
    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;
}

/* Contenido de la tarjeta */
.ip-modal-card {
    background-color: #0a0a0a;
    /* Fondo muy oscuro */
    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;
    /* Centrado si usamos flex en overlay */
}

/* Botón cerrar */
.close-modal {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
}

.close-modal:hover {
    color: #ff3e4d;
}

/* Cabecera del Modal */
.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: 'Courier New', monospace;
    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;
}

.ip-badge.bogon {
    background: #ff3e4d;
    color: #fff;
}

.ip-badge.clean {
    background: #3498db;
    color: #fff;
}

/* Grid de detalles */
.ip-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Secciones (Geo, Network, etc.) */
.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;
    /* Amarillo */
    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;
}

/* Filas de datos */
.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 {
    color: #fff;
    font-weight: 500;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

/* Icono de info para tooltip */
.info-icon {
    color: #3498db;
    cursor: help;
    font-size: 0.8rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.info-icon:hover {
    opacity: 1;
    text-shadow: 0 0 5px #3498db;
}

/* Enlace clicable en tablas */
.ip-clickable {
    /* Estilos Visuales (Lo que ya tenías) */
    cursor: pointer;
    border-bottom: 1px dotted #f5c842;
    transition: all 0.2s;

    /* Estilos de Layout (Lo nuevo para evitar desbordes) */
    display: block;
    /* Necesario para que el width/overflow funcionen */
    overflow: hidden;
    /* Oculta lo que sobra */
    text-overflow: ellipsis;
    /* Pone los puntos suspensivos (...) */
    white-space: nowrap;
    /* Evita que el texto salte de línea */
}

.ip-clickable:hover {
    color: #fff !important;
    text-shadow: 0 0 8px #f5c842;
    border-bottom-style: solid;
}

/* Animación de entrada */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- AJUSTES DE CABECERA Y HERRAMIENTA IP --- */

/* Ajuste del Título para integrar subtítulo */
#header h1 {
    font-size: 2.5em;
    margin: 0 0 0.2em 0;
    line-height: 1.2;
    display: inline-block;
}

#header h1 i {
    margin-right: 10px;
}

.header-subtitle {
    font-size: 0.9em !important;
    color: rgba(255, 255, 255, 0.5);
    margin: 0 0 1rem 0;
    text-transform: none;
    font-weight: 400;
}

/* --- BARRA DE HERRAMIENTAS IP --- */
.ip-tools-bar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Centrado extra */
    gap: 8px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(28, 180, 149, 0.5);
    border-radius: 50px;

    /* Altura y padding ajustados */
    padding: 0 6px 0 15px;
    height: 32px;

    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.ip-tools-bar:hover {
    border-color: #1cb495;
    box-shadow: 0 0 15px rgba(28, 180, 149, 0.2);
}

.ip-input-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-label {
    font-size: 0.7em;
    color: #aaa;
    text-transform: uppercase;
    font-weight: 700;
    margin-top: 1px;
}

/* Input estilo Terminal */
#userCurrentIp {
    background: transparent;
    border: none;
    border-bottom: 1px solid transparent;
    color: #fff;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    width: 110px;
    padding: 0;
    height: 20px;
    outline: none;
    text-align: center;
    transition: border-color 0.3s, width 0.3s;
}

#userCurrentIp:focus {
    border-bottom-color: #f5c842;
    color: #f5c842;
    width: 120px;
}

/* --- ESTA ES LA PARTE QUE TE FALTABA O ESTABA MAL --- */
/* Forzamos el botón a ser pequeño y redondo */
.ip-tools-bar .action-btn.ip-btn {
    width: 26px !important;
    /* Ancho forzado */
    height: 26px !important;
    /* Alto forzado */
    min-width: auto !important;
    /* Evita herencias */
    padding: 0 !important;
    /* Sin relleno */
    border-radius: 50% !important;
    /* Totalmente redondo */

    background: rgba(255, 255, 255, 0.1) !important;
    color: #1cb495 !important;
    border: none;

    display: flex;
    align-items: center;
    justify-content: center;

    margin: 0 0 0 5px;
    /* Un poco de aire a la izquierda */
    box-shadow: none;
}

/* Efecto Hover del botón */
.ip-tools-bar .action-btn.ip-btn:hover {
    background: #1cb495 !important;
    color: #fff !important;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(28, 180, 149, 0.4);
}

/* Nuevo color para tarjetas "buenas" en LAN */
.kpi-card.border-green {
    border-left-color: #2ecc71;
}

.border-green .kpi-icon {
    color: #2ecc71;
}

/* --- ESTILOS MODAL DETALLES (Action Details) --- */

/* Contenedor con scroll vertical */
.modal-table-wrapper {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Adiós scroll horizontal */
    margin-top: 10px;
}

/* La tabla en sí */
.modal-action-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    /* OBLIGATORIO para respetar anchos */
    font-size: 0.9rem;
}

/* Cabecera */
.modal-action-table thead tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: #1cb495;
}

.modal-action-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 700;
}

/* Filas */
.modal-action-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- COLUMNAS ESPECÍFICAS --- */

.modal-action-table td {
    vertical-align: top;
    padding-top: 8px;
}

/* 1. Hora: La protegemos de la regla global "max-width: 0" */
.modal-action-table .col-time {
    width: 90px !important;
    min-width: 90px !important;
    max-width: none !important;
    white-space: nowrap !important;
    color: #aaa;
    font-family: 'Courier New', monospace;
    text-align: left !important;
}

/* 2. Dominio: Ocupa todo el espacio libre */
.modal-action-table .col-domain {
    width: auto !important;
    max-width: none !important;
    text-align: left !important;
    color: #f5c842;
    word-break: break-all;
    line-height: 1.3;
}

/* 3. Cliente */
.modal-action-table .col-client {
    width: 140px !important;
    min-width: 140px !important;
    text-align: right !important;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}