/* --- HEADER REDESIGN --- */
.header {
    background: #2c3e50;
    padding: 15px 25px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    border-bottom: 2px solid #3498db;
    text-align: left; /* Override centered text from original */
}

.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-left, .header-right {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px; /* Add spacing between buttons */
}

.header-left {
    justify-content: flex-start;
}

.header-center {
    flex: 1.5;
    text-align: center;
}

.header-right {
    justify-content: flex-end;
    gap: 20px;
}

.header h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 600;
    text-shadow: none;
    letter-spacing: 1px;
}

.info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 15px;
    margin-top: 15px;
    border-radius: 8px;
}

.info-bar-status {
    font-size: 0.9rem;
}

.info-bar-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.operator-filters {
    display: flex;
    gap: 15px;
    padding-left: 15px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

/* --- REFINED TOGGLE SWITCH --- */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 40px;
    height: 22px;
    background: #7f8c8d;
    border-radius: 11px;
    transition: background-color 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
    background: #27ae60;
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(18px);
}

.toggle-switch input[type="checkbox"]:not(:checked) + .toggle-slider {
    background: #F44336;
}

.toggle-label {
    font-weight: 500;
    font-size: 0.85rem;
    text-shadow: none;
    min-width: 0;
}

/* --- NAVIGATION BUTTONS --- */
.nav-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    font-size: 0.9rem;
    border-radius: 20px; /* More rounded */
    color: white;
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    color: white;
    text-decoration: none;
}

/* --- LOGOUT BUTTON --- */
.logout-btn {
    padding: 8px 16px;
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: 25px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 6px;
}

.logout-btn:hover {
    background: rgba(231, 76, 60, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.2);
}

/* --- CLEANUP OLD/ABSOLUTE STYLES --- */
.monitoring-toggle, .lejproximity-toggle, .routes-toggle, .nav-buttons, .operator-filters {
    position: static; /* Override absolute positioning */
    top: auto;
    left: auto;
    right: auto;
}

.flight-info { display: none; } /* Hide the old info bar */

/* Improved Live Status Indicator */
.status-live {
    background: #2ecc71;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-right: 10px;
    animation: pulse-glow 2s infinite;
}
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(46, 204, 113, 0); }
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f1419;
    color: white;
}

/* Old header and toggle styles removed - using new redesigned header above */

/* LEJ Proximity Alert */
.lej-proximity-alert {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    background: linear-gradient(135deg, #FF6B35, #F7931E);
    color: white;
    border-radius: 10px;
    padding: 0;
    margin-bottom: 10px;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
    animation: slideInRight 0.3s ease-out;
    max-width: 300px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.alert-content {
    display: flex;
    align-items: center;
    padding: 15px;
    gap: 12px;
    position: relative;
}

.alert-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.alert-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.alert-text strong {
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.alert-close {
    position: absolute;
    top: 5px;
    right: 8px;
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-close:hover {
    opacity: 1;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* LEJ Airport Marker */
.custom-airport-icon {
    background: none !important;
    border: none !important;
}

.airport-marker {
    font-size: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    animation: airportPulse 2s ease-in-out infinite alternate;
}

@keyframes airportPulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

.airport-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
}

.proximity-zone-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
}

/* Duplicate nav-btn styles removed - defined in header section */

.container {
    display: flex;
    height: 60vh;
}

.sidebar {
    width: 350px;
    background: #1a1a1a;
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid #333;
}

.map-container {
    flex: 1;
    position: relative;
}

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

.info-card {
    background: #2a2a2a;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 4px solid #4CAF50;
}

.info-card h3 {
    margin-top: 0;
    color: #4CAF50;
    font-size: 1.2rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    padding: 5px 0;
    border-bottom: 1px solid #333;
}

.info-row:last-child {
    border-bottom: none;
}

.label {
    color: #888;
    font-weight: 500;
}

.value {
    color: white;
    font-weight: 600;
}

.status-live {
    display: inline-block;
    background: #4CAF50;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.aircraft-icon {
    font-size: 2rem;
    text-align: center;
    margin: 10px 0;
}

.update-btn {
    background: #2196F3;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
    margin-top: 15px;
    transition: background 0.3s;
}

.update-btn:hover {
    background: #1976D2;
}

.route-info {
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    background-size: 200% 200%;
    animation: gradient 3s ease infinite;
}

@keyframes gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.map-style-btn {
    background: #333;
    color: white;
    border: 2px solid #555;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
}

.map-style-btn:hover {
    background: #444;
    border-color: #2196F3;
    transform: translateY(-1px);
}

.map-style-btn.active {
    background: #2196F3;
    border-color: #2196F3;
    color: white;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.flights-table-section {
    background: #1a1a1a;
    color: white;
    padding: 20px;
    border-top: 1px solid #333;
}

.flights-table-section h2 {
    margin: 0 0 20px 0;
    font-size: 1.5rem;
    color: #4CAF50;
    text-align: center;
}

.flights-table {
    width: 100%;
    background: #2a2a2a;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.flights-table table {
    width: 100%;
    border-collapse: collapse;
}

.flights-table th {
    background: #333;
    color: #4CAF50;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 2px solid #4CAF50;
}

.flights-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #333;
    font-size: 0.85rem;
}

.flights-table tr:hover {
    background: rgba(76, 175, 80, 0.1);
    cursor: pointer;
}

.flights-table tr.active-flight {
    background: rgba(33, 150, 243, 0.2);
    border-left: 4px solid #2196F3;
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

/* Sortable table headers */
.flights-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s ease;
}

.flights-table th.sortable:hover {
    background: #404040;
}

.flights-table th.sortable .sort-icon {
    margin-left: 8px;
    font-size: 0.8rem;
    color: #888;
    transition: color 0.2s ease;
}

.flights-table th.sortable:hover .sort-icon {
    color: #4CAF50;
}

.flights-table th.sortable.sorted-asc .sort-icon {
    color: #4CAF50;
}

.flights-table th.sortable.sorted-asc .sort-icon::before {
    content: '↑';
}

.flights-table th.sortable.sorted-desc .sort-icon {
    color: #4CAF50;
}

.flights-table th.sortable.sorted-desc .sort-icon::before {
    content: '↓';
}

/* Filter row */
.flights-table .filter-row {
    background: #2a2a2a;
}

.flights-table .filter-row th {
    padding: 8px;
    border-bottom: 1px solid #444;
    background: #2a2a2a;
}

.flights-table .filter-input,
.flights-table .filter-dropdown {
    width: 100%;
    padding: 6px 8px;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    color: #fff;
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

/* Specific styling for progress filter input (narrower) */
.flights-table .filter-input[data-column="progress"] {
    width: 80px;
    max-width: 100%;
    padding: 6px 4px;
    font-size: 0.75rem;
}

.flights-table .filter-input:focus,
.flights-table .filter-dropdown:focus {
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.flights-table .filter-input::placeholder {
    color: #888;
}

.flights-table .filter-dropdown option {
    background: #333;
    color: #fff;
}

.status-active { background: #4CAF50; }
.status-delayed { background: #FF9800; }
.status-landed { background: #666; }

.aircraft-type {
    font-weight: 600;
    color: #00d4ff;
}

.flight-route {
    color: #FFD700;
    font-weight: 500;
}

/* Route visualization styles */
.airport-marker {
    background: none !important;
    border: none !important;
    font-size: 18px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    transition: transform 0.3s ease;
}

.airport-marker:hover {
    transform: scale(1.3);
}

.route-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3) !important;
}

.route-popup .leaflet-popup-content {
    margin: 15px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    text-align: center !important;
}

.route-popup .leaflet-popup-tip {
    background: #764ba2 !important;
}

/* Flight path animations */
@keyframes flight-pulse {
    0%, 100% { 
        opacity: 0.8; 
        stroke-width: 3;
    }
    50% { 
        opacity: 1; 
        stroke-width: 4;
    }
}

.flight-path-animated {
    animation: flight-pulse 2s ease-in-out infinite;
}

@keyframes dash-flow {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -20; }
}

.remaining-path-animated {
    animation: dash-flow 2s linear infinite;
}

/* Modern Sidebar Design */
.modern-card {
    background: rgba(42, 42, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0;
    margin-bottom: 16px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    overflow: hidden;
}

.modern-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border-color: rgba(76, 175, 80, 0.3);
}

.card-header {
    display: flex;
    align-items: center;
    padding: 16px 20px 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.1), rgba(33, 150, 243, 0.1));
}

.card-icon {
    font-size: 18px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Fleet Summary Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 0;
}

.metric-item {
    background: rgba(42, 42, 42, 0.8);
    padding: 20px 16px;
    text-align: center;
    transition: background 0.3s ease;
}

.metric-item:hover {
    background: rgba(76, 175, 80, 0.1);
}

.metric-value {
    font-size: 24px;
    font-weight: 700;
    color: #4CAF50;
    margin-bottom: 4px;
    font-family: 'SF Mono', Monaco, monospace;
}

.metric-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Statistics List */
.stats-list {
    padding: 16px 20px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: #aaa;
    font-size: 13px;
    font-weight: 500;
}

.stat-value {
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    font-family: 'SF Mono', Monaco, monospace;
}

.status-operational {
    color: #4CAF50 !important;
}

/* Selected Flight */
.selected-flight .card-header {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.2), rgba(78, 205, 196, 0.2));
}

.flight-details {
    padding: 20px;
    text-align: center;
}

.flight-callsign {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    font-family: 'SF Mono', Monaco, monospace;
}

.flight-meta {
    font-size: 12px;
    color: #888;
    opacity: 0.8;
}

/* Control Sections */
.control-section {
    padding: 16px 20px;
}

.control-group {
    margin-bottom: 16px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    font-weight: 600;
}

.control-buttons {
    display: flex;
    gap: 8px;
}

.control-btn {
    flex: 1;
    background: rgba(33, 150, 243, 0.8);
    border: 1px solid rgba(33, 150, 243, 0.6);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: rgba(33, 150, 243, 1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.control-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.control-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.control-btn.risk-toggle {
    background: rgba(244, 67, 54, 0.8);
    border-color: rgba(244, 67, 54, 0.6);
}

.control-btn.risk-toggle:hover {
    background: rgba(244, 67, 54, 1);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.control-btn.refresh {
    background: rgba(255, 152, 0, 0.8);
    border-color: rgba(255, 152, 0, 0.6);
}

.control-btn.refresh:hover {
    background: rgba(255, 152, 0, 1);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.control-btn:disabled,
.control-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-icon {
    font-size: 14px;
}

/* Style Grid */
.style-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.style-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    text-align: center;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.style-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(33, 150, 243, 0.5);
    transform: scale(1.05);
}

.style-btn.active {
    background: rgba(33, 150, 243, 0.8);
    border-color: rgba(33, 150, 243, 1);
    color: white;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

/* Altitude Legend Styles */
.altitude-legend {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    color: #bbb;
}

.legend-color {
    width: 16px;
    height: 8px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Risk Card Specific */
.risk-card .card-header {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.1), rgba(255, 152, 0, 0.1));
}

.risk-summary {
    font-size: 12px;
    color: #ccc;
    margin-top: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    border-left: 3px solid #4CAF50;
}

.risk-timestamp {
    font-size: 10px;
    color: #888;
    margin-top: 8px;
    text-align: center;
    opacity: 0.7;
}

/* Action Section */
.action-section {
    margin-top: 20px;
}

.update-fleet-btn {
    width: 100%;
    background: linear-gradient(135deg, #FF6B35, #FF8C00);
    border: none;
    border-radius: 12px;
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.update-fleet-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.4);
}

.update-fleet-btn .btn-icon {
    font-size: 20px;
}

.btn-content {
    flex: 1;
    text-align: left;
}

.btn-title {
    font-size: 14px;
    font-weight: 700;
    color: white;
    margin-bottom: 2px;
}

.btn-subtitle {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.last-update {
    margin-top: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border-left: 3px solid #2196F3;
}

.update-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 4px;
}

.update-time {
    font-size: 13px;
    color: #fff;
    font-weight: 600;
    font-family: 'SF Mono', Monaco, monospace;
}

.update-source {
    font-size: 10px;
    color: #666;
    margin-top: 4px;
}