:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #141b2d;
    --bg-tertiary: #1a2332;
    --accent-primary: #fbbf24;
    /* Pro Gold */
    --accent-secondary: #7c3aed;
    /* Deep Blue */
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0f1419 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 20px;
    gap: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px 30px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px var(--shadow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-left h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: #ffffff;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 14px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    /* Animation handled by connected class */
}

.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
    animation: blink-green 2s infinite;
}

@keyframes blink-green {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 10px var(--success);
    }

    50% {
        opacity: 0.4;
        box-shadow: 0 0 2px var(--success);
    }
}

.header-right {
    display: flex;
    gap: 15px;
}

.stat-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 20px;
    min-width: 100px;
    text-align: center;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
    color: var(--accent-primary);
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px var(--shadow);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.panel-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.btn {
    padding: 8px 16px;
    background: var(--accent-secondary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: #6d28d9;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
}

/* Packet Table */
.table-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.packet-table {
    width: 100%;
    border-collapse: collapse;
}

.packet-table thead {
    position: sticky;
    top: 0;
    background: var(--bg-tertiary);
    z-index: 10;
}

.packet-table th {
    padding: 12px 15px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.packet-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.packet-table tbody tr:hover {
    background: var(--bg-tertiary);
    cursor: pointer;
}

.packet-table tbody tr.new-packet {
    background: rgba(0, 212, 255, 0.1);
    animation: highlight 2s ease-out;
}

@keyframes highlight {
    0% {
        background: rgba(0, 212, 255, 0.3);
    }

    100% {
        background: transparent;
    }
}

.packet-table td {
    padding: 12px 15px;
    font-size: 13px;
}

.packet-table .no-data {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.time {
    font-family: 'Roboto Mono', monospace;
    color: var(--text-secondary);
    font-size: 12px;
}

.node-name {
    font-weight: 500;
    color: var(--accent-primary);
}

.path-start-node {
    color: #10b981;
    /* Green */
    font-weight: 600;
}

.path-end-node {
    color: #ef4444;
    /* Red */
    font-weight: 600;
}

.location {
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
}

.signal {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
}

.signal-good {
    color: var(--success);
}

.signal-medium {
    color: var(--warning);
}

.signal-poor {
    color: var(--danger);
}

.path {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.path-hop {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: 'Roboto Mono', monospace;
}

.hops {
    font-family: 'Roboto Mono', monospace;
    font-weight: 600;
    color: var(--accent-secondary);
}

/* Map */
#map {
    flex: 1;
    background: var(--bg-tertiary);
}

.leaflet-container {
    background: #1a1a2e !important;
}

/* Custom Scrollbar */
.table-container::-webkit-scrollbar {
    width: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--accent-secondary);
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #6d28d9;
}

/* Responsive */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

/* Custom Map Markers */
.custom-marker {
    background: transparent !important;
    border: none !important;
}

.marker-icon {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.marker-dot {
    width: 12px;
    height: 12px;
    position: relative;
    /* Enable z-index */
    z-index: 10;
    background: var(--accent-primary);
    border: 2px solid var(--bg-primary);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.neighbor-marker .marker-dot {
    background: var(--success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.repeater-marker .marker-dot {
    background: #3b82f6;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.packet-marker .marker-dot {
    background: var(--accent-secondary);
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.5);
}

.marker-label {
    position: absolute;
    top: 14px;
    white-space: nowrap;
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px var(--shadow);
    pointer-events: none;
    z-index: 400;
    opacity: 0.95;
}

/* Hide labels when popup is open */
.leaflet-popup-pane~.leaflet-marker-pane .marker-label {
    display: none;
}


.marker-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-primary);
    opacity: 0.6;
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

.highlight-marker .marker-pulse {
    width: 40px;
    height: 40px;
    background: #ef4444;
}

.marker-popup {
    font-family: 'Inter', sans-serif;
}

.marker-popup h3 {
    margin: 0 0 8px 0;
    color: var(--accent-primary);
    font-size: 14px;
}

.marker-popup p {
    margin: 4px 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.marker-popup strong {
    color: var(--text-primary);
}

.route-line {
    animation: dash 20s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -1000;
    }
}

/* Hide Leaflet attribution flag */
.leaflet-attribution-flag {
    display: none !important;
}

/* Hide Leaflet attribution text */
.leaflet-control-attribution {
    display: none !important;
}

/* Dark theme for Leaflet popups */
.leaflet-popup-content-wrapper {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 32px var(--shadow) !important;
}

.leaflet-popup-content {
    margin: 16px !important;
    font-family: 'Inter', sans-serif !important;
}

.leaflet-popup-content h3 {
    color: #fbbf24 !important;
    margin: 0 0 12px 0 !important;
    font-size: 16px !important;
}

.leaflet-popup-content p {
    color: var(--text-secondary) !important;
    margin: 6px 0 !important;
    font-size: 13px !important;
}

.leaflet-popup-content strong {
    color: var(--text-primary) !important;
}

.leaflet-popup-content code {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    padding: 6px !important;
    border-radius: 4px !important;
    font-family: 'Roboto Mono', monospace !important;
}

.leaflet-popup-tip {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border) !important;
}

.leaflet-popup-close-button {
    color: var(--text-secondary) !important;
    font-size: 20px !important;
}

.leaflet-popup-close-button:hover {
    color: var(--text-primary) !important;
}

/* Hop markers for routing path */
.hop-marker .marker-dot {
    background: #f59e0b;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.8);
    width: 14px;
    height: 14px;
}

.receiver-marker .marker-dot {
    background: #ef4444;
    box-shadow: 0 0 20px rgba(239, 68, 68, 1);
    width: 16px;
    height: 16px;
    animation: receiver-pulse 2s infinite;
}

@keyframes receiver-pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(239, 68, 68, 1);
    }

    50% {
        transform: scale(1.2);
        box-shadow: 0 0 30px rgba(239, 68, 68, 1);
    }
}

.route-arrow {
    color: #f59e0b;
    font-size: 20px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    background: transparent !important;
    border: none !important;
    z-index: 650 !important;
}

.route-highlight {
    animation: route-pulse 2s infinite;
    z-index: 600 !important;
}

@keyframes route-pulse {

    0%,
    100% {
        opacity: 0.8;
    }

    50% {
        opacity: 1;
    }
}

/* Ensure route elements stay on top */
.leaflet-overlay-pane svg {
    z-index: 600 !important;
}

/* Missing hops warning badge */
.missing-hops-warning {
    background: transparent !important;
    border: none !important;
}

.warning-badge {
    background: rgba(239, 68, 68, 0.95);
    border: 2px solid #dc2626;
    border-radius: 8px;
    padding: 8px 12px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    text-align: center;
    white-space: nowrap;
}

.warning-icon {
    font-size: 16px;
    margin-right: 6px;
}

.warning-text {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.9;
}

.warning-details {
    margin-top: 4px;
    font-size: 10px;
    opacity: 0.8;
    font-weight: 400;
}

/* Missing hops warning box - fixed position */
.missing-hops-warning-box {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.missing-hops-warning-box .warning-badge {
    background: rgba(239, 68, 68, 0.95);
    border: 2px solid #dc2626;
    border-radius: 8px;
    padding: 12px 16px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    min-width: 200px;
}

/* Numbered hop markers */
.numbered-hop-marker {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hop-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 3px solid white;
}

/* Numbered hop markers */
.numbered-hop-marker {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hop-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 3px solid white;
}

/* Segment number markers on lines */
.segment-number-marker {
    background: transparent !important;
    border: none !important;
}

.segment-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
    border: 2px solid white;
}

/* Route Information Panel */
.route-info-panel {
    position: fixed;
    bottom: -300px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 20px;
    box-shadow: 0 -8px 32px var(--shadow);
    backdrop-filter: blur(10px);
    z-index: 1000;
    transition: bottom 0.3s ease-out;
}

.route-info-panel.visible {
    bottom: 0;
}

.route-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.route-info-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--accent-primary);
}

