/* CSS Custom Properties for Configuration */
:root {
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    
    --panel-left-width: 300px;
    --panel-right-width: 350px;
    --panel-bottom-height: 200px;
    --panel-opacity: 0.65;
}

/* Ensure full viewport height on mobile */
html, body {
    height: 100%;
    min-height: 100vh;
}

/* CSS Custom styles for resize handles */
.resize-handle-left,
.resize-handle-right,
.resize-handle-top {
    transition: background-color 0.2s ease;
}

.resize-handle-left:hover,
.resize-handle-right:hover,
.resize-handle-top:hover {
    background-color: #3b82f6 !important;
}

/* Header Base Styles - All Screen Sizes */
header.bg-gray-800 {
    padding: 8px 16px;
    min-height: 56px;
}

/* Header Components */
header.bg-gray-800 button {
    padding: 6px;
}

header.bg-gray-800 h1 {
    font-size: 1.125rem;
    margin: 0;
}

/* Clustering Slider Styles */
.clustering-slider {
    display: flex;
    align-items: center;
    gap: 6px;
}

.clustering-slider label {
    font-size: 0.875rem;
    color: #d1d5db;
    font-weight: 500;
}

.clustering-slider .slider {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    width: 80px;
    height: 4px;
    border-radius: 2px;
    outline: none;
    transition: all 0.2s ease;
}

.clustering-slider .slider::-webkit-slider-track {
    background: #4b5563;
    height: 4px;
    border-radius: 2px;
    transition: background 0.2s ease;
}

.clustering-slider .slider::-moz-range-track {
    background: #4b5563;
    height: 4px;
    border-radius: 2px;
    transition: background 0.2s ease;
}

.clustering-slider .slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background: #3b82f6;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #1e40af;
    cursor: pointer;
    margin-top: -6px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.clustering-slider .slider::-moz-range-thumb {
    background: #3b82f6;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #1e40af;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.clustering-slider .slider:hover::-webkit-slider-thumb {
    background: #2563eb;
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

.clustering-slider .slider:hover::-moz-range-thumb {
    background: #2563eb;
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

.clustering-slider .slider:active::-webkit-slider-thumb {
    background: #1d4ed8;
    transform: scale(0.95);
}

.clustering-slider .slider:active::-moz-range-thumb {
    background: #1d4ed8;
    transform: scale(0.95);
}

.clustering-slider span {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.75rem;
    color: #9ca3af;
    min-width: 2.5rem;
    text-align: right;
}

/* Sidebar Slider Styles */
.panel .slider {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    outline: none;
    transition: all 0.2s ease;
}

.panel .slider::-webkit-slider-track {
    background: #e5e7eb;
    height: 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.panel .slider::-moz-range-track {
    background: #e5e7eb;
    height: 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.panel .slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background: #3b82f6;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #1e40af;
    cursor: pointer;
    margin-top: -6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.panel .slider::-moz-range-thumb {
    background: #3b82f6;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #1e40af;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.panel .slider:hover::-webkit-slider-thumb {
    background: #2563eb;
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(59, 130, 246, 0.4);
}

.panel .slider:hover::-moz-range-thumb {
    background: #2563eb;
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(59, 130, 246, 0.4);
}

.panel .slider:active::-webkit-slider-thumb {
    background: #1d4ed8;
    transform: scale(0.95);
}

.panel .slider:active::-moz-range-thumb {
    background: #1d4ed8;
    transform: scale(0.95);
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    /* Only stack specific layouts vertically on mobile */
    .flex.flex-col {
        flex-direction: column !important;
    }
    
    /* Keep header horizontal */
    header .flex {
        flex-direction: row !important;
    }
    
    /* Full-width panels on mobile */
    .panel {
        width: 100% !important;
        max-width: 100% !important;
        position: fixed !important;
        transform: none !important;
    }

    /* Reset margins on mobile - map should fill available space */
    .map-container {
        margin: 0 !important;
        flex: 1 !important;
        min-height: 0 !important;
        height: calc(100vh - 52px) !important;
        height: calc(100dvh - 52px) !important;
    }

    /* Ensure map element fills container on mobile */
    #map {
        height: 100% !important;
        min-height: 0 !important;
    }

    aside.panel {
        top: 52px !important;
        height: calc(100vh - 52px) !important;
        height: calc(100dvh - 52px) !important;
    }
    
    /* Larger touch targets */
    .resize-handle-top {
        height: 12px !important;
        top: -6px !important;
        background: linear-gradient(to bottom, #374151, #6b7280) !important;
    }
    
    .resize-handle-left,
    .resize-handle-right {
        width: 12px !important;
        background: linear-gradient(to right, #374151, #6b7280) !important;
    }
    

    
    /* Mobile-friendly buttons */
    button {
        min-height: 44px; /* iOS touch target minimum */
        min-width: 44px;
    }
    
    /* Mobile Header Overrides */
    header.bg-gray-800 {
        padding: 6px 12px;
        min-height: 52px;
    }
    
    header.bg-gray-800 button {
        padding: 8px;
        min-height: 44px;
        min-width: 44px;
    }
    
    header.bg-gray-800 h1 {
        font-size: 0.875rem;
    }
    
    /* Better button spacing on mobile */
    header .flex.items-center.space-x-2 {
        gap: 12px;
    }
    
    /* Hide commit SHA on mobile */
    .commit-sha {
        display: none !important;
    }
    
    /* Mobile clustering slider adjustments - REMOVED (now in sidebar) */
    
    /* Mobile modal adjustments */
    .modal-content {
        margin: 16px !important;
        max-width: calc(100vw - 32px) !important;
    }
}

/* Extreme small screen support */
@media (max-width: 380px) {
    header.bg-gray-800 h1 {
        font-size: 0.8rem;
    }
    
    header.bg-gray-800 {
        padding: 4px 8px;
    }
    
    header .flex.items-center.space-x-2 {
        gap: 8px;
    }
}

/* Extreme small screen support */
@media (max-width: 380px) {
    header.bg-gray-800 h1 {
        font-size: 0.8rem;
    }
    
    header.bg-gray-800 {
        padding: 4px 8px;
    }
    
    header .flex.items-center.space-x-2 {
        gap: 8px;
    }
}


/* Make bottom resize handle more visible */
.resize-handle-top {
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to bottom, #d1d5db, #9ca3af);
    cursor: row-resize;
    z-index: var(--z-dropdown);
}

.resize-handle-top:hover {
    background: linear-gradient(to bottom, #3b82f6, #2563eb);
}

/* Ensure map container fills available space */
#map {
    height: 100%;
    min-height: 400px;
    z-index: 1;
}

/* Prevent map from interfering with modal */
body.modal-open #map {
    pointer-events: none;
}

/* Ensure modal content is always interactive */
.pointer-events-auto {
    pointer-events: auto !important;
}

/* Fix Leaflet control z-index */
.leaflet-control-container {
    z-index: var(--z-sticky);
}

.leaflet-top {
    z-index: var(--z-sticky);
}

/* Mobile touch feedback */
@media (hover: none) and (pointer: coarse) {
    .resize-handle-top {
        background: linear-gradient(to bottom, #374151, #6b7280) !important;
        height: 12px !important;
    }
    
    button:active {
        background-color: #1f2937 !important;
        transform: scale(0.95);
    }
}

/* Custom scrollbar styles */
.overflow-y-auto::-webkit-scrollbar {
    width: 6px;
}

.overflow-y-auto::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}


/* Map controls styling - moved to top-left with padding */
.leaflet-control-container .leaflet-top.leaflet-left {
    top: 10px !important;
    left: 10px !important;
}

/* Ensure zoom controls are properly positioned */
.leaflet-control-zoom {
    margin: 0 !important;
}

/* Add some spacing between zoom controls and other potential top-left elements */
.leaflet-control-container .leaflet-top.leaflet-left .leaflet-control {
    margin: 5px 5px 0 0 !important;
}

/* Glass Panel Styling */
.glass-panel {
    background: rgba(255, 255, 255, var(--panel-opacity));
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1100; /* Ensure panels appear above map and controls */
}

/* Ensure bottom panel has identical top border */
footer.glass-panel {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* Node status colors */
.node-icon.currently-active {
    background-color: #4CAF50;
    color: white;
    border: 2px solid #388E3C;
}

.node-icon.recently-active {
    background-color: #FF9800;
    color: white;
    border: 2px solid #F57C00;
}

.node-icon.inactive {
    background-color: #9E9E9E;
    color: white;
    border: 2px solid #616161;
}

/* Cluster marker styles */
.cluster-marker {
    background: transparent;
}

.cluster-icon {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    border: 3px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    font-weight: bold;
    color: white;
    position: relative;
    transition: all 0.3s ease;
}

.cluster-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.cluster-icon i {
    font-size: 16px;
    margin-right: 2px;
}

.cluster-count {
    font-weight: bold;
    font-size: 12px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Node marker animations */
.node-icon {
    transition: all 0.3s ease;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

@keyframes node-flash-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.0);
        outline: 0 solid rgba(59, 130, 246, 0.0);
    }
    20% {
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.45);
        outline: 2px solid rgba(59, 130, 246, 0.85);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.0);
        outline: 0 solid rgba(59, 130, 246, 0.0);
    }
}

.node-icon.flash {
    animation: node-flash-pulse 0.8s ease-in-out infinite;
}

@keyframes cluster-flash-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
        background: #2196F3;
    }
    25% {
        transform: scale(1.15);
        box-shadow: 0 4px 12px rgba(255, 152, 0, 0.6);
        background: #FF9800;
    }
    50% {
        transform: scale(1.2);
        box-shadow: 0 6px 16px rgba(255, 152, 0, 0.8);
        background: #FF9800;
    }
    75% {
        transform: scale(1.15);
        box-shadow: 0 4px 12px rgba(255, 152, 0, 0.6);
        background: #FF9800;
    }
    100% {
        transform: scale(1);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
        background: #2196F3;
    }
}

.cluster-icon.cluster-flash {
    animation: cluster-flash-pulse 0.6s ease-in-out 2;
}

.node-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Custom cluster styling */
.custom-cluster-marker {
    background: transparent !important;
    border: none !important;
}

.cluster-icon {
    transition: all 0.3s ease;
}

.cluster-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4) !important;
}

/* Status legend styles */
.status-legend {
    background: rgba(255, 255, 255, 0.95);
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    font-size: 12px;
    min-width: 200px;
    max-width: 280px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    gap: 8px;
}

.legend-item .node-icon {
    margin-right: 0;
    flex-shrink: 0;
}

.legend-section-title {
    font-weight: bold;
    margin: 12px 0 8px 0;
    border-top: 1px solid #ddd;
    padding-top: 8px;
    color: #374151;
}

/* Version display */
.commit-sha {
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
    color: #ccc;
}

/* Node popup styling */
.node-popup {
    min-width: 200px;
}

.node-popup h4 {
    margin: 0 0 10px 0;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.node-popup p {
    margin: 5px 0;
    font-size: 12px;
}

.status-badge {
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

.status-badge.currently-active {
    background-color: #4CAF50;
    color: white;
}

.status-badge.recently-active {
    background-color: #FF9800;
    color: white;
}

.status-badge.inactive {
    background-color: #9E9E9E;
    color: white;
}

/* Node markers */
.node-marker {
    background: transparent;
}

.node-icon.moving {
    border: 3px solid rgba(255, 0, 0, 0.8) !important;
}

.node-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    border: 2px solid;
    position: relative;
    transition: all 0.3s ease;
}

.node-icon-directional {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    border: 2px solid;
    position: relative;
    transition: all 0.3s ease;
    clip-path: polygon(50% 0%, 0% 100%, 50% 70%, 100% 100%);
    transform-origin: center;
}

.node-icon i {
    position: relative;
    top: -1px;
}

.node-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

/* Node Popup Styles */
.node-popup {
    min-width: 200px;
    max-width: 300px;
}

.node-popup h4 {
    margin: 0 0 8px 0;
    color: #1f2937;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 4px;
}

.node-role-section {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 6px 0;
    border-bottom: 1px solid #f3f4f6;
}

.role-icon {
    margin-right: 6px;
    color: #666;
    font-size: 14px;
}

.role-badge {
    background: linear-gradient(135deg, #e5e7eb, #d1d5db);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid #d1d5db;
    /* Add pattern for colorblind accessibility */
    background-image: repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(0,0,0,0.05) 2px);
    position: relative;
}

.role-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(90deg, transparent, transparent 1px, rgba(0,0,0,0.1) 1px);
    border-radius: 12px;
    pointer-events: none;
}

.hw-model {
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    color: #6b7280;
    font-weight: 500;
    border: 1px solid #d1d5db;
    margin-left: 6px;
}

.node-popup .space-y-1 > * {
    margin-bottom: 4px;
}

.node-popup strong {
    color: #374151;
}

/* Network Event Styles */
.network-event-line {
    stroke-dasharray: 5, 5;
    animation: dash 20s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -100;
    }
}

.packet-propagation {
    stroke: #10b981;
    stroke-width: 3;
    fill: none;
    opacity: 0.8;
}

.traceroute-path {
    stroke-width: 2;
    fill: none;
    opacity: 0.7;
}

.traceroute-path.good-snr {
    stroke: #10b981;
}

.traceroute-path.medium-snr {
    stroke: #f59e0b;
}

.traceroute-path.poor-snr {
    stroke: #ef4444;
}

/* Error handling styles */
.error-message {
    position: fixed;
    top: 80px;
    right: 16px;
    background: #ef4444;
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    max-width: 300px;
}

.error-message .close-btn {
    float: right;
    cursor: pointer;
    font-weight: bold;
    margin-left: 8px;
}

