@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    --bg-space: #030712;
    --card-bg: rgba(17, 24, 39, 0.55);
    --card-border: rgba(255, 255, 255, 0.07);
    --card-border-hover: rgba(147, 51, 234, 0.3);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    /* Colori Pianeti */
    --color-mercury: #9ca3af;
    --color-venus: #fef08a;
    --color-earth: #60a5fa;
    --color-mars: #f87171;
    --color-jupiter: #fdba74;
    --color-saturn: #fde047;
    --color-uranus: #67e8f9;
    --color-neptune: #3b82f6;
    
    /* Neon Accents */
    --accent-glow: rgba(147, 51, 234, 0.15);
    --neon-green: #10b981;
    --neon-red: #ef4444;
    
    --font-sans: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-space);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: auto;
    position: relative;
    background-image: 
        radial-gradient(at 10% 20%, rgba(88, 28, 135, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(30, 58, 138, 0.15) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(15, 23, 42, 0.5) 0px, transparent 100%);
    background-attachment: fixed;
}

/* Sfondo Stellato Dinamico */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.45;
    background-image: 
        radial-gradient(1px 1px at 20px 30px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 40px 70px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 50px 160px, #fff, rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 90px 40px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 130px 80px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 160px 120px, #fff, rgba(0,0,0,0));
    background-size: 200px 200px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 2rem;
}

.logo-area h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-area p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Status Bar & GPS Controls */
.location-status {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.status-item {
    display: flex;
    flex-direction: column;
}

.status-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-value {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Griglia Principale */
.main-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    .main-layout {
        grid-template-columns: 320px 1fr;
    }
}

/* Sidebar Controlli */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

.panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.panel:hover {
    border-color: var(--card-border-hover);
    box-shadow: 0 8px 32px var(--accent-glow);
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.5rem;
}

/* Form inputs & Bottoni */
.input-group {
    margin-bottom: 1rem;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

input, select {
    width: 100%;
    background: rgba(31, 41, 55, 0.5);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.625rem;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

input[type="number"], .mono-input {
    font-family: var(--font-mono);
}

input:focus, select:focus {
    outline: none;
    border-color: #a855f7;
    background: rgba(31, 41, 55, 0.8);
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

button {
    width: 100%;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

button:hover {
    opacity: 0.95;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
    transform: translateY(-1px);
}

button.secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
}

button.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

/* Switcher Real-Time */
.realtime-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.1);
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--neon-green);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Dashboard Area */
.content-area {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    min-width: 0;
}

/* Griglia delle schede dei pianeti */
.planets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
}

.planet-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.planet-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--planet-color, var(--text-muted));
}

.planet-card:hover {
    transform: translateY(-4px);
    border-color: var(--planet-color, var(--card-border-hover));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.planet-card.active-selection {
    background: rgba(147, 51, 234, 0.08);
    border-color: #a855f7;
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.2);
}

.planet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.planet-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.planet-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: var(--planet-color);
    box-shadow: 0 0 8px var(--planet-color);
}

.planet-name {
    font-size: 1.15rem;
    font-weight: 600;
}

.visibility-badge {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    letter-spacing: 0.5px;
}

.visibility-badge.visible {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--neon-green);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.visibility-badge.invisible {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--neon-red);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.planet-coords {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.6rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.coord-box {
    display: flex;
    flex-direction: column;
}

.coord-label {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.coord-val {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 500;
}

.planet-times {
    font-size: 0.72rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 0.5rem;
}

/* Bussola Radar (Mappa del Cielo) */
.sky-compass-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 1rem 0;
}

.compass-svg-wrapper {
    width: 320px;
    height: 320px;
    max-width: 100%;
    position: relative;
}

@media (min-width: 640px) {
    .compass-svg-wrapper {
        width: 360px;
        height: 360px;
    }
}

.compass-svg {
    width: 100%;
    height: 100%;
}

.compass-grid-circle {
    fill: none;
    stroke: rgba(255, 255, 255, 0.07);
    stroke-width: 1;
}

.compass-grid-line {
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 1;
}

.compass-axis {
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 1;
    stroke-dasharray: 2 4;
}

.compass-label {
    fill: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-anchor: middle;
}

.compass-planet-node {
    cursor: pointer;
    transition: r 0.2s ease, filter 0.2s ease;
}

.compass-planet-node:hover {
    r: 8px;
    filter: drop-shadow(0 0 6px var(--planet-color));
}

/* Dettaglio Lune Panel */
.moons-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.moons-section:not(.active) {
    display: none !important;
}

@media (min-width: 1024px) {
    .moons-section {
        grid-template-columns: 1fr 340px;
    }
}

.canvas-container {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
    aspect-ratio: 16/9;
    min-height: 280px;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.canvas-controls {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    pointer-events: auto;
}

.canvas-controls button {
    width: auto;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.canvas-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.lunes-legend {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.moon-legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.15);
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.moon-legend-name {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.moon-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: 0 0 4px #fff;
}

.moon-legend-offset {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Utilities e animazioni */
.pulse-indicator {
    width: 8px;
    height: 8px;
    background-color: var(--neon-green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--neon-green);
    animation: pulse 2s infinite;
}

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

.error-message {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.25);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    display: none;
}

/* Informazioni di footer */
footer {
    margin-top: 4rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--card-border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Stili per la sezione ISS */
.iss-table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
}

.iss-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    text-align: left;
}

.iss-table th {
    background: rgba(255, 255, 255, 0.03);
    padding: 0.6rem 0.8rem;
    font-weight: 600;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.iss-table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    vertical-align: middle;
    white-space: nowrap;
}

.iss-table tr:last-child td {
    border-bottom: none;
}

.iss-table tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

.iss-time-cell {
    font-family: var(--font-mono);
    font-weight: 500;
}

.iss-duration-cell {
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.iss-elev-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-family: var(--font-mono);
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    font-size: 0.75rem;
}

.iss-elev-high {
    background: rgba(16, 185, 129, 0.15);
    color: var(--neon-green);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.iss-elev-mid {
    background: rgba(253, 186, 116, 0.15);
    color: var(--color-jupiter);
    border: 1px solid rgba(253, 186, 116, 0.25);
}

.iss-elev-low {
    background: rgba(156, 163, 175, 0.15);
    color: var(--text-secondary);
    border: 1px solid rgba(156, 163, 175, 0.25);
}

.iss-vis-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    display: inline-block;
    text-align: center;
}

.iss-vis-yes {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.25);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.15);
}

