/* ─── Night-Mode Design System ──────────────────────────────────────────── */
:root {
    --bg-0:       #06060d;
    --bg-1:       #0d0d1a;
    --bg-2:       #131324;
    --bg-card:    #1a1a2e;
    --bg-card-h:  #1e1e38;
    --accent:     #c94b13;       /* deep red — night-vision safe */
    --accent-h:   #e05522;
    --gold:       #d4a427;
    --gold-dim:   #a07820;
    --text:       #d8d0c8;
    --text-dim:   #7a7890;
    --text-bright:#f0ece4;
    --border:     rgba(201, 75, 19, 0.25);
    --border-dim: rgba(255,255,255,0.07);
    --vis-yes:    #4caf50;
    --vis-no:     #555;
    --radius:     8px;
    --radius-lg:  14px;
    --shadow:     0 4px 24px rgba(0,0,0,0.6);
    --transition: 0.18s ease;
}

/* ─── Reset / Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-0);
    color: var(--text);
    min-height: 100vh;
    display: flex;
}

a { color: var(--accent-h); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold); }

/* ─── Layout ────────────────────────────────────────────────────────────── */
#sidebar {
    width: 220px;
    min-height: 100vh;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
}

#main-content {
    margin-left: 220px;
    flex: 1;
    min-height: 100vh;
    background: var(--bg-0);
    padding: 28px 32px;
    max-width: calc(100vw - 220px);
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar-brand {
    padding: 22px 20px 16px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}
.sidebar-brand .logo-icon {
    font-size: 2.2rem;
    display: block;
    margin-bottom: 4px;
}
.sidebar-brand h1 {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gold);
}
.sidebar-brand p {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 2px;
}

nav.sidebar-nav { flex: 1; padding: 12px 0; }

nav.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--text-dim);
    font-size: 0.88rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all var(--transition);
}
nav.sidebar-nav a .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
nav.sidebar-nav a:hover,
nav.sidebar-nav a.active {
    color: var(--text-bright);
    background: rgba(201, 75, 19, 0.12);
    border-left-color: var(--accent);
}

.sidebar-location {
    padding: 14px 16px;
    border-top: 1px solid var(--border-dim);
    font-size: 0.72rem;
    color: var(--text-dim);
    line-height: 1.5;
}
.sidebar-location .loc-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    font-size: 0.65rem;
    display: block;
    margin-bottom: 3px;
}
.sidebar-location .loc-value {
    color: var(--gold-dim);
    word-break: break-all;
}
.sidebar-location a.change-loc {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--accent-h);
}

/* ─── Page header ───────────────────────────────────────────────────────── */
.page-header {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-dim);
    padding-bottom: 14px;
}
.page-header h2 {
    font-size: 1.45rem;
    font-weight: 600;
    color: var(--text-bright);
}
.page-header .subtitle {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-top: 3px;
}

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow);
}
.card-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 12px;
}
.card-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1;
}
.card-sub {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 5px;
}

/* ─── Grid helpers ──────────────────────────────────────────────────────── */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* ─── Status badges ─────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-visible  { background: rgba(76,175,80,0.15); color: #4caf50; border: 1px solid #4caf5040; }
.badge-below    { background: rgba(120,120,140,0.15); color: #888; border: 1px solid #88888840; }
.badge-day      { background: rgba(255,200,60,0.15);  color: #ffc83c; border: 1px solid #ffc83c40; }
.badge-planet   { background: rgba(212,164,39,0.12); color: var(--gold); border: 1px solid var(--gold-dim)44; }
.badge-galaxy   { background: rgba(100,140,255,0.12); color: #7aa0ff; border: 1px solid #7aa0ff44; }
.badge-nebula   { background: rgba(200,100,255,0.12); color: #c87aff; border: 1px solid #c87aff44; }
.badge-cluster  { background: rgba(60,200,180,0.12); color: #3cc8b4; border: 1px solid #3cc8b444; }
.badge-star     { background: rgba(255,255,200,0.10); color: #fffac8; border: 1px solid #fffac844; }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
table.data-table thead th {
    background: var(--bg-2);
    color: var(--text-dim);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-dim);
}
table.data-table tbody tr {
    border-bottom: 1px solid var(--border-dim);
    transition: background var(--transition);
}
table.data-table tbody tr:last-child { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--bg-card-h); }
table.data-table td {
    padding: 10px 14px;
    color: var(--text);
    vertical-align: middle;
}
.obj-name { font-weight: 600; color: var(--text-bright); }
.coords-cell { font-family: monospace; font-size: 0.82rem; color: var(--text-dim); }

/* ─── Forms ─────────────────────────────────────────────────────────────── */
.form-section { max-width: 540px; }
.field { margin-bottom: 18px; }
.field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius);
    color: var(--text-bright);
    padding: 9px 13px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--accent);
}
.field .hint {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 4px;
}
.field .errors { color: #f66; font-size: 0.78rem; margin-top: 4px; }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: var(--radius);
    border: none;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-h); color: #fff; }
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-dim);
    color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-h); }
