/* === Variables === */
:root {
    --bg:           #0d0d0f;
    --surface:      #141418;
    --surface2:     #1c1c22;
    --border:       #2a2a35;
    --accent:       #3d8ef0;
    --accent-hover: #5aa3f7;
    --text:         #e0e0e8;
    --text-muted:   #8888a0;
    --text-dim:     #555568;
    --green:        #22c55e;
    --red:          #ef4444;
    --orange:       #f59e0b;
    --sidebar-w:    220px;
    --header-h:     56px;
    --radius:       8px;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* === Layout === */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s ease;
    overflow: hidden;
}

.sidebar.collapsed { width: 56px; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    height: var(--header-h);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.logo-icon { font-size: 22px; flex-shrink: 0; }

.logo-text {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.sidebar.collapsed .logo-text { display: none; }

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    line-height: 1;
}

.sidebar-toggle:hover { color: var(--text); background: var(--surface2); }

/* Agent status */
.agent-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    flex-shrink: 0;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.3s;
}

.status-dot.online  { background: var(--green); box-shadow: 0 0 6px color-mix(in srgb, var(--green) 60%, transparent); }
.status-dot.offline { background: var(--red); }

.status-info { overflow: hidden; }

.status-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar.collapsed .status-info { display: none; }

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 8px 0;
    flex-shrink: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(61, 142, 240, 0.12); color: var(--accent); }

.nav-icon { font-size: 18px; flex-shrink: 0; width: 28px; text-align: center; }
.nav-label { font-size: 14px; }
.sidebar.collapsed .nav-label { display: none; }

/* === Main content === */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.page-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.page-title { font-size: 18px; font-weight: 600; }

.page-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* === Toolbar === */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

/* === Search === */
.search-box {
    position: relative;
    flex: 1;
    min-width: 180px;
    max-width: 380px;
}

.search-box input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 8px 36px 8px 12px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}

.search-box input::placeholder { color: var(--text-dim); }
.search-box input:focus { border-color: var(--accent); }

.search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 14px;
}

/* === Filter chips === */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.chip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    padding: 5px 14px;
    transition: all 0.15s;
}

.chip:hover  { border-color: var(--accent); color: var(--text); }
.chip.active { background: rgba(61,142,240,0.15); border-color: var(--accent); color: var(--accent); }

/* === Aircraft grid === */
.aircraft-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.aircraft-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
}

.aircraft-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(61, 142, 240, 0.12);
}

.aircraft-card.selected {
    border-color: var(--accent);
    background: rgba(61, 142, 240, 0.08);
}

.aircraft-card.hidden { display: none !important; }

.card-source {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.source-community { color: var(--orange); }
.source-official   { color: var(--green); }

.card-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 4px;
    color: var(--text);
}

.card-manufacturer {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* === Badges === */
.badge {
    background: var(--surface2);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 11px;
    padding: 2px 8px;
    white-space: nowrap;
}

.badge-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
}

/* === Empty state === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h2 { font-size: 20px; color: var(--text); margin-bottom: 8px; font-weight: 600; }
.empty-state p  { font-size: 14px; line-height: 1.7; margin-bottom: 24px; max-width: 440px; }

/* === Buttons === */
.btn {
    display: inline-block;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    padding: 9px 20px;
    transition: background 0.15s, opacity 0.15s;
    text-align: center;
}

.btn-primary        { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-full { width: 100%; }

/* === Alerts === */
.alert {
    border-radius: var(--radius);
    margin-bottom: 16px;
    padding: 12px 16px;
    font-size: 14px;
}

.alert-error   { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.3);  color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: #fcd34d; }

/* === Login page === */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon-large { font-size: 40px; display: block; margin-bottom: 10px; }
.login-logo h1 { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.login-logo p  { color: var(--text-muted); font-size: 14px; }

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

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 15px;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.15s;
}

.form-group input:focus { border-color: var(--accent); }
.login-form .btn { margin-top: 8px; }

/* === Stub pages === */
.stub-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60vh;
}

/* === Utility === */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.25s ease, width 0.25s ease;
        width: var(--sidebar-w) !important;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 199;
    }

    .sidebar-overlay.visible { display: block; }

    .page-body { padding: 16px; }

    .aircraft-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 12px;
    }

    .toolbar { flex-direction: column; align-items: stretch; }
    .search-box { max-width: 100%; }
}