.iss-vis-no {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.iss-no-passes {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.1);
}

.iss-arrow {
    display: inline-block;
    font-weight: bold;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.iss-tle-info {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.6rem;
    text-align: right;
    font-family: var(--font-mono);
}

/* Ottimizzazioni per schermi mobile verticali */
@media (max-width: 767px) {
    html, body {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
    }
    
    .container {
        padding: 0.5rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .panel {
        padding: 0.85rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    header {
        padding-bottom: 0.75rem;
        margin-bottom: 1rem;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }
    
    .location-status {
        width: 100%;
        gap: 0.75rem;
        justify-content: space-between;
        padding: 0.5rem 0.75rem;
        box-sizing: border-box;
    }
    
    .status-value {
        font-size: 0.78rem;
    }
    
    .planets-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        width: 100%;
    }
    
    .planet-card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .iss-table-wrapper {
        margin: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .iss-table th, .iss-table td {
        padding: 0.45rem 0.5rem;
        font-size: 0.72rem;
    }
    
    /* Impedisce al pannello delle lune e ai suoi figli flex di allargarsi oltre lo schermo */
    .moons-section {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        gap: 1.25rem !important;
    }
    
    .moons-section > div {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* Impedisce al canvas delle lune di esplodere in larghezza su mobile */
    .canvas-container {
        min-height: auto !important;
        aspect-ratio: 16/9;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box !important;
    }
    
    /* Riduce dimensione caratteri e pulsanti su mobile */
    button {
        padding: 0.6rem;
        font-size: 0.82rem;
    }
    
    .sky-compass-container {
        padding: 0.35rem 0;
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .compass-svg-wrapper {
        width: 270px;
        height: 270px;
        max-width: 100%;
    }
    
    /* Responsività del planisfero su mobile */
    #planisphereSection .compass-svg-wrapper {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 !important;
        max-width: 520px !important;
    }
}

/* Stile specifico per ingrandire il Planisfero Celeste su desktop */
#planisphereSection .compass-svg-wrapper {
    width: 640px;
    height: 640px;
    max-width: 100%;
    margin: 0 auto;
}

/* Stili per la sezione Comete Responsive Card-based */
.comets-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.comet-card {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: all 0.2s ease-in-out;
}

.comet-card:hover {
    border-color: rgba(192, 132, 252, 0.25);
    background: rgba(192, 132, 252, 0.015);
    box-shadow: 0 4px 12px rgba(192, 132, 252, 0.05);
}

.comet-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.comet-card-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    transition: color 0.2s;
}

.comet-card-constellation {
    font-size: 0.72rem;
    color: #c084fc;
    font-weight: 500;
    margin-top: 2px;
}

.comet-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    padding-top: 0.6rem;
    margin-top: 0.15rem;
}

.comet-coord-box {
    padding: 0.4rem 0.6rem;
    background: rgba(255, 255, 255, 0.015);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

@media (max-width: 767px) {
    .comet-card {
        padding: 0.6rem 0.8rem;
        gap: 0.4rem;
    }
    .comet-card-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
        padding-top: 0.4rem;
        margin-top: 0.1rem;
    }
    .comet-card-stats > div:nth-child(3) {
        grid-column: span 2; /* Posizione Attuale (Alt / Az) si allunga su 2 colonne */
    }
    .comet-coord-box {
        padding: 0.3rem 0.5rem;
    }
}
