/* Solaris Design System & Styling */

:root {
    --bg-primary: #070a13;
    --bg-secondary: #0c101f;
    --panel-bg: rgba(15, 22, 42, 0.65);
    --panel-border: rgba(255, 255, 255, 0.08);
    --panel-glow: rgba(245, 158, 11, 0.03);
    
    --text-primary: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #4b5563;
    
    --accent-gold: #f59e0b;
    --accent-gold-hover: #d97706;
    --accent-gold-dark: #b45309;
    --accent-gold-glow: rgba(245, 158, 11, 0.35);
    
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    
    --accent-copper: #d97706;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'Outfit', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
}

/* Background Ambient Orbs */
.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    backdrop-filter: blur(100px);
    z-index: -1;
}

.glow-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -2;
    opacity: 0.25;
    pointer-events: none;
    transition: var(--transition-smooth);
}

#orb-solar {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent-gold) 0%, transparent 70%);
    top: -100px;
    right: -100px;
    animation: pulseSolar 15s infinite alternate ease-in-out;
}

#orb-secondary {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #4f46e5 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
}

@keyframes pulseSolar {
    0% { transform: scale(1) translate(0, 0); opacity: 0.2; }
    100% { transform: scale(1.2) translate(-50px, 50px); opacity: 0.3; }
}

/* App Container */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sun-icon {
    font-size: 2.25rem;
    filter: drop-shadow(0 0 10px var(--accent-gold-glow));
    animation: spinSlow 30s infinite linear;
}

@keyframes spinSlow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.brand h1 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #fff 30%, var(--accent-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Main Layout Grid */
.main-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 1.5rem;
    flex-grow: 1;
    align-items: start;
}

/* Sidebar & Controls */
.sidebar {
    background-color: var(--panel-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-glass);
    height: calc(100vh - 8rem);
    position: sticky;
    top: 6.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.sidebar h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.75rem;
}

.control-scroll-area {
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Custom Scrollbar for Sidebar */
.control-scroll-area::-webkit-scrollbar {
    width: 6px;
}
.control-scroll-area::-webkit-scrollbar-track {
    background: transparent;
}
.control-scroll-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.control-scroll-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 1.5rem;
}

.control-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.control-section h3 {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-gold);
}

/* Mode Selector Switch */
.mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.mode-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.85rem;
    padding: 0.5rem 0.25rem;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.mode-tab:hover {
    color: var(--text-primary);
}

.mode-tab.active {
    background: linear-gradient(135deg, var(--accent-gold) 0%, var(--accent-gold-hover) 100%);
    color: #000;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* Form Controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.val-display {
    color: var(--accent-gold);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9rem;
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: -0.25rem;
    font-style: italic;
}

/* Ranges and Inputs */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-gold);
    box-shadow: 0 0 10px var(--accent-gold-glow);
    transition: var(--transition-smooth);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #fff;
}

.input-number-wrap {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.25rem;
}

input[type="number"], select, input[type="date"] {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    outline: none;
    transition: var(--transition-smooth);
}

input[type="number"]:focus, select:focus, input[type="date"]:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

input[type="number"] {
    width: 80px;
    text-align: right;
    font-family: var(--font-heading);
}

select {
    width: 100%;
    cursor: pointer;
}

input[type="date"] {
    width: 100%;
}

.form-group-row {
    display: flex;
    gap: 0.5rem;
}

.form-group-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.form-group-checkbox input[type="checkbox"] {
    accent-color: var(--accent-gold);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.form-group-checkbox label {
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-full-width {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-gold) 0%, var(--accent-gold-hover) 100%);
    color: #000;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
}

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-gold {
    background: transparent;
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.05);
}

.btn-gold:hover {
    background: rgba(245, 158, 11, 0.1);
    box-shadow: 0 0 15px var(--accent-gold-glow);
}

.btn-mini {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

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

.btn-mini-wide {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 6px;
}

.quick-dates {
    display: flex;
    justify-content: space-between;
    gap: 0.25rem;
    margin-top: 0.35rem;
}

.time-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.time-quick-val {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    color: var(--accent-gold);
    background: rgba(0,0,0,0.2);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.03);
}

/* Pulse Live Indicator */
.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px #10b981;
}

#btn-live.active {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
    color: #10b981;
}

#btn-live.active .pulse-dot {
    animation: pulseGreen 1.5s infinite;
}

@keyframes pulseGreen {
    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); }
}

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Glass Panels */
.glass-panel {
    background-color: var(--panel-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-glass);
    position: relative;
    overflow: hidden;
}

.glass-panel::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 0%, var(--panel-glow) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* View Header */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    position: relative;
    z-index: 1;
}

.view-header h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.export-actions {
    display: flex;
    gap: 0.5rem;
}

/* Sundial Drawing Viewport */
.drawing-viewport {
    background-color: rgba(2, 6, 23, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    height: 480px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    overflow: hidden;
}

#sundial-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

#sundial-canvas:active {
    cursor: grabbing;
}

.viewport-legend {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.glass-card {
    background-color: var(--panel-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.glass-card h4 {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-gold);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.5rem;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.metric-label {
    color: var(--text-muted);
}

.metric-value {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-primary);
}

.metric-value.highlight {
    color: var(--accent-gold);
    font-size: 0.95rem;
}

/* Chart Card specific */
.chart-card {
    grid-column: span 1;
}

.chart-container {
    height: 120px;
    width: 100%;
    margin-top: 0.25rem;
}

#eot-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.chart-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    padding-top: 0.5rem;
}

/* Tracing Data Panel */
.data-panel {
    z-index: 1;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.panel-header h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
}

.panel-instructions {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    max-width: 90%;
    line-height: 1.4;
}

/* Tabbed Table System */
.tabbed-table-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.table-switch {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.5rem;
}

.table-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border-bottom: 2px solid transparent;
}

.table-tab:hover {
    color: var(--text-primary);
}

.table-tab.active {
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
    font-weight: 600;
}

.table-wrapper {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.table-wrapper::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.table-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.data-table th {
    background: rgba(15, 22, 42, 0.9);
    position: sticky;
    top: 0;
    padding: 0.75rem 1rem;
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.data-table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-family: var(--font-heading);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr td:first-child {
    font-family: var(--font-body);
    font-weight: 500;
}

.data-table tbody tr td.highlight {
    color: var(--accent-gold);
    font-weight: 600;
}

/* Flag & Lang Styling */
.lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
    border-radius: 6px;
}
.lang-flag {
    font-size: 0.9rem;
}

/* Helpers */
.hidden {
    display: none !important;
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .chart-card {
        grid-column: span 2;
    }
}

@media (max-width: 992px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        height: auto;
        position: static;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    .header-controls {
        align-self: flex-end;
    }
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    .chart-card {
        grid-column: span 1;
    }
    .drawing-viewport {
        height: 360px;
    }
}

/* Stili di Stampa per report in-page */
@media screen {
    #print-report {
        display: none !important;
    }
}

@media print {
    /* Nasconde completamente l'interfaccia dell'applicazione SPA */
    body > *:not(#print-report) {
        display: none !important;
    }
    /* Mostra esclusivamente il report */
    #print-report {
        display: block !important;
        background: #ffffff !important;
        color: #000000 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}