.btn-gold {
    background: var(--gold-dim);
    color: #000;
}
.btn-gold:hover { background: var(--gold); }

/* ─── Search bar ─────────────────────────────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.search-bar input, .search-bar select {
    background: var(--bg-2);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius);
    color: var(--text-bright);
    padding: 8px 13px;
    font-size: 0.9rem;
    outline: none;
}
.search-bar input:focus, .search-bar select:focus {
    border-color: var(--accent);
}
.search-bar input { flex: 1; min-width: 180px; }

/* ─── Sky stat row ────────────────────────────────────────────────────────── */
.sky-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.sky-stat {
    background: var(--bg-card);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius);
    padding: 12px 18px;
    min-width: 130px;
    flex: 1;
}
.sky-stat .stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.sky-stat .stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-bright);
}
.sky-stat .stat-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 2px;
}

/* ─── Moon phase visual ──────────────────────────────────────────────────── */
.moon-visual {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    background: #333;
    box-shadow: 0 0 40px rgba(212,164,39,0.2);
    margin: 0 auto 16px;
}
.moon-visual .moon-light {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 35% 35%, #f0e090, #c8a840 55%, #806020);
}
.moon-visual .moon-shadow {
    position: absolute;
    inset: 0;
    background: var(--bg-0);
    border-radius: 50%;
    transition: transform 0.3s ease;
}

/* ─── No-location banner ─────────────────────────────────────────────────── */
.no-location {
    background: rgba(201,75,19,0.1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}
.no-location .nl-icon { font-size: 1.8rem; }
.no-location p { font-size: 0.88rem; color: var(--text); }
.no-location a { color: var(--accent-h); font-weight: 600; }

/* ─── Divider ────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border-dim); margin: 22px 0; }

/* ─── Night-mode dim overlay (extra red tint for dark-sky use) ──────────── */
body.night-mode-dim {
    filter: brightness(0.6) sepia(0.4) hue-rotate(-10deg);
}
body.night-mode-dim #night-mode-btn {
    border-color: var(--accent);
    color: var(--accent-h);
}

/* ─── Altitude indicator bar ─────────────────────────────────────────────── */
.alt-bar-wrap { display: flex; align-items: center; gap: 8px; }
.alt-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-2);
    border-radius: 99px;
    overflow: hidden;
}
.alt-bar-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent), var(--gold));
    transition: width 0.4s ease;
}
.alt-bar-fill.below { background: var(--vis-no); }
.alt-val { font-size: 0.78rem; color: var(--text-dim); width: 42px; text-align: right; }

/* ─── Mobile hamburger button ────────────────────────────────────────────── */
#menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    background: var(--bg-1);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.25rem;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}
#menu-toggle:hover { border-color: var(--accent); color: var(--accent-h); }

/* ─── Sidebar overlay backdrop ───────────────────────────────────────────── */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    backdrop-filter: blur(2px);
}
#sidebar-overlay.open { display: block; }

/* ─── Responsive — tablet (≤ 800 px) ────────────────────────────────────── */
@media (max-width: 800px) {
    #menu-toggle { display: flex; }

    #sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 240px;
        z-index: 150;
    }
    #sidebar.open { transform: translateX(0); }

    /* Full labels visible inside the drawer */
    #sidebar .sidebar-brand p,
    #sidebar .sidebar-brand h1,
    nav.sidebar-nav a span,
    .sidebar-location { display: revert; }

    nav.sidebar-nav a { justify-content: flex-start; padding: 12px 20px; }

    #main-content {
        margin-left: 0;
        max-width: 100vw;
        padding: 64px 16px 24px;
    }

    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }

    .form-section { max-width: 100%; }
}

/* ─── Responsive — phone (≤ 480 px) ─────────────────────────────────────── */
@media (max-width: 480px) {
    .grid-4 { grid-template-columns: 1fr; }

    .card { padding: 16px; }
    .card-value { font-size: 1.4rem; }

    .sky-stat { min-width: 120px; }

    .btn { padding: 10px 16px; font-size: 0.84rem; }

    table.data-table { font-size: 0.8rem; }
    table.data-table td,
    table.data-table thead th { padding: 8px 10px; }

    .page-header h2 { font-size: 1.2rem; }
    .no-location { flex-direction: column; align-items: flex-start; gap: 8px; }

    .moon-visual { width: 110px; height: 110px; }

    .search-bar { flex-direction: column; align-items: stretch; }
    .search-bar input { min-width: unset; }
}
