/* ═══════════════════════════════════════════════════════════════════════════
   DENDAT Orbiter — Satellite Tracking & Signal Decoding Platform
   Dark space theme with accent blues and orbital greens
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --bg-primary: #05080f;
    --bg-secondary: #0a0f1a;
    --bg-card: #0d1321;
    --bg-card-hover: #111827;
    --bg-input: #0f1629;
    --border: rgba(56, 189, 248, 0.08);
    --border-hover: rgba(56, 189, 248, 0.15);
    --border-active: rgba(56, 189, 248, 0.3);

    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-heading: #f1f5f9;

    --accent-blue: #38bdf8;
    --accent-cyan: #22d3ee;
    --accent-green: #34d399;
    --accent-purple: #a78bfa;
    --accent-amber: #fbbf24;
    --accent-red: #f87171;
    --accent-orange: #fb923c;

    --orbital-glow: rgba(56, 189, 248, 0.12);
    --signal-glow: rgba(34, 211, 238, 0.12);

    --sidebar-width: 240px;
    --topbar-height: 52px;
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;

    --font-display: 'Space Grotesk', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
    font-family: var(--font-display);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: var(--accent-blue); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-cyan); }
button { cursor: pointer; font-family: inherit; }
input, select, textarea {
    font-family: inherit;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 0.9rem;
    transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.1);
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition), transform var(--transition);
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-width))); }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}
.brand-icon {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    border-radius: var(--radius);
    color: #000;
    font-size: 18px;
}
.brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-heading);
}
.brand-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.brand-text { display: flex; flex-direction: column; }

.sidebar-nav {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
}
.nav-item:hover { background: var(--orbital-glow); color: var(--text-primary); }
.nav-item.active {
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent-blue);
    border-left: 2px solid var(--accent-blue);
}
.nav-item i { font-size: 16px; width: 20px; text-align: center; }

.nav-section {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    padding: 16px 12px 6px;
    text-transform: uppercase;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}
.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: #fff;
}
.user-name { font-size: 0.8rem; font-weight: 500; color: var(--text-primary); }
.user-role { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.logout-btn { margin-top: 4px; }
.logout-btn:hover { color: var(--accent-red) !important; }

/* ─── Main Content ──────────────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition);
}
.sidebar.collapsed ~ .main-content { margin-left: 0; }

.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: rgba(5, 8, 15, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    z-index: 50;
}
.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    padding: 4px;
}
.topbar-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-heading);
    flex: 1;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.utc-clock {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-green);
    letter-spacing: 0.5px;
    padding: 4px 10px;
    background: rgba(34, 211, 159, 0.08);
    border-radius: var(--radius);
    border: 1px solid rgba(34, 211, 159, 0.12);
}
.topbar-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius);
    transition: all var(--transition);
}
.topbar-btn:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

.page-content { padding: 20px; }

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition);
}
.card:hover { border-color: var(--border-hover); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-title i { color: var(--accent-blue); font-size: 16px; }

/* ─── Stat Cards ────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--stat-accent, var(--accent-blue));
}
.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-heading);
    line-height: 1;
}
.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 6px;
}
.stat-icon {
    position: absolute;
    top: 14px; right: 14px;
    font-size: 20px;
    color: var(--stat-accent, var(--accent-blue));
    opacity: 0.5;
}

/* ─── Grid Layouts ──────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }

/* ─── Tables ────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(56, 189, 248, 0.04);
    font-size: 0.85rem;
    color: var(--text-secondary);
}
tr:hover td { background: rgba(56, 189, 248, 0.03); }
td.mono { font-family: var(--font-mono); font-size: 0.8rem; }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all var(--transition);
    cursor: pointer;
}
.btn:hover { border-color: var(--border-hover); background: var(--bg-card-hover); color: var(--text-heading); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    color: #000;
    border-color: transparent;
    font-weight: 600;
}
.btn-primary:hover { opacity: 0.9; color: #000; }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-danger { border-color: rgba(248, 113, 113, 0.3); color: var(--accent-red); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.1); }
.btn-success { border-color: rgba(52, 211, 153, 0.3); color: var(--accent-green); }
.btn-success:hover { background: rgba(52, 211, 153, 0.1); }
.btn-icon { padding: 6px 8px; min-width: 32px; justify-content: center; }

/* ─── Badges ────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}
.badge-blue { background: rgba(56, 189, 248, 0.12); color: var(--accent-blue); }
.badge-green { background: rgba(52, 211, 153, 0.12); color: var(--accent-green); }
.badge-amber { background: rgba(251, 191, 36, 0.12); color: var(--accent-amber); }
.badge-red { background: rgba(248, 113, 113, 0.12); color: var(--accent-red); }
.badge-purple { background: rgba(167, 139, 250, 0.12); color: var(--accent-purple); }
.badge-cyan { background: rgba(34, 211, 238, 0.12); color: var(--accent-cyan); }

/* ─── Category Colors ───────────────────────────────────────────────────── */
.cat-stations { color: var(--accent-amber); }
.cat-weather, .cat-noaa { color: var(--accent-cyan); }
.cat-amateur { color: var(--accent-green); }
.cat-starlink { color: var(--accent-blue); }
.cat-military { color: var(--accent-red); }
.cat-science { color: var(--accent-purple); }
.cat-gps-ops, .cat-galileo { color: var(--accent-orange); }

/* ─── Map Container ─────────────────────────────────────────────────────── */
.map-container {
    width: 100%;
    height: 500px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    background: var(--bg-card);
}
.map-container.fullheight { height: calc(100vh - var(--topbar-height) - 40px); }

