/* --- 1. VARIABLES & RESET --- */
:root {
    --bg-dark: #0a0b10;
    --panel-bg: rgba(20, 20, 25, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-cyan: #00d2ff;
    --accent-purple: #9d50bb;
    --accent-green: #00e676;
    --accent-red: #ff5252;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --font-ui: 'Inter', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
    --sidebar-width: 260px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* SAFETY RULE: Prevents images from exploding */
img { max-width: 100%; height: auto; }

body {
    font-family: var(--font-ui);
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; 
}

#astro-canvas {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1;
    background: radial-gradient(circle at bottom right, #1b2735 0%, #090a0f 80%);
}

/* --- 2. HEADER & LOGO --- */
.mobile-header { display: none !important; }
.menu-overlay { display: none !important; }

.brand img, .brand-mobile img {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-cyan);
    display: block;
}

/* --- 3. LAYOUT --- */
.layout-wrapper {
    display: flex; 
    width: 95%; max-width: 1300px; height: 85vh;
    background: var(--panel-bg); backdrop-filter: blur(15px);
    border: 1px solid var(--border-color); border-radius: 20px;
    overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    position: relative;
}

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width); 
    max-width: var(--sidebar-width); 
    flex-shrink: 0; 
    background: rgba(0,0,0,0.2);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex; flex-direction: column;
    z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 2rem; font-weight: 800; font-size: 1.1rem; color: var(--accent-cyan); }

.nav-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 20px; margin-bottom: 5px; font-weight: 800; opacity: 0.6; letter-spacing: 1px; }
.nav-btn { background: transparent; border: none; color: var(--text-muted); padding: 10px 12px; text-align: left; font-family: var(--font-ui); font-weight: 600; cursor: pointer; border-radius: 8px; transition: 0.3s; display: flex; align-items: center; gap: 10px; font-size: 0.9rem; width: 100%; }
.nav-btn:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-btn.active { background: rgba(0, 210, 255, 0.1); color: var(--accent-cyan); border: 1px solid rgba(0, 210, 255, 0.2); }
.back-home { text-decoration: none; color: var(--text-muted); font-size: 0.85rem; padding: 10px; border-top: 1px solid var(--border-color); margin-top: auto; transition: 0.3s; display: flex; align-items: center; gap: 8px; }
.back-home:hover { color: white; }

.tool-display { flex: 1; position: relative; padding: 2rem; overflow-y: auto; overflow-x: hidden; }
.tool-panel { display: none; animation: fadeIn 0.3s ease-out; }
.tool-panel.active { display: block; }
.panel-header { margin-bottom: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 1rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.panel-header h2 { font-size: 1.5rem; margin: 0; }

/* --- 4. WIDGETS --- */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.dash-card { background: rgba(0,0,0,0.3); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 10px; }
.card-header h3 { font-size: 1rem; color: var(--text-muted); font-weight: 600; margin: 0; }
.live-badge { background: rgba(255, 82, 82, 0.2); color: var(--accent-red); font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; font-weight: 800; animation: pulse 2s infinite; }

/* Weather & Planets */
.weather-stat, .planet-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.9rem; }
.status-good { color: var(--accent-green); } .status-bad { color: var(--accent-red); }
.is-up { color: var(--accent-green); } .is-down { color: var(--accent-red); }

