:root {
    --glass-bg: rgba(22, 27, 34, 0.85);
    /* Slightly darker for better contrast */
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-blur: 16px;
    /* Increased blur */
    --accent-primary: #3b82f6;
    --accent-secondary: #06b6d4;
    --accent-hover: #2563eb;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --font-main: 'Inter', sans-serif;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

html,
body,
#cesiumContainer {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: var(--font-main);
    color: var(--text-primary);
    background-color: #0f172a;
    /* Fallback */
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* --- Top Control Bar --- */
.control-bar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: 999px;
    /* Pill shape */
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 16px;
    border-right: 1px solid var(--glass-border);
}

.brand-logo {
    height: 24px;
    width: auto;
}

.brand-title {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 8px 16px 8px 36px;
    border-radius: 20px;
    font-family: var(--font-main);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
    width: 200px;
}

.search-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
    width: 240px;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-secondary);
    font-size: 12px;
    pointer-events: none;
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-btn {
    background: transparent;
    border: 1px solid transparent;
    /* Invisible border to prevent layout shift */
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    position: relative;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.control-btn.active {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent-primary);
    border-color: rgba(59, 130, 246, 0.3);
}

/* Tooltip implementation via data-title */
.control-btn[data-title]:hover::after {
    content: attr(data-title);
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    animation: fadeIn 0.2s forwards 0.3s;
    /* Delay tooltip */
    pointer-events: none;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        bottom: -40px;
    }
}

/* --- Sidebar & Panels --- */
.glass-panel {
    position: absolute;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 90;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    overflow: hidden;
    /* Entrance Animation */
    opacity: 0;
    transform: translateY(20px);
    animation: slideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#estatisticas {
    top: 90px;
    left: 20px;
    width: 280px;
    max-height: calc(100vh - 120px);
    animation-delay: 0.1s;
}

#pilotosCub {
    top: 90px;
    right: 20px;
    width: 300px;
    max-height: calc(100vh - 120px);
    animation-delay: 0.2s;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.panel-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-title i {
    color: var(--accent-primary);
}

.panel-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: monospace;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
}

/* --- Stats Card Specifics --- */
.network-card {
    margin: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
}

.network-header {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.network-header.ivao {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.1), transparent);
    color: #34d399;
}

.network-header.vatsim {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.1), transparent);
    color: #f87171;
}

.network-header.combined {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1), transparent);
    color: #60a5fa;
}

.network-stats {
    display: flex;
    padding: 16px;
    gap: 12px;
}

.stat-item {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    transition: var(--transition);
}

.stat-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: white;
    line-height: 1.2;
}

.stat-value.ground {
    color: #fca5a5;
    /* Light red/orangeish */
}

.stat-value.inair {
    color: #93c5fd;
    /* Light blue */
}

.stat-label {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 4px;
}

.top5-section {
    padding: 0 16px 16px 16px;
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
}

.top5-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.top5-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    font-size: 12px;
    color: var(--text-primary);
}

.top5-item:last-child {
    border-bottom: none;
}

.airport-code {
    font-family: monospace;
    font-weight: 700;
    color: #e2e8f0;
}

.airport-count {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
}

/* --- Pilots List --- */
.pilots-list-container {
    overflow-y: auto;
    flex: 1;
    padding: 12px;
}

.piloto-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.02);
}

.piloto-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

.piloto-item.highlight {
    background: rgba(6, 182, 212, 0.15);
    border-color: rgba(6, 182, 212, 0.4);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.1);
}

.piloto-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.1);
    margin-right: 12px;
    background-color: #1e293b;
}

.piloto-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.piloto-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.piloto-callsign {
    font-size: 11px;
    color: var(--accent-primary);
    font-family: monospace;
    font-weight: 500;
}

.no-pilots {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.no-pilots i {
    font-size: 32px;
    opacity: 0.3;
}

/* Cesium Customization */
.cesium-baseLayerPicker-dropDown,
.cesium-navigation-help,
.cesium-infoBox {
    z-index: 200 !important;
    background: var(--glass-bg) !important;
    backdrop-filter: blur(20px) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 12px !important;
    color: var(--text-primary) !important;
}

.cesium-toolbar-button {
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 50% !important;
    color: #fff !important;
    box-shadow: var(--shadow-sm);
}

.cesium-performanceDisplay-defaultContainer {
    top: auto !important;
    bottom: 5px !important;
    right: 5px !important;
}

/* --- Custom Tooltip --- */
.custom-tooltip {
    position: absolute;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    padding: 12px 16px;
    border-radius: 12px;
    pointer-events: none;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    font-family: var(--font-main);
    color: var(--text-primary);
    transform: translate(15px, 15px);
    /* Offset from cursor */
    min-width: 180px;
}

.tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip-callsign {
    font-weight: 700;
    font-size: 15px;
    color: white;
    letter-spacing: 0.5px;
}

.tooltip-network {
    font-size: 10px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-secondary);
    text-transform: uppercase;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.tooltip-row i {
    color: var(--accent-primary);
    margin-right: 6px;
    width: 14px;
    text-align: center;
}

.tooltip-route {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    font-family: monospace;
    font-size: 12px;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tooltip-route i {
    color: var(--text-secondary);
    font-size: 10px;
}

/* --- Help Modal --- */
.help-modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    animation: fadeInModal 0.3s;
}

.help-modal.active {
    display: flex;
}

.help-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.help-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
}

.help-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(5px);
}

.help-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.help-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.help-text strong {
    font-size: 14px;
    color: var(--text-primary);
}

.help-text span {
    font-size: 12px;
    color: var(--text-secondary);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
    padding: 4px;
    position: absolute;
    top: 16px;
    right: 16px;
}

.close-btn:hover {
    color: white;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}