/* Reset e variabili */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

:root {
    --primary-color: #e10600;
    --bg-dark: #15151e;
    --bg-light: #1f1f2e;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border-color: #38383f;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: hidden; /* Blocca lo scroll verticale della pagina */
}

/* Header */
.header {
    background-color: var(--bg-light);
    padding: 1rem 2rem;
    border-bottom: 2px solid var(--primary-color);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Main container */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Column wrapper */
.column {
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem;
}

.column:first-child {
    width: 300px;
    background-color: var(--bg-light);
    border-right: 1px solid var(--border-color);
}

.column:nth-child(2) {
    flex-grow: 1;
}

.column:last-child {
    flex-grow: 4;
}

/* Sidebar */
.sidebar {
    width: 100%;
    background-color: var(--bg-light);
}

.control-section {
    margin-bottom: 2rem;
}

.control-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 500;
}

/* Charts container - Supporta grafici più larghi */
.charts-container {
    flex: 1;
    padding: 1.5rem;
    overflow-x: auto; /* Scroll orizzontale per grafici larghi */
}

.chart-wrapper {
    background-color: var(--bg-light);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    min-width: 1200px;
    border: 1px solid var(--border-color);
}

.chart-wrapper h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.chart {
    width: 100%;
    min-height: 480px;
    background-color: var(--bg-dark);
    border-radius: 4px;
    overflow: visible;
}

/* SVG styling per grafici */
.chart svg {
    display: block;
    margin: 0 auto;
    background-color: var(--bg-dark);
}

/* Messaggi di no-data */
.no-data {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Loading overlay */
.back-button {
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    background-color: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.back-button:hover {
    background-color: #555;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(21, 21, 30, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Selezione driver */
.driver-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.driver-item:hover {
    background-color: var(--bg-dark);
}

/* Select personalizzato */
select {
    width: 100%;
    padding: 0.5rem;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Selettori gerarchici */
.control-section select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Driver selectors */
.driver-select-container {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.driver-color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
}

.driver-select {
    flex: 1;
}

/* Info text */
.info-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Fix per option lunghe */
select option {
    padding: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Stili per elementi D3.js */
.chart .axis {
    color: var(--text-secondary);
}

.chart .axis text {
    fill: var(--text-secondary);
    font-size: 12px;
}

.chart .axis .domain,
.chart .axis .tick line {
    stroke: var(--border-color);
}

/* Legenda */
.legend text {
    fill: var(--text-primary);
    font-size: 12px;
}

/* Responsive per schermi piccoli */
@media (max-width: 1400px) {
    .charts-container {
        overflow-x: scroll; /* Forza scroll orizzontale su schermi piccoli */
    }
}

/* Bottone fastest lap */
.fastest-lap-button {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: var(--text-primary);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 0.5rem;
    transition: background-color 0.2s;
}

.fastest-lap-button:hover {
    background-color: #c60500;
}

.tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.5);
    color: #ddd;
    padding: 6px;
    margin-top: -25px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.5;
    pointer-events: none;
    transition: opacity 0.2s;
}

.tyre-info {
    font-size: 12px;
    margin-top: 5px;
    color: #ccc;
}

.load-data-button {
    width: 100%;
    padding: 10px;
    background-color: #e10600;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 10px;
}

.load-data-button:disabled {
    background-color: #555;
    cursor: not-allowed;
}

.fastest-lap-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.track-map {
    position: relative;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
}

.spinner-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.track-map-container {
    width: 100%;
    aspect-ratio: 1;
    max-height: 300px;
    margin-left: 12px;
    margin-top: 23px;
}

.track-map svg {
    display: block;
}

/* Rimuovi il placeholder quando la track è caricata */
.track-map.loaded .track-map-placeholder {
    display: none;
}

/* Animazione per i car markers */
.car-markers circle {
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.5));
}

.car-markers text {
    font-family: 'Formula1-Bold', monospace;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Track info styling */
.track-info {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    font-size: 12px;
}

.track-info span {
    color: #ccc;
}

/* Toggle Sidebar Button */
.toggle-sidebar-button {
    position: absolute;
    left: 284px; /* Adjust to not overlap */
    top: 50%; /* Adjust this value to center the button */
    transform: translateY(-50%);
    z-index: 50;
    width: 15px;
    height: 30px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
    font-size: 10px;
    transition: left 0.3s ease, background-color 0.2s, top 0.3s ease, opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
}

.toggle-sidebar-button:hover {
    opacity: 1;
}

.toggle-sidebar-button:hover {
    background-color: #c60500;
}

/* When sidebar is hidden */
.column.sidebar-hidden {
    width: 0 !important;
    padding: 0;
    overflow: hidden;
    border-right: none;
}

.column.sidebar-hidden .toggle-sidebar-button {
    left: 0;
}

.driver-info-container {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.driver-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #2c2c2c;
    padding: 0.5rem;
    border-radius: 4px;
}

.driver-details {
    display: flex;
    flex-direction: column;
}

.driver-name {
    font-weight: bold;
    color: #eee;
}

/* Footer */
.footer {
    background-color: var(--bg-light);
    padding: 8px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.lap-time {
    font-size: 0.9rem;
    color: #ccc;
}

.tyre-image {
    width: 40px;
    height: 40px;
}

.tyre-image-tooltip {
    width: 20px;
    height: 20px;
    vertical-align: middle;
}

/* Weather container */
.weather-container {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #2c2c2c;
    border-radius: 4px;
}

.weather-container h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 500;
}

.weather-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    font-size: 0.9rem;
}

.weather-info div {
    display: flex;
    flex-direction: column;
}

.weather-info .label {
    font-weight: bold;
    color: #eee;
}

/* Added styles */
.race-chart-tooltip, .violin-plot-tooltip {
    z-index: 1000 !important;
    pointer-events: none !important;
}

.telemetry-tooltip {
    z-index: 500 !important;
    pointer-events: none !important;
}

.tooltip-line {
    pointer-events: none !important;
}

.hidden-by-default {
    display: none !important;
}