/* Modern Premium Dark Glassmorphism Styling for APRS Dashboard */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-base: #0a0b10;
    --bg-surface: rgba(18, 20, 30, 0.65);
    --bg-card: rgba(26, 28, 45, 0.45);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-blue: #3b82f6;
    --accent-blue-glow: rgba(59, 130, 246, 0.3);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.3);
    --accent-purple: #8b5cf6;
    --accent-purple-glow: rgba(139, 92, 246, 0.3);
    --accent-yellow: #f59e0b;
    --accent-orange: #f97316;
    --accent-red: #ef4444;

    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Fira Code', monospace;
    
    --glow-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: blur(12px);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 50% 0%, rgba(139, 92, 246, 0.06) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.04) 0px, transparent 50%);
    background-attachment: fixed;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Page Layout */
.dashboard-container {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    height: 100vh;
    padding: 16px;
    gap: 16px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--glow-shadow);
}

.logo-section h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 30%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-section p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.logo-section p span {
    font-family: var(--font-mono);
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-green);
    letter-spacing: 0.5px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulse 1.8s infinite;
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.5);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-blue);
}

.stat-card.direct::before {
    background: var(--accent-purple);
}

.stat-card.total-pkts::before {
    background: var(--accent-orange);
}

.stat-header {
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-top: 8px;
    font-feature-settings: "tnum";
}

.stat-subtext {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Main Grid (Map + Sidebar) */
.main-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    min-height: 0; /* Important for flex/grid inner scroll behavior */
}

@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr;
        grid-template-rows: 400px auto;
        overflow-y: auto;
    }
    .dashboard-container {
        height: auto;
        overflow-y: auto;
    }
}

.map-container {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: var(--glow-shadow);
    display: flex;
    flex-direction: column;
}

#map {
    width: 100%;
    height: 100%;
    background-color: #1a1a24;
}

/* Custom map overlays/controls styling for premium dark look */
.leaflet-bar {
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--glow-shadow) !important;
}

.leaflet-bar a {
    background-color: #1c1e2f !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.leaflet-bar a:hover {
    background-color: #2b2e47 !important;
    color: #fff !important;
}

/* Sidebar Info Panel */
.sidebar-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
}

.sidebar-card {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--glow-shadow);
    min-height: 0;
}

.sidebar-card.flex-grow {
    flex: 1;
}

.sidebar-card h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-card h2 span {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
}

.sidebar-list-container {
    overflow-y: auto;
    flex: 1;
}

.station-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    transition: var(--transition-smooth);
}

.station-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.05);
}

.station-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.station-symbol {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: bold;
}

.station-callsign {
    font-weight: 600;
    font-size: 14px;
}

.station-path-tag {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.station-meta {
    text-align: right;
}

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

.station-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    text-transform: uppercase;
    margin-top: 2px;
}

.badge-direct {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

.badge-indirect {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

/* Distribution Chart Bars */
.dist-item {
    margin-bottom: 12px;
}

.dist-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.dist-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.dist-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    border-radius: 4px;
    transition: width 0.8s ease-out;
}

/* Bottom Console */
.console-container {
    background: #06070a;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--glow-shadow);
    display: flex;
    flex-direction: column;
    height: 180px;
    overflow: hidden;
}

.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0f1118;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
}

.console-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.console-controls {
    display: flex;
    gap: 8px;
}

.console-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: var(--transition-smooth);
}

.console-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.console-log {
    flex: 1;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 12px;
    line-height: 1.6;
    color: #10b981; /* Default terminal green */
}

.console-line {
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    padding-bottom: 2px;
    margin-bottom: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    animation: console-fade-in 0.2s ease-out;
}

.console-ts {
    color: var(--text-muted);
    margin-right: 8px;
}

.console-src {
    color: #3b82f6;
    font-weight: bold;
    margin-right: 4px;
}

.console-dest {
    color: var(--text-muted);
}

.console-path {
    color: #f59e0b;
    margin-right: 8px;
}

.console-comment {
    color: var(--text-primary);
}

.console-raw {
    color: #4b5563;
    font-style: italic;
    font-size: 11px;
}

/* Custom Marker Styling */
.marker-pin-home {
    background-color: var(--accent-red);
    border: 2px solid #fff;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    width: 24px;
    height: 24px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.marker-pin-station {
    background-color: var(--accent-blue);
    border: 2px solid #fff;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    width: 20px;
    height: 20px;
}

.marker-pin-direct {
    background-color: var(--accent-purple);
}

/* Animations */
@keyframes pulse {
    0% {
        transform: scale(0.9);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.9);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes console-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