/* ─── Satellite List Items ──────────────────────────────────────────────── */
.sat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(56, 189, 248, 0.04);
    transition: background var(--transition);
}
.sat-item:hover { background: rgba(56, 189, 248, 0.03); }
.sat-item .sat-name { font-weight: 500; color: var(--text-heading); flex: 1; }
.sat-item .sat-norad { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); }
.sat-item .sat-category { font-size: 0.7rem; }
.track-star {
    font-size: 16px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color var(--transition);
}
.track-star.tracked { color: var(--accent-amber); }
.track-star:hover { color: var(--accent-amber); }

/* ─── Pass Cards ────────────────────────────────────────────────────────── */
.pass-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    display: flex;
    gap: 14px;
}
.pass-elevation {
    width: 60px; height: 60px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.pass-elevation.excellent { background: rgba(52, 211, 153, 0.12); color: var(--accent-green); border: 2px solid rgba(52, 211, 153, 0.3); }
.pass-elevation.good { background: rgba(56, 189, 248, 0.12); color: var(--accent-blue); border: 2px solid rgba(56, 189, 248, 0.3); }
.pass-elevation.fair { background: rgba(251, 191, 36, 0.12); color: var(--accent-amber); border: 2px solid rgba(251, 191, 36, 0.3); }
.pass-elevation.poor { background: rgba(248, 113, 113, 0.12); color: var(--accent-red); border: 2px solid rgba(248, 113, 113, 0.3); }
.pass-elevation small { font-size: 0.55rem; font-weight: 400; }
.pass-info { flex: 1; }
.pass-sat-name { font-weight: 600; color: var(--text-heading); margin-bottom: 4px; }
.pass-times { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-secondary); }
.pass-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ─── Spectrum Visualization ────────────────────────────────────────────── */
.spectrum-container {
    width: 100%;
    height: 300px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.spectrum-canvas { width: 100%; height: 100%; }

/* ─── Forms ─────────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ─── Upload Zone ───────────────────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.03);
}
.upload-zone i { font-size: 36px; color: var(--accent-blue); opacity: 0.5; margin-bottom: 12px; }
.upload-zone .upload-text { color: var(--text-secondary); font-size: 0.9rem; }
.upload-zone .upload-hint { color: var(--text-muted); font-size: 0.75rem; margin-top: 6px; }

/* ─── Pagination ────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
    justify-content: center;
}
.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.pagination a:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.pagination .active { background: var(--accent-blue); color: #000; border-color: var(--accent-blue); }

/* ─── Flash Messages ────────────────────────────────────────────────────── */
.flash-messages { margin-bottom: 16px; }
.flash {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 8px;
}
.flash-error { background: rgba(248, 113, 113, 0.1); color: var(--accent-red); border: 1px solid rgba(248, 113, 113, 0.2); }
.flash-success { background: rgba(52, 211, 153, 0.1); color: var(--accent-green); border: 1px solid rgba(52, 211, 153, 0.2); }
.flash-info { background: rgba(56, 189, 248, 0.1); color: var(--accent-blue); border: 1px solid rgba(56, 189, 248, 0.2); }

/* ─── Toast ─────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; }
.toast {
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-top: 8px;
    opacity: 0;
    transform: translateX(40px);
    transition: all 0.3s ease;
    max-width: 360px;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-info { background: rgba(56, 189, 248, 0.15); color: var(--accent-blue); border: 1px solid rgba(56, 189, 248, 0.2); }
.toast-success { background: rgba(52, 211, 153, 0.15); color: var(--accent-green); border: 1px solid rgba(52, 211, 153, 0.2); }
.toast-error { background: rgba(248, 113, 113, 0.15); color: var(--accent-red); border: 1px solid rgba(248, 113, 113, 0.2); }

/* ─── Toolbar ───────────────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.toolbar .search-input {
    flex: 1;
    min-width: 200px;
    padding-left: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center;
}
.toolbar select { min-width: 140px; }

/* ─── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ─── Empty State ───────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; opacity: 0.3; margin-bottom: 16px; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }

/* ─── Login ─────────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image: radial-gradient(ellipse at 50% 0%, rgba(56, 189, 248, 0.06) 0%, transparent 60%);
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 400px;
    max-width: 90%;
}
.login-brand {
    text-align: center;
    margin-bottom: 32px;
}
.login-brand .brand-icon {
    width: 56px; height: 56px;
    margin: 0 auto 12px;
    font-size: 28px;
}
.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--text-heading);
}
.login-brand p { color: var(--text-muted); font-size: 0.8rem; margin-top: 4px; }
.login-form .form-group { margin-bottom: 20px; }
.login-form .btn-primary { width: 100%; justify-content: center; padding: 12px; font-size: 0.9rem; }

/* ─── Frequency Table ───────────────────────────────────────────────────── */
.freq-value {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent-cyan);
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(56, 189, 248, 0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(56, 189, 248, 0.25); }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
}

/* ─── Animations ────────────────────────────────────────────────────────── */
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 4px rgba(56, 189, 248, 0.3); }
    50% { box-shadow: 0 0 12px rgba(56, 189, 248, 0.6); }
}
.live-indicator {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse-glow 2s infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ─── Loading Skeleton ──────────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Polar Plot (for pass elevation) ───────────────────────────────────── */
.polar-container {
    width: 200px; height: 200px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    position: relative;
    margin: 0 auto;
}