/* Moon */
.moon-flex { display: flex; align-items: center; gap: 20px; }
.moon-graphic { width: 80px; height: 80px; background: #ddd; border-radius: 50%; position: relative; overflow: hidden; box-shadow: 0 0 20px rgba(255,255,255,0.1); flex-shrink: 0; }
.moon-shadow { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #111; opacity: 0.85; border-radius: 50%; transform: translateX(50%); }
.big-percent { font-size: 2rem; font-weight: 800; font-family: var(--font-code); color: var(--accent-cyan); }

/* Earth & APOD */
.earth-view-box { position: relative; display: block; width: 100%; height: 75vh; min-height: 400px; background: #000; border-radius: 12px; border: 1px solid var(--border-color); overflow: hidden; }
.earth-controls { display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.3); padding: 10px 15px; border-radius: 8px; border: 1px solid var(--border-color); margin-bottom: 10px; }
.apod-content img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.apod-text { padding: 10px; font-size: 0.9rem; color: #ccc; line-height: 1.5; background: rgba(0,0,0,0.5); width: 100%; }

/* Deep Sky */
.filter-controls { margin-bottom: 20px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-btn { background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); color: var(--text-muted); padding: 5px 15px; border-radius: 20px; cursor: pointer; transition: 0.3s; }
.filter-btn:hover, .filter-btn.active { background: var(--accent-cyan); color: #000; font-weight: 700; }
.dso-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; }
.dso-card { background: rgba(0,0,0,0.4); border: 1px solid var(--border-color); border-radius: 10px; padding: 15px; display: flex; justify-content: space-between; align-items: center; }
.dso-info h4 { color: var(--accent-cyan); margin: 0 0 5px 0; }
.dso-alt { font-family: var(--font-code); font-size: 1.2rem; font-weight: 700; color: var(--accent-green); }
.type-badge { font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,0.1); margin-top: 5px; display: inline-block; }

/* --- 5. ISS TRACKER (The Part that was Broken!) --- */
.iss-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 20px;
    height: 300px;
}

.iss-display { display: flex; flex-direction: column; gap: 20px; }
.iss-map-placeholder { background: rgba(0,0,0,0.5); height: 200px; border-radius: 12px; display: flex; flex-direction: column; justify-content: center; align-items: center; border: 1px solid var(--border-color); color: var(--accent-cyan); }
.iss-map-placeholder i { font-size: 4rem; margin-bottom: 15px; opacity: 0.5; }
.iss-coords { font-family: var(--font-code); color: white; text-align: center; }
.iss-stats { display: flex; gap: 20px; justify-content: space-around; flex-wrap: wrap; }
.stat-box { background: rgba(255,255,255,0.03); padding: 15px; border-radius: 8px; flex: 1; text-align: center; min-width: 140px; }
.stat-box .value { font-family: var(--font-code); font-size: 1.5rem; font-weight: 700; color: white; }

/* ISS Pass List Styles */
.pass-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.pass-card h3 {
    padding: 15px 20px;
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 10px;
}
.pass-list-header {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 700;
}
.pass-list-content { flex: 1; overflow-y: auto; padding: 0; }
.pass-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-family: var(--font-code);
    font-size: 0.9rem;
    align-items: center;
    transition: background 0.2s;
}
.pass-row:last-child { border-bottom: none; }
.pass-row:hover { background: rgba(255, 255, 255, 0.05); }
.pass-time { color: #fff; opacity: 0.9; }
.pass-peak { color: var(--accent-cyan); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.pass-end { color: var(--text-muted); opacity: 0.7; }
.elev-tag {
    font-size: 0.75em;
    background: rgba(0, 210, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 210, 255, 0.2);
}
/* Scrollbar */
.pass-list-content::-webkit-scrollbar { width: 6px; }
.pass-list-content::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
.pass-list-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* Gallery & Calc */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.gallery-item { aspect-ratio: 1; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-color); cursor: zoom-in; position: relative; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.action-btn { background: var(--accent-cyan); color: #000; border: none; padding: 8px 16px; border-radius: 6px; font-weight: 700; cursor: pointer; }

.lightbox { display: none; position: fixed; z-index: 10000; padding-top: 50px; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.95); backdrop-filter: blur(10px); }
.lightbox-content { margin: auto; display: block; max-width: 95%; max-height: 80vh; border-radius: 8px; border: 1px solid var(--accent-cyan); box-shadow: 0 0 30px rgba(0,210,255,0.2); }
.lightbox-close { position: absolute; top: 10px; right: 20px; color: #fff; font-size: 40px; font-weight: bold; cursor: pointer; }

.calc-grid { margin-bottom: 2rem; display: flex; flex-direction: column; gap: 1rem; }
.results-box { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.result-item { background: rgba(0,0,0,0.3); padding: 15px; border-radius: 8px; text-align: center; border: 1px solid var(--border-color); }
.result-item .value { font-family: var(--font-code); font-size: 1.5rem; font-weight: 700; display: block; }
input[type=range] { width: 100%; -webkit-appearance: none; height: 4px; background: rgba(255,255,255,0.1); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; background: var(--accent-cyan); border-radius: 50%; cursor: pointer; }

/* --- 6. MOBILE BREAKPOINT (Activates < 900px) --- */
@media (max-width: 900px) {
    /* Show Mobile Header */
    .mobile-header { 
        display: flex !important;
        position: fixed; top: 0; left: 0; width: 100%; height: 60px;
        background: rgba(20, 20, 25, 0.95); border-bottom: 1px solid var(--border-color);
        z-index: 2000; justify-content: space-between; align-items: center; padding: 0 20px;
        backdrop-filter: blur(10px);
    }
    
    .brand-mobile { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--accent-cyan); }
    #mobile-menu-btn { background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; }

    /* Layout Reset */
    .layout-wrapper {
        width: 100%; height: 100vh;
        border-radius: 0; border: none;
        background: transparent; box-shadow: none;
        padding-top: 60px;
        display: block; 
    }

    /* Sidebar Slide-in Logic */
    .sidebar {
        position: fixed; top: 60px; left: -100%;
        width: 250px; height: calc(100vh - 60px);
        background: rgba(10, 11, 16, 0.98);
        border-right: 1px solid var(--border-color);
        z-index: 2000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        backdrop-filter: blur(20px);
        min-width: unset; max-width: unset;
    }
    .sidebar.active { left: 0; }
    .sidebar .brand { display: none; } 

    /* Overlay */
    .menu-overlay { 
        display: none;
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.5); z-index: 1500; backdrop-filter: blur(2px);
    }
    .menu-overlay.active { display: block !important; }

    /* Content Area */
    .tool-display { width: 100%; height: 100%; padding: 15px; padding-bottom: 80px; }

    /* Stack Widgets */
    .dashboard-grid { grid-template-columns: 1fr; } 
    .earth-view-box { height: 60vh; min-height: 300px; }
    
    /* Mobile ISS (Stack them) */
    .iss-layout { grid-template-columns: 1fr; height: auto; }
    .pass-card { min-height: 250px; }
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }