/* SkyRadar - Modern Flight Tracker CSS */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #0ea5e9;
    --accent: #22d3ee;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252542;
    --bg-card: rgba(26, 26, 46, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.05);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.3);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-glass: rgba(0, 0, 0, 0.03);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.1);
    --border-hover: rgba(0, 0, 0, 0.2);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Header */
.header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 64px;
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 20px;
    max-width: 1920px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-icon {
    width: 32px; height: 32px;
    color: var(--primary);
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav { display: flex; gap: 6px; }

.nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.nav-btn svg { width: 18px; height: 18px; }
.nav-btn:hover { background: var(--bg-glass); color: var(--text-primary); }
.nav-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.header-actions { display: flex; align-items: center; gap: 10px; }

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.search-box svg { width: 16px; height: 16px; color: var(--text-muted); }

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    width: 160px;
}

.search-box input::placeholder { color: var(--text-muted); }

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.loading svg { animation: spin 1s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Main */
.main {
    position: fixed;
    top: 64px; left: 0; right: 0; bottom: 0;
}

.view { display: none; height: 100%; }
.view.active { display: block; }

/* Map */
#map { width: 100%; height: 100%; background: var(--bg-primary); }
.leaflet-container { background: var(--bg-primary); font-family: 'Inter', sans-serif; }

.map-overlay {
    position: absolute;
    bottom: 20px; left: 20px;
    z-index: 500;
}

.stats-panel {
    display: flex;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 14px;
    border-right: 1px solid var(--border);
}

.stat-item:last-child { border-right: none; }
.stat-item.clickable { cursor: pointer; }
.stat-item.clickable:hover .stat-value { color: var(--accent); }

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-light);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.map-controls {
    position: absolute;
    top: 20px; right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 500;
}

.map-control-btn {
    width: 40px; height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.map-control-btn:hover {
    background: var(--primary);
    color: white;
}

.map-control-btn svg { width: 20px; height: 20px; }

/* Plane Marker */
.plane-marker-wrapper { background: transparent !important; border: none !important; }

.plane-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    transition: transform 0.1s linear;
    will-change: transform;
}

.plane-marker svg {
    width: 24px; height: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.plane-marker.on-ground svg { fill: var(--warning); }
.plane-marker.in-flight svg { fill: var(--primary-light); }
.plane-marker.selected svg { fill: var(--accent); filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.8)); }

.leaflet-marker-icon { transition: transform 0.1s linear !important; }

/* Popup */
.leaflet-popup-content-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content { margin: 12px 16px; color: var(--text-primary); }
.leaflet-popup-tip { background: var(--bg-secondary); }

.popup-content { min-width: 200px; }
.popup-title { font-size: 1.1rem; font-weight: 600; color: var(--primary-light); }
.popup-airline { font-size: 0.85rem; color: var(--accent); margin: 4px 0; }
.popup-route { font-size: 0.85rem; color: var(--success); font-weight: 500; margin-bottom: 8px; }
.popup-info { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.6; }

