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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

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

header {
    background-color: #fff;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    color: #333;
    font-size: 24px;
    margin-bottom: 8px;
}

header .header-info {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
}

header .filter-info {
    color: #666;
    font-size: 12px;
    font-style: italic;
    margin: 0;
}

header .real-laps-info {
    color: #FF0000;
    font-size: 12px;
    font-weight: 600;
    margin: 0;
    background-color: #fff3cd;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #ffc107;
}

header .real-laps-info strong {
    color: #d9534f;
    font-size: 14px;
}

/* Filtros */
.filters-panel {
    background-color: #fff;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.filters-panel {
    position: relative;
}

.filters-panel h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #333;
    font-weight: 600;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-weight: 600;
    font-size: 14px;
}

.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-button {
    padding: 8px 16px;
    background-color: #e0e0e0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.filter-button:hover {
    background-color: #d0d0d0;
}

.filter-button.active {
    background-color: #333;
    color: #fff;
}

.filter-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.filter-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.filter-checkbox-item:hover {
    background-color: #f0f0f0;
}

.filter-checkbox-item input[type="checkbox"] {
    cursor: pointer;
}

.filter-checkbox-item.checked {
    background-color: #333;
    color: #fff;
}

.filter-checkbox-item.checked label {
    color: #fff;
}

/* Layout principal */
.main-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Tablas */
.tables-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Tabla de resumen por vuelta */
.laps-summary-container {
    background-color: #fff;
    padding: 20px;
    margin-top: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.laps-summary-container h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #333;
    font-weight: 600;
}

.laps-summary-container .table-container {
    overflow-x: auto;
}

#lapsSummaryTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#lapsSummaryTable thead {
    background-color: #f8f8f8;
    position: sticky;
    top: 0;
    z-index: 10;
}

#lapsSummaryTable th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
    background-color: #f8f8f8;
    white-space: nowrap;
}

#lapsSummaryTable td {
    padding: 10px 8px;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

#lapsSummaryTable tbody tr:hover {
    background-color: #f9f9f9;
}

#lapsSummaryTable tbody tr:nth-child(even) {
    background-color: #fafafa;
}

#lapsSummaryTable tbody tr:nth-child(even):hover {
    background-color: #f0f0f0;
}

#lapsSummaryTable tfoot .total-row {
    background-color: #f0f0f0;
    font-weight: 600;
    border-top: 2px solid #ddd;
}

#lapsSummaryTable tfoot .total-row td {
    padding: 12px 8px;
}

.table-wrapper {
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table-wrapper h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #666;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

table thead {
    background-color: #f8f8f8;
}

table th {
    padding: 8px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
}

table td {
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
}

table tbody tr:hover {
    background-color: #f9f9f9;
}

table tfoot .total-row {
    background-color: #f0f0f0;
    font-weight: 600;
}

/* Mapa */
.map-container {
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    min-height: 700px;
    width: 100%;
}

.map-container h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #666;
    font-weight: 600;
}

.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    z-index: 1000;
    font-weight: 600;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

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

.map-no-data {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 8px;
    z-index: 1000;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    max-width: 400px;
}

.map-no-data p {
    margin: 10px 0;
    color: #333;
}

.map-no-data ul {
    text-align: left;
    margin: 15px 0;
    padding-left: 20px;
}

.map-no-data li {
    margin: 5px 0;
    color: #666;
}

.map-no-data small {
    color: #999;
    font-size: 12px;
}

#map {
    height: 700px;
    width: 100%;
    border-radius: 8px;
    z-index: 1;
    min-height: 700px;
    background-color: #e0e0e0;
    border: 2px solid #ccc;
    position: relative;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

#map.leaflet-container {
    font-family: inherit;
}

/* Asegurar que el mapa sea visible */
.leaflet-container {
    background-color: #e0e0e0 !important;
}

/* Asegurar que el mapa tenga altura mínima visible */
.leaflet-container.leaflet-touch {
    min-height: 700px;
}

/* Estilo para el marcador de línea de meta */
.finish-line-marker {
    background: transparent !important;
    border: none !important;
}

/* Leyenda de velocidad */
.speed-legend {
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    font-size: 12px;
    line-height: 1.6;
}

.speed-legend h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin: 4px 0;
}

.legend-color {
    width: 20px;
    height: 12px;
    display: inline-block;
    margin-right: 8px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.2);
}

/* Mejorar controles del mapa */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}

.leaflet-control-zoom a {
    background-color: white !important;
    color: #333 !important;
    border: 1px solid #ccc !important;
    font-weight: 600 !important;
}

.leaflet-control-zoom a:hover {
    background-color: #f0f0f0 !important;
}

.leaflet-control-layers {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
    border-radius: 8px !important;
}

/* Análisis */
.analysis-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.analysis-container h2 {
    font-size: 18px;
    margin-bottom: 20px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.metric-card {
    background-color: #f8f8f8;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.metric-card h4 {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.metric-card p {
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.chart-container {
    height: 300px;
    position: relative;
}

select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background-color: #fff;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #333;
}

/* Responsive */
@media (max-width: 1200px) {
    .tables-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .filters-panel {
        position: relative;
    }
    
    .filters-panel h2 {
        position: static;
        writing-mode: horizontal-tb;
        transform: none;
    }
}

