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

body {
    font-family: 'Arial', 'Helvetica', sans-serif;
    background: #0a0a0a;
    color: #ffffff;
    overflow: hidden;
    height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header F1 Style */
.header {
    background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #e10600;
    box-shadow: 0 4px 20px rgba(225, 6, 0, 0.3);
    position: relative;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.menu-toggle span {
    width: 100%;
    height: 3px;
    background: #ffd700;
    border-radius: 3px;
    transition: all 0.3s;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
}

.logo h1 {
    font-size: 28px;
    font-weight: bold;
    color: #ffffff;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.logo .subtitle {
    font-size: 12px;
    color: #888;
    letter-spacing: 2px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #888;
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: #00ff00;
    box-shadow: 0 0 10px #00ff00;
}

.status-dot.disconnected {
    background: #e10600;
    box-shadow: 0 0 10px #e10600;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 320px;
    background: #151515;
    border-right: 2px solid #2a2a2a;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar.mobile-hidden {
    transform: translateX(-100%);
}

.panel {
    padding: 20px;
    border-bottom: 1px solid #2a2a2a;
}

.panel h3 {
    color: #e10600;
    font-size: 16px;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.vehicles-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vehicle-item {
    background: #1f1f1f;
    padding: 12px;
    border-radius: 4px;
    border-left: 3px solid #e10600;
    cursor: pointer;
    transition: all 0.3s;
}

.vehicle-item:hover {
    background: #2a2a2a;
    transform: translateX(5px);
}

.vehicle-item.active {
    border-left-color: #ffd700;
    background: #2a2a2a;
}

.vehicle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.vehicle-name {
    font-weight: bold;
    color: #ffffff;
}

.vehicle-speed {
    color: #ffd700;
    font-size: 14px;
}

.vehicle-info {
    font-size: 12px;
    color: #888;
    display: flex;
    gap: 15px;
}

.stats-panel {
    margin-top: auto;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #2a2a2a;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: #888;
    font-size: 13px;
}

.stat-value {
    color: #ffd700;
    font-weight: bold;
    font-size: 14px;
}

/* Upload Section */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.upload-btn {
    background: #1a1a1a;
    color: #ffffff;
    border: 1px solid #2a2a2a;
    padding: 12px 15px;
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
}

.upload-btn:hover {
    background: #e10600;
    border-color: #e10600;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(225, 6, 0, 0.4);
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1f1f1f;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #2a2a2a;
}

.file-info span {
    color: #888;
    font-size: 12px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clear-btn {
    background: #e10600;
    color: #ffffff;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    margin-left: 10px;
}

.clear-btn:hover {
    background: #ff0000;
    transform: scale(1.1);
}

.help-text {
    color: #666;
    font-size: 11px;
    font-style: italic;
    margin-top: 5px;
}

/* Control Section */
.control-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-btn-small {
    background: #1a1a1a;
    color: #ffffff;
    border: 1px solid #2a2a2a;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
}

.control-btn-small:hover {
    background: #ffd700;
    border-color: #ffd700;
    color: #0a0a0a;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(255, 215, 0, 0.4);
}

/* Circuit Container */
.circuit-container {
    flex: 1;
    position: relative;
    background: #0a0a0a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: 0;
}

.circuit-wrapper {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

#circuitSvg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.circuit-info {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(26, 26, 26, 0.9);
    padding: 15px 20px;
    border-radius: 4px;
    border: 1px solid #2a2a2a;
}

.circuit-name {
    color: #ffd700;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.circuit-length {
    color: #888;
    font-size: 12px;
}

.map-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-btn {
    background: rgba(26, 26, 26, 0.9);
    color: #ffffff;
    border: 1px solid #2a2a2a;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 13px;
    border-radius: 4px;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.control-btn:hover {
    background: #e10600;
    border-color: #e10600;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(225, 6, 0, 0.4);
}

/* Scrollbar Styling */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: #0a0a0a;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #2a2a2a;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #e10600;
}

/* Vehicle Trail SVG */
#circuitTrails path {
    transition: opacity 0.3s;
}

/* Vehicle Icons SVG */
#circuitVehicles g {
    transition: transform 0.1s ease-out;
    cursor: pointer;
}

#circuitVehicles g:hover {
    filter: brightness(1.3);
}

/* Timing Table F1 Style */
.timing-table {
    background: #1a1a1a;
    border-collapse: collapse;
    width: 100%;
}

.timing-table thead {
    background: #0f0f0f;
}

.timing-table tbody tr {
    transition: background 0.2s;
}

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

.timing-table tbody tr:last-child {
    border-bottom: none;
}

/* Mobile Responsive */
@media screen and (max-width: 768px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .container {
        height: auto;
        min-height: 100vh;
    }
    
    .header {
        padding: 12px 15px;
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    .logo h1 {
        font-size: 18px;
    }
    
    .logo .subtitle {
        font-size: 10px;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .dashboard {
        flex-direction: column;
        overflow-y: auto;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 999;
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.mobile-visible {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.7);
        z-index: 998;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        flex-direction: column !important;
        gap: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }
    
    /* Circuito in alto su mobile */
    .circuit-column {
        order: 1;
        flex: none !important;
        height: 50vh;
        min-height: 300px;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
    }
    
    .circuit-column > div:first-child {
        padding: 10px 15px;
    }
    
    .circuit-column > div:first-child h2 {
        font-size: 14px;
    }
    
    .circuit-container {
        padding: 10px !important;
        height: 100% !important;
        min-height: 0 !important;
    }
    
    .circuit-wrapper {
        height: 100% !important;
        min-height: 0 !important;
        width: 100% !important;
    }
    
    #circuitSvg {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        preserveAspectRatio: xMidYMid meet !important;
        display: block;
    }
    
    .circuit-info {
        top: 10px;
        left: 10px;
        padding: 8px 12px;
    }
    
    .circuit-name {
        font-size: 14px;
    }
    
    .circuit-length {
        font-size: 10px;
    }
    
    /* Timing in basso su mobile */
    .timing-column {
        order: 2;
        flex: none !important;
        min-height: 50vh;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
    }
    
    .timing-column > div:first-child {
        padding: 10px 15px;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    
    .timing-column > div:first-child h2 {
        font-size: 14px;
    }
    
    .timing-column > div:last-child {
        padding: 10px !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .timing-panel {
        padding: 10px !important;
    }
    
    .timing-panel h2 {
        font-size: 14px !important;
        margin-bottom: 10px !important;
        padding-bottom: 5px !important;
    }
    
    /* Tabella timing mobile - font più piccoli e colonne compatte */
    .timing-table {
        font-size: 10px;
        min-width: 800px; /* Forza scroll orizzontale se necessario */
    }
    
    .timing-table th {
        padding: 8px 4px !important;
        font-size: 9px !important;
        white-space: nowrap;
    }
    
    .timing-table td {
        padding: 8px 4px !important;
        font-size: 10px !important;
        white-space: nowrap;
    }
    
    /* Colonne più compatte */
    .timing-table th:nth-child(1),
    .timing-table td:nth-child(1) {
        width: 35px;
        min-width: 35px;
    }
    
    .timing-table th:nth-child(2),
    .timing-table td:nth-child(2) {
        width: 60px;
        min-width: 60px;
    }
    
    .timing-table th:nth-child(3),
    .timing-table td:nth-child(3),
    .timing-table th:nth-child(4),
    .timing-table td:nth-child(4),
    .timing-table th:nth-child(5),
    .timing-table td:nth-child(5),
    .timing-table th:nth-child(6),
    .timing-table td:nth-child(6) {
        width: 70px;
        min-width: 70px;
    }
    
    .timing-table th:nth-child(7),
    .timing-table td:nth-child(7),
    .timing-table th:nth-child(8),
    .timing-table td:nth-child(8) {
        width: 50px;
        min-width: 50px;
    }
    
    .timing-table th:nth-child(9),
    .timing-table td:nth-child(9) {
        width: 60px;
        min-width: 60px;
    }
}

/* Tablet */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .main-content {
        flex-direction: column !important;
        gap: 0 !important;
    }
    
    .circuit-column {
        order: 1;
        height: 50vh;
        min-height: 400px;
    }
    
    .timing-column {
        order: 2;
        min-height: 50vh;
    }
    
    .timing-table {
        font-size: 11px;
    }
    
    .timing-table th,
    .timing-table td {
        padding: 10px 6px !important;
        font-size: 11px !important;
    }
}