/* List View */
.list-container {
    height: 100%;
    padding: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.list-header h2 { font-size: 1.25rem; font-weight: 600; }

.flight-count {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.table-wrapper {
    flex: 1;
    overflow: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.flight-table { width: 100%; border-collapse: collapse; }

.flight-table th,
.flight-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.flight-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.flight-table th.sortable { cursor: pointer; }
.flight-table th.sortable:hover { color: var(--primary-light); }

.flight-table tbody tr {
    background: var(--bg-secondary);
    transition: var(--transition);
    cursor: pointer;
}

.flight-table tbody tr:hover { background: var(--bg-tertiary); }

.airline-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.flying { background: rgba(99, 102, 241, 0.2); color: var(--primary-light); }
.status-badge.ground { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.status-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.action-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover { background: var(--primary); color: white; }

/* Stats View */
.stats-container {
    height: 100%;
    padding: 20px;
    overflow: auto;
}

.stats-header { margin-bottom: 20px; }
.stats-header h2 { font-size: 1.25rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.stats-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.stats-card h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-big {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-light);
    line-height: 1;
}

.stats-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

.stats-list { display: flex; flex-direction: column; gap: 8px; }

.stats-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.stats-list-item span:first-child { font-weight: 500; }
.stats-list-item span:last-child { color: var(--primary-light); font-weight: 600; }

/* Flight Panel */
.flight-panel {
    position: fixed;
    top: 64px; right: -420px;
    width: 400px;
    height: calc(100% - 64px);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 900;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.flight-panel.open { right: 0; }

.panel-close {
    position: absolute;
    top: 16px; right: 16px;
    width: 36px; height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.panel-close:hover { background: var(--danger); color: white; }
.panel-close svg { width: 18px; height: 18px; }

.panel-content { padding: 20px; }

.panel-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.flight-icon {
    width: 52px; height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md);
}

.flight-icon svg { width: 28px; height: 28px; fill: white; }

.flight-title { flex: 1; }
.flight-title h3 { font-size: 1.4rem; font-weight: 700; }
.flight-title span { font-size: 0.85rem; color: var(--text-muted); }

.bookmark-btn {
    width: 40px; height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.bookmark-btn:hover, .bookmark-btn.active {
    background: var(--warning);
    color: white;
}

.bookmark-btn svg { width: 20px; height: 20px; }

.panel-route {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.route-point { text-align: center; }
.route-code { display: block; font-size: 1.5rem; font-weight: 700; color: var(--primary-light); }
.route-name { font-size: 0.75rem; color: var(--text-muted); }

.route-line { color: var(--text-muted); }
.route-line svg { width: 32px; height: 32px; }

.panel-details { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.detail-label { font-size: 0.8rem; color: var(--text-muted); }
.detail-value { font-size: 0.9rem; font-weight: 600; }

.panel-actions { display: flex; gap: 10px; }

.panel-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.panel-btn:hover { background: var(--primary); color: white; }
.panel-btn svg { width: 18px; height: 18px; }

/* Filter Panel */
.filter-panel {
    position: fixed;
    top: 64px; left: -320px;
    width: 300px;
    height: calc(100% - 64px);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    z-index: 900;
    transition: left 0.3s ease;
    overflow-y: auto;
}

.filter-panel.open { left: 0; }

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.filter-header h3 { font-size: 1rem; }

.filter-close {
    width: 32px; height: 32px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.filter-content { padding: 20px; }

.filter-group { margin-bottom: 20px; }
.filter-group label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; }

.filter-options { display: flex; gap: 16px; }

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

.filter-checkbox input { width: 18px; height: 18px; accent-color: var(--primary); }

.filter-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.filter-input:focus { outline: none; border-color: var(--primary); }

.filter-actions { display: flex; gap: 10px; margin-top: 24px; }

.btn-filter {
    flex: 1;
    padding: 12px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-filter:hover { background: var(--primary-dark); }
.btn-filter.secondary { background: var(--bg-tertiary); color: var(--text-primary); }

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.open { display: flex; }

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 400px;
    width: 90%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.shortcuts-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.shortcut {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Bookmarks Panel */
.bookmarks-panel {
    position: fixed;
    top: 64px; right: -320px;
    width: 300px;
    height: calc(100% - 64px);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 850;
    transition: right 0.3s ease;
}

.bookmarks-panel.open { right: 0; }

.bookmarks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.bookmarks-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.bookmarks-list { padding: 16px; }

.bookmark-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.bookmark-item:hover { background: var(--primary); }

.bookmark-info h4 { font-size: 0.9rem; }
.bookmark-info span { font-size: 0.75rem; color: var(--text-muted); }

.bookmark-remove {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 15, 26, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.3s, visibility 0.3s;
}

.loading-overlay.hidden { opacity: 0; visibility: hidden; }

.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loader-plane {
    width: 60px; height: 60px;
    animation: fly 2s ease-in-out infinite;
}

.loader-plane svg {
    width: 100%; height: 100%;
    fill: var(--primary);
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.6));
}

@keyframes fly {
    0%, 100% { transform: translateY(0) rotate(-10deg); }
    50% { transform: translateY(-15px) rotate(10deg); }
}

.loader span { font-size: 1rem; color: var(--text-secondary); }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px; right: 24px;
    padding: 14px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition);
    z-index: 3000;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* Route Line */
.route-line-style {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 10, 10;
    animation: dash 1s linear infinite;
}

@keyframes dash { to { stroke-dashoffset: -20; } }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
    .header-content { padding: 0 12px; }
    .search-box { display: none; }
    .nav-btn span { display: none; }
    .stats-panel { flex-wrap: wrap; left: 12px; right: 12px; bottom: 12px; }
    .flight-panel, .filter-panel, .bookmarks-panel { width: 100%; }
    .flight-panel { right: -100%; }
    .filter-panel { left: -100%; }
}