.remove-route-btn {
    padding: 8px 16px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.remove-route-btn:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.route-hops {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0;
}

.hop-badge {
    min-width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 3px solid white;
}

.hop-badge-number {
    font-size: 16px;
}

.hop-arrow {
    font-size: 20px;
    color: var(--text-secondary);
    font-weight: bold;
}

.hop-distance {
    background: var(--bg-tertiary);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
    white-space: nowrap;
}

.route-total {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    font-size: 16px;
    color: var(--text-primary);
    text-align: center;
}

.route-total strong {
    color: var(--accent-primary);
}

/* Multi-path badge */
.path-count-badge {
    display: inline-block;
    background: linear-gradient(135deg, #00d4ff 0%, #0077ff 100%);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    transition: all 0.2s;
}

.path-count-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.6);
}

/* Path list dropdown */
.path-list-row {
    background: rgba(59, 130, 246, 0.05);
    border-left: 3px solid #667eea;
}

.path-list-container {
    padding: 12px 20px;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.path-list-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.path-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin: 4px 0;
    background: var(--bg-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.path-list-item:hover {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: #3b82f6;
    transform: translateX(4px);
}

.path-list-item.shortest-path {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.path-index {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 20px;
}

.path-route {
    flex: 1;
    font-family: 'Roboto Mono', monospace;
    font-size: 12px;
    color: var(--text-primary);
}

.path-stats {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-shortest {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
}

.updated-packet {
    animation: pulse 1s ease-in-out;
}

@keyframes pulse {

    0%,
    100% {
        background: transparent;
    }

    50% {
        background: rgba(59, 130, 246, 0.15);
    }
}

/* Expansion column */
.expand-col {
    text-align: center;
    vertical-align: middle;
    width: 35px;
    padding: 8px 4px !important;
}

.expand-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 auto;
    user-select: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.expand-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.3);
}

.expand-btn:active {
    transform: scale(0.92);
}

/* Update badge style to be more subtle if it's just info */
.path-count-badge.badge-info {
    cursor: default;
    background: rgba(102, 126, 234, 0.15);
    color: #a3bffa;
    border: 1px solid rgba(102, 126, 234, 0.3);
    box-shadow: none;
}

.path-count-badge.badge-info:hover {
    transform: none;
    box-shadow: none;
}