/* MeshLink Node Tracking - CSS Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
}

header h1 {
    font-size: 2em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.stats-bar {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat {
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.stat-label {
    font-size: 0.9em;
    opacity: 0.9;
    margin-right: 8px;
}

.stat-value {
    font-size: 1.2em;
    font-weight: bold;
}

/* Tabs */
.tab-nav {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: all 0.3s;
    color: #666;
}

.tab-btn:hover {
    background: #e9ecef;
}

.tab-btn.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
}

.tab-btn.tab-link {
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
    animation: fadeIn 0.3s;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Controls */
.controls, .topology-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 200px;
    padding: 12px 20px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.search-box:focus {
    outline: none;
    border-color: #667eea;
}

.filter-select {
    padding: 12px 20px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1em;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.filter-select:focus {
    outline: none;
    border-color: #667eea;
}

.refresh-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.refresh-btn:active {
    transform: translateY(0);
}

/* Table */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}

td {
    padding: 15px;
    border-bottom: 1px solid #f1f3f5;
}

tr:hover {
    background: #f8f9fa;
}

.loading {
    text-align: center;
    padding: 40px !important;
    color: #adb5bd;
}

/* Node Info */
.node-name {
    font-weight: 600;
    color: #212529;
}

.node-id {
    font-size: 0.85em;
    color: #6c757d;
    font-family: 'Courier New', monospace;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
}

.status-online {
    background: #d4edda;
    color: #155724;
}

.status-recent {
    background: #fff3cd;
    color: #856404;
}

.status-offline {
    background: #f8d7da;
    color: #721c24;
}

/* Battery */
.battery-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.battery-bar {
    width: 60px;
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
}

.battery-fill {
    height: 100%;
    transition: width 0.3s;
    border-radius: 5px;
}

.battery-high { background: #28a745; }
.battery-medium { background: #ffc107; }
.battery-low { background: #dc3545; }

.battery-charging {
    color: #28a745;
}

/* Buttons */
.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #adb5bd;
    transition: color 0.2s;
}

.close:hover {
    color: #495057;
}

.modal-body {
    margin-top: 20px;
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.detail-item {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid #f1f3f5;
}

.detail-label {
    font-weight: 600;
    width: 150px;
    color: #495057;
}

.detail-value {
    flex: 1;
    color: #212529;
}

/* Topology */
.topology-container {
    min-height: 600px;
    height: 600px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: #ffffff;
    position: relative;
    overflow: hidden;
}

#topology-graph {
    width: 100%;
    height: 100%;
    min-height: 600px;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
}

#topology-graph svg {
    display: block;
    border-radius: 8px;
}

#topology-graph text {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

#topology-graph circle {
    transition: stroke-width 0.2s, r 0.2s;
}

#topology-graph circle:hover {
    stroke-width: 4;
    r: 28;
}

#topology-graph line {
    stroke: #667eea !important;
    stroke-width: 3 !important;
    stroke-opacity: 0.8 !important;
}

#topology-graph .links {
    pointer-events: none;
}

#topology-info {
    position: relative;
    z-index: 10;
}

.info-message {
    text-align: center;
    color: #6c757d;
    padding: 40px;
    line-height: 1.6;
}

.link-item {
    background: white;
    padding: 15px;
    margin: 10px 0;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.link-quality-high { border-left-color: #28a745; }
.link-quality-medium { border-left-color: #ffc107; }
.link-quality-low { border-left-color: #dc3545; }

/* Map */
.map-container {
    min-height: 600px;
    height: 600px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.leaflet-map {
    width: 100%;
    height: 100%;
    min-height: 600px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        margin: 0;
        border-radius: 0;
    }
    
    .stats-bar {
        flex-direction: column;
    }
    
    .controls, .topology-controls {
        flex-direction: column;
    }
    
    .search-box, .filter-select {
        width: 100%;
    }
    
    table {
        font-size: 0.85em;
    }
    
    th, td {
        padding: 10px 8px;
    }
    
    .modal-content {
        margin: 10% 10px;
        padding: 20px;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-muted { color: #6c757d; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.hidden { display: none; }

/* Traceroutes Page Styles */
.route-path {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    max-width: 400px;
}

.route-path code {
    background: #f4f4f4;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    line-height: 1.6;
}

td.center {
    text-align: center;
}

.hop-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.hop-link:hover {
    text-decoration: underline;
}

.trace-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.trace-link:hover {
    text-decoration: underline;
}

.loading, .no-data, .error {
    text-align: center;
    padding: 40px !important;
    color: #6c757d;
    font-style: italic;
}

.error {
    color: #dc3545;
}

/* Connections Page Styles */
.connections-container {
    padding: 20px;
}

.node-connections-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.3s ease;
}

.node-connections-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.node-header {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
}

.node-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.2em;
}

.node-info {
    display: flex;
    gap: 10px;
    align-items: center;
}

.badge {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
}

.connection-count {
    background: #28a745;
}

.connections-list {
    padding: 15px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.connection-item {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    border-left: 4px solid #667eea;
    transition: transform 0.2s ease;
}

.connection-item:hover {
    transform: translateX(5px);
}

.connection-item.quality-high {
    border-left-color: #28a745;
}

.connection-item.quality-medium {
    border-left-color: #ffc107;
}

.connection-item.quality-low {
    border-left-color: #dc3545;
}

.connection-node {
    margin-bottom: 8px;
}

.connection-node strong {
    color: #333;
    font-size: 1em;
}

.connection-node small {
    color: #6c757d;
    font-size: 0.85em;
}

.connection-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.connection-stats .badge {
    background: #e9ecef;
    color: #495057;
    font-size: 0.75em;
    padding: 3px 8px;
}

@media (max-width: 768px) {
    .node-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .connections-list {
        grid-template-columns: 1fr;
    }
}

/* Sortable Column Headers */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: rgba(102, 126, 234, 0.1); }
th.sortable::after { content: ''; display: inline-block; width: 0; margin-left: 6px; }
th.sortable.sort-asc::after { content: ' ▲'; }
th.sortable.sort-desc::after { content: ' ▼'; }