/* CSS Variables for design consistency */
:root {
    --bg-dark: #070913;
    --bg-space: radial-gradient(circle at 50% 50%, #0c1122 0%, #04050b 100%);
    --card-bg: rgba(13, 20, 38, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-border-hover: rgba(0, 229, 255, 0.2);
    --text-primary: #f0f2fa;
    --text-secondary: #9aa0b9;
    --text-muted: #646a8a;
    
    /* Vectors Colors */
    --color-sun: #ffd000;
    --color-mutual: #00ffd2;
    --color-net: #ff477e;
    --color-velocity: #39ff14;
    --color-satellite: #10b981;
    
    /* UI Accent Colors */
    --accent-blue: #0088ff;
    --accent-glow: rgba(0, 136, 255, 0.35);
    
    --font-family: 'Outfit', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    background-image: var(--bg-space);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Background Stars */
.stars-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(1px 1px at 10% 20%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 30% 40%, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 50% 60%, rgba(255,255,255,0.8), transparent),
        radial-gradient(2px 2px at 70% 30%, #fff, transparent),
        radial-gradient(1px 1px at 90% 80%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1.5px 1.5px at 80% 10%, rgba(255,255,255,0.9), transparent);
    background-size: 550px 550px;
    opacity: 0.45;
    z-index: 0;
    pointer-events: none;
}

/* Main Container */
.app-container {
    width: 100%;
    max-width: 1600px;
    height: 95vh;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    background: rgba(13, 20, 38, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid var(--card-border);
    padding: 0.8rem 1.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

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

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 210, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(0, 255, 210, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 210, 0); }
}

.header-logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* View Selector buttons */
.view-selector {
    display: flex;
    gap: 0.75rem;
    background: rgba(4, 6, 12, 0.6);
    padding: 0.3rem;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.view-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.view-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.view-btn.active {
    color: var(--text-primary);
    background: var(--accent-blue);
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* Main Layout */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 1.5rem;
    min-height: 0; /* Important for grid item overflow */
}

/* Canvas Panel (Left Side) */
.canvas-panel {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    min-height: 0;
}

.canvas-panel.maximized {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: #050711; /* Deep space solid dark background */
    padding: 0; /* Full edge-to-edge screensaver view */
    box-sizing: border-box;
    gap: 0;
}

.canvas-panel.maximized .timeline-container {
    display: none !important; /* Hide timeline entirely in fullscreen */
}

.canvas-panel.maximized .canvas-wrapper {
    border-radius: 0;
    border: none;
}

.canvas-wrapper {
    flex: 1;
    background: rgba(5, 7, 18, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
}

#simulator-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: default;
}

/* Tip on Canvas */
.interactive-tip {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(13, 20, 38, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid var(--card-border);
    padding: 0.5rem 0.8rem;
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: fadeIn 1.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Vector Legend / Toggles Overlay */
.vector-legend {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    background: rgba(10, 15, 30, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid var(--card-border);
    padding: 0.8rem 1rem;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.legend-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.legend-item:hover {
    color: var(--text-primary);
}

.legend-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid var(--text-muted);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.legend-item input[type="checkbox"]:checked {
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
}

.legend-item input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 3px;
    height: 6px;
    border: solid white;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.color-indicator {
    width: 16px;
    height: 4px;
    border-radius: 2px;
}
.sun-grav { background-color: var(--color-sun); box-shadow: 0 0 5px var(--color-sun); }
.mutual-grav { background-color: var(--color-mutual); box-shadow: 0 0 5px var(--color-mutual); }
.net-grav { background-color: var(--color-net); box-shadow: 0 0 5px var(--color-net); }
.velocity-vec { background-color: var(--color-velocity); box-shadow: 0 0 5px var(--color-velocity); }
.satellite-vec { background-color: var(--color-satellite); box-shadow: 0 0 5px var(--color-satellite); }

.text-sun-gravity { color: #facc15 !important; }
.text-mutual-gravity { color: #00ffd2 !important; }
.text-net-gravity { color: #ff5083 !important; }
.text-velocity { color: #52ff28 !important; }

/* Timeline and Slider (Bottom of left side) */
.timeline-container {
    background: rgba(13, 20, 38, 0.55);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    padding: 1.2rem;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.timeline-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap; /* Wrap nicely on narrow screens */
}

.date-start-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: auto; /* Push it to the right side if space permits */
}

.date-start-control input {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.date-start-control input:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(15, 23, 42, 0.85);
}

.highlight-time {
    color: #38bdf8;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
}

.ctrl-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.25s ease;
}

.ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.ctrl-btn:active {
    transform: scale(0.95);
}

.hidden {
    display: none !important;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: auto;
}

.speed-control select {
    background: rgba(10, 15, 30, 0.7);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    font-weight: 500;
}

.speed-control select:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.slider-wrapper {
    position: relative;
    padding-top: 1.2rem;
    width: 100%;
}

.timeline-ticks {
    position: absolute;
    top: -4px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.timeline-ticks span {
    position: absolute;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Custom styled range input */
#time-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    cursor: pointer;
    transition: background 0.3s;
}

#time-slider:hover {
    background: rgba(255, 255, 255, 0.15);
}

#time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 2px 4px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--accent-blue);
    cursor: pointer;
    transition: all 0.1s ease;
}

#time-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--text-primary);
    box-shadow: 0 0 14px rgba(0, 136, 255, 0.8), 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Dashboard Panel (Right Side) */
.dashboard-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    padding-right: 0.3rem;
}

/* Custom scrollbar for dashboard */
.dashboard-panel::-webkit-scrollbar {
    width: 6px;
}
.dashboard-panel::-webkit-scrollbar-track {
    background: transparent;
}
.dashboard-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}
.dashboard-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Card Design */
.dash-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: border-color 0.3s, transform 0.3s;
}

.dash-card:hover {
    border-color: var(--card-border-hover);
}

.dash-card h2 {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 0.5rem;
}

.card-icon {
    font-size: 1.1rem;
}

/* Card Border highlights for Earth/Moon specificity */
.border-earth {
    border-left: 3px solid #3b82f6;
}
.border-moon {
    border-left: 3px solid #94a3b8;
}
.border-satellite {
    border-left: 3px solid #10b981;
}

.text-earth { color: #3b82f6; }
.text-moon { color: #e2e8f0; }
.text-satellite { color: #10b981 !important; }

.card-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* State rows */
.state-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.state-label {
    color: var(--text-secondary);
}

.state-value {
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
}

.state-value.highlight {
    color: var(--color-mutual);
    background: rgba(0, 255, 210, 0.06);
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    border: 1px solid rgba(0, 255, 210, 0.15);
}

/* Phase Preview inside card */
.phase-preview-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.8rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.phase-moon-sphere {
    width: 44px;
    height: 44px;
    background: radial-gradient(circle, #e2e8f0 0%, #cbd5e1 70%, #64748b 100%);
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(226, 232, 240, 0.3), inset 0 0 4px rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}

.phase-shadow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #04060c;
    border-radius: 50%;
    transition: transform 0.1s ease, width 0.1s ease, background 0.1s ease;
}

#txt-phase-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Force Items & Progress Bars */
.force-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.net-force-item {
    margin-top: 0.4rem;
    padding-top: 0.6rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.force-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.force-label {
    color: var(--text-secondary);
}

.force-val {
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
}

.force-bar-bg {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
    width: 100%;
}

.force-bar {
    height: 100%;
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s cubic-bezier(0.1, 0.8, 0.2, 1);
}

.bg-sun-gravity {
    background: linear-gradient(90deg, #ca8a04 0%, var(--color-sun) 100%);
    box-shadow: 0 0 8px rgba(255, 208, 0, 0.4);
}
.bg-mutual-gravity {
    background: linear-gradient(90deg, #0d9488 0%, var(--color-mutual) 100%);
    box-shadow: 0 0 8px rgba(0, 255, 210, 0.4);
}
.bg-net-gravity {
    background: linear-gradient(90deg, #be123c 0%, var(--color-net) 100%);
    box-shadow: 0 0 8px rgba(255, 71, 126, 0.4);
}
.bg-moon-gravity {
    background: linear-gradient(90deg, #475569 0%, #94a3b8 100%);
    box-shadow: 0 0 8px rgba(148, 163, 184, 0.4);
}

/* Q&A Panel styling */
.physics-qa {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.physics-qa::-webkit-scrollbar {
    width: 4px;
}
.physics-qa::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
}

.qa-item {
    font-size: 0.78rem;
    line-height: 1.5;
}

.qa-q {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
    position: relative;
    padding-left: 0.8rem;
}

.qa-q::before {
    content: "•";
    color: var(--color-mutual);
    position: absolute;
    left: 0;
    font-weight: bold;
}

.qa-a {
    color: var(--text-secondary);
    padding-left: 0.8rem;
}

.qa-a ul {
    margin-top: 0.25rem;
    padding-left: 1rem;
}

.qa-a li {
    margin-bottom: 0.2rem;
}

/* Floating Zoom Controls */
.zoom-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
}

.zoom-btn {
    width: 36px;
    height: 36px;
    background: rgba(13, 20, 38, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.zoom-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.zoom-btn:active {
    transform: scale(0.95);
}

/* Responsive adjustment */
@media (max-width: 1100px) {
    .app-container {
        height: auto;
    }
    .main-content {
        grid-template-columns: 1fr;
        height: auto;
    }
    .canvas-wrapper {
        height: 500px;
    }
    .dashboard-panel {
        height: auto;
        overflow-y: visible;
    }
}

/* 8 Planets Table Styles */
.planet-table {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.8rem;
    margin-top: 0.2rem;
}
.planet-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    align-items: center;
    border-radius: 4px;
}
.planet-row:hover {
    background: rgba(255, 255, 255, 0.02);
}
.planet-header {
    font-weight: bold;
    color: #94a3b8;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    background: transparent !important;
}
.p-col-name {
    flex: 1.2;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 6px;
}
.p-col-dist {
    flex: 1.5;
    text-align: right;
    font-family: monospace;
    color: #38bdf8;
}
.p-col-speed {
    flex: 1.3;
    text-align: right;
    font-family: monospace;
    color: #fb7185;
}
.text-sun {
    color: #f59e0b;
}
.border-solar {
    border-left: 4px solid #f59e0b !important;
}
