/* MeshLink Network Map - 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: #1a1a2e;
    color: #333;
    height: 100vh;
    overflow: hidden;
}

.map-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.map-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    z-index: 1000;
}

.map-header h1 {
    font-size: 1.5em;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.control-select {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.9em;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.control-select option {
    background: #333;
    color: white;
}

.control-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.nav-btn {
    background: rgba(255, 255, 255, 0.15);
}

/* Stats Bar */
.stats-bar {
    background: #f8f9fa;
    padding: 10px 20px;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
    border-bottom: 1px solid #e9ecef;
    z-index: 999;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-label {
    font-size: 0.85em;
    color: #6c757d;
}

.stat-value {
    font-size: 1em;
    font-weight: 600;
    color: #495057;
}

.loading-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    color: #667eea;
    margin-left: auto;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e9ecef;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Map Container */
#map-container {
    flex: 1;
    position: relative;
    min-height: 0;
}

#map {
    width: 100%;
    height: 100%;
}

/* Legend */
.map-legend {
    position: absolute;
    bottom: 30px;
    left: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    padding: 15px;
    z-index: 1000;
    max-width: 280px;
    font-size: 0.85em;
    transition: transform 0.3s, opacity 0.3s;
}

.map-legend.collapsed {
    transform: translateY(calc(100% - 40px));
}

.map-legend.collapsed .legend-section {
    display: none;
}

.legend-section {
    margin-bottom: 12px;
}

.legend-section:last-of-type {
    margin-bottom: 10px;
}

.legend-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 6px;
    font-size: 0.9em;
}

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

.legend-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.legend-line {
    width: 24px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.solid {
    background: #667eea;
}

.legend-line.solid.thick {
    height: 4px;
}

.legend-line.solid.thin {
    height: 2px;
}

.legend-toggle {
    width: 100%;
    padding: 6px;
    border: none;
    background: #f8f9fa;
    color: #667eea;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    margin-top: 5px;
}

.legend-toggle:hover {
    background: #e9ecef;
}

/* Details Panel */
.details-panel {
    position: absolute;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100%;
    background: white;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.details-panel.open {
    right: 0;
}

.details-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.details-header h3 {
    font-size: 1.1em;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

.close-btn:hover {
    opacity: 0.8;
}

.details-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
}

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

.detail-section h4 {
    color: #667eea;
    font-size: 0.95em;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e9ecef;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f1f3f5;
}

.detail-label {
    color: #6c757d;
    font-size: 0.9em;
}

.detail-value {
    color: #212529;
    font-size: 0.9em;
    text-align: right;
}

.detail-value.monospace {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.8em;
}

.detail-link {
    color: #667eea;
    text-decoration: none;
    font-size: 0.9em;
}

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

.battery-bar-container {
    width: 60px;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

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

.connection-item {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    border-left: 3px solid #667eea;
}

.connection-name {
    font-weight: 500;
    color: #495057;
    margin-bottom: 4px;
}

.connection-stats {
    display: flex;
    gap: 12px;
    font-size: 0.85em;
    color: #6c757d;
}

.no-data {
    color: #adb5bd;
    font-style: italic;
    font-size: 0.9em;
}

.detail-actions {
    padding: 15px 20px;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.action-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: opacity 0.2s;
    border: none;
    cursor: pointer;
    margin-bottom: 8px;
}

.action-btn:hover {
    opacity: 0.9;
}

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

/* Airplane marker styles */
.airplane-marker {
    background: transparent;
    border: none;
    cursor: pointer;
}

.airplane-marker .airplane-emoji {
    font-size: 24px;
    display: block;
    text-align: center;
    line-height: 28px;
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.3));
    pointer-events: none;
}

/* Popup Styles */
.node-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.15);
}

.popup-content {
    padding: 5px 0;
}

.popup-title {
    font-weight: 600;
    color: #212529;
    margin-bottom: 4px;
}

.popup-id {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.8em;
    color: #6c757d;
    margin-bottom: 10px;
}

.popup-details {
    margin-bottom: 10px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.9em;
}

.popup-label {
    color: #6c757d;
}

.popup-btn {
    width: 100%;
    padding: 8px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
}

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

/* Responsive */
@media (max-width: 768px) {
    .map-header {
        padding: 10px 15px;
    }

    .map-header h1 {
        font-size: 1.2em;
    }

    .stats-bar {
        padding: 8px 15px;
        gap: 15px;
    }

    .stat-item {
        font-size: 0.9em;
    }

    .map-legend {
        bottom: 15px;
        left: 10px;
        max-width: 220px;
        padding: 10px;
        font-size: 0.8em;
    }

    .details-panel {
        width: 100%;
        right: -100%;
    }

    .details-panel.open {
        right: 0;
    }
}

@media (max-width: 480px) {
    .header-controls {
        width: 100%;
        justify-content: flex-start;
    }

    .control-select,
    .control-btn {
        padding: 6px 10px;
        font-size: 0.85em;
    }

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

    .stat-item {
        flex: 0 0 auto;
    }
}
