/* charts.css */

/* --- Style Loadera Dostosowane do Motywu F1 --- */
.chart-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(7, 13, 15, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: 10px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.loading-tire-small {
    width: 40px;
    height: 40px;
    animation: spin 1.5s linear infinite;
    margin-bottom: 10px;
}

.chart-loader p {
    margin: 0;
    font-size: 1em;
    font-weight: bold;
    color: #cdd9e5;
    font-family: 'Formula1-Bold', sans-serif;
}

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

/* --- Podstawowe style strony --- */
@font-face {
  font-family: 'Formula1-Bold';
  src: url("/static/fonts/Formula1-Regular_web_0.90c10fedcba6.ttf") format('truetype');
  font-weight: bold;
  font-style: normal;
}

body {
  font-family: 'Formula1-Bold', sans-serif;
  font-size: 1rem;
  background-color: #000000;
  color: #506678;
  padding: 15px; /* Domyślny, mniejszy padding dla najmniejszych ekranów */
}

.chart-container {
  position: relative;
  width: 100%;
  margin: 0 auto 20px auto;
  max-width: 1200px;
  background-color: #070D0F;
  border-radius: 10px;
  padding: 15px;
}

.chart-container .canvas {
    height: 450px;
    width: 100%;
}

#tyreStrategyChartCanvas {
    width: 100% !important;
    max-height: 700px;
}

#driverPositionChartCanvas {
    width: 100% !important;
    max-height: 700px;
}

.chart-container-map {
    position: relative;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto 20px auto;
    background-color: #070D0F;
    border-radius: 10px;
    padding: 15px;
}

.chart-container-map .canvas {
    width: 100%;
    height: auto;
}

.note {
  width: 100%;
  text-align: center;
  padding: 15px 0;
}

a {
  text-decoration: none;
  color: #506678;
  border-bottom: 1px solid rgba(80, 102, 120, 0.25);
  transition: all 0.35s;
}
a:hover {
  color: #677f93;
  border-bottom: 1px solid rgba(149, 76, 233, 0.5);
}

/* --- Przycisk resetu zoomu --- */
.reset-zoom-button {
    position: absolute;
    /* ZMIANA: Wyrównanie góry z ikoną pobierania dla spójności wizualnej */
    top: 12px;
    /* ZMIANA: Ustawienie pozycji na lewo od ikony pobierania */
    /* Kalkulacja:
       - Ikona pobierania jest na 'right: 35px'
       - Szerokość ikony to ok. 38px (28px obrazek + 2*5px padding)
       - Zostawiamy 8px odstępu
       - Nowa pozycja 'right' = 35px + 38px + 8px = 81px. Zaokrąglijmy do 85px dla bezpieczeństwa.
    */
    right: 85px;
    z-index: 11; /* Wyższy z-index, aby zawsze był na wierzchu */
    padding: 6px 12px;
    background-color: rgba(7, 13, 15, 0.8);
    color: #cdd9e5;
    border: 1px solid #506678;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
    font-family: 'Formula1-Bold', sans-serif;
    text-transform: uppercase;
    box-shadow: 3px 3px 10px -5px rgba(0, 0, 0, 0.4);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
}
.reset-zoom-button:hover {
    background-color: rgba(7, 13, 15, 0.95);
    border-color: #a0b4c7;
    color: #fff;
    box-shadow: 3px 3px 15px -3px rgba(0, 0, 0, 0.6);
}
.reset-zoom-button:active {
    background-color: #192027;
    box-shadow: none;
    transform: translateY(1px);
}
.reset-zoom-button:focus {
    outline: none;
    border-color: #a0b4c7;
    box-shadow: 0 0 0 2px rgba(80, 102, 120, 0.5), 3px 3px 15px -3px rgba(0, 0, 0, 0.6);
}

/* --- ZMIANA: Style dla przycisku pobierania jako ikony --- */
.download-chart-button {
    position: absolute;
    top: 8px;
    right: 35px; /* Pozycja na lewo od przycisku Reset Zoom */
    z-index: 10;
    padding: 5px; /* Mały padding wokół ikony */
    background: transparent;
    border: none;
    cursor: pointer;
    line-height: 0; /* Zapobiega dodatkowej wysokości przycisku */
    border-radius: 5px;
    transition: background-color 0.2s ease;
}
.download-chart-button:hover {
    background-color: rgba(80, 102, 120, 0.2); /* Lekkie tło po najechaniu */
}
.download-chart-button img {
    width: 28px;
    height: 28px;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease;
    vertical-align: middle;
}
.download-chart-button:hover img {
    opacity: 1;
    transform: scale(1.1);
}
/* --- KONIEC ZMIAN --- */

/* === Główny kontener strony === */
.page-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1500px;
    margin: 0 auto;
}

/* === Panel Filtrów === */
.filters-panel {
    background-color: #070D0F;
    padding: 20px;
    border-radius: 10px;
}

.panel-title {
    font-family: 'Formula1-Bold', sans-serif;
    color: #e10600;
    text-transform: uppercase;
    font-size: 1.4rem;
    margin-top: 0;
    margin-bottom: 25px;
    text-align: center;
    border-bottom: 1px solid #333f4a;
    padding-bottom: 10px;
}

/* === Pojedynczy element filtra === */
.filter-item {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}
.filter-item:last-child { margin-bottom: 0; }

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

.filter-item-header label {
    margin-bottom: 0;
    font-family: 'Formula1-Bold', sans-serif;
    font-size: 0.95rem;
    color: #cdd9e5;
}

.deselect-button {
    padding: 4px 10px;
    background-color: rgba(80, 102, 120, 0.3);
    color: #cdd9e5;
    border: 1px solid #506678;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8em;
    font-family: 'Formula1-Bold', sans-serif;
    text-transform: uppercase;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.deselect-button:hover {
    background-color: rgba(100, 122, 140, 0.5);
    border-color: #a0b4c7;
    color: #fff;
}

.deselect-button:active {
    background-color: #192027;
    transform: translateY(1px);
}

.deselect-button:focus {
    outline: none;
    border-color: #a0b4c7;
    box-shadow: 0 0 0 2px rgba(80, 102, 120, 0.5);
}

.filter-item label {
    font-family: 'Formula1-Bold', sans-serif;
    font-size: 0.95rem;
    color: #cdd9e5;
    margin-bottom: 8px;
}

.filter-item select,
.filter-item .driver-pills-container {
    width: 100%;
    box-sizing: border-box;
}

select {
    font-family: 'Formula1-Bold', sans-serif;
    font-size: 1rem;
    padding: 0.6em 2.5em 0.6em 1em;
    border: 1px solid #506678;
    border-radius: 5px;
    background-color: #0c1418;
    color: #cdd9e5;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23cdd9e5'%3E%3Cpath d='M8 11.5a.5.5 0 0 1-.354-.146l-4-4a.5.5 0 0 1 .708-.708L8 10.293l3.646-3.647a.5.5 0 0 1 .708.708l-4 4A.5.5 0 0 1 8 11.5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7em top 50%;
    background-size: 1em auto;
}
select::-ms-expand { display: none; }
select:focus {
    outline: none;
    border-color: #a0b4c7;
    box-shadow: 0 0 0 2px rgba(80, 102, 120, 0.5);
}
select:hover { border-color: #a0b4c7; }
select option {
    background-color: #070D0F;
    color: #cdd9e5;
}

.driver-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border: 1px solid #506678;
    border-radius: 5px;
    min-height: 42px;
    background-color: #0c1418;
    align-items: center;
}
.driver-pill {
    font-family: 'Formula1-Bold', sans-serif;
    font-size: 0.9rem;
    padding: 5px 10px;
    border: 1px solid #506678;
    background-color: rgba(80, 102, 120, 0.2);
    color: #cdd9e5;
    border-radius: 15px;
    cursor: pointer;
    text-align: center;
    user-select: none;
    outline: none;
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.driver-pill:hover {
    border-color: #a0b4c7;
    background-color: rgba(160, 180, 199, 0.3);
    color: #ffffff;
}
.driver-pill.selected {
    background-color: #e10600;
    color: #ffffff;
    border-color: #b30500;
    box-shadow: 0 0 0 2px rgba(225, 6, 0, 0.4), 0 2px 5px rgba(0,0,0,0.3);
}
.driver-pill.selected:hover {
    background-color: #ff1e00;
    border-color: #e10600;
}
.driver-pills-container .no-drivers-message {
    font-family: 'Formula1-Bold', sans-serif;
    padding: 8px 12px;
    color: #8a9aa8;
    font-style: italic;
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
}

.charts-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.charts-area .chart-container:last-child {
    margin-bottom: 0;
}

.telemetry-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    padding-left: 5px;
    min-height: 25px;
}

.telemetry-pill {
    background-color: #2a3135;
    color: #cdd9e5;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8em;
    display: flex;
    align-items: center;
    border: 1px solid #506678;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.telemetry-pill span {
    margin-right: 6px;
    white-space: nowrap;
}

.telemetry-pill .remove-pill {
    background: none;
    border: none;
    color: #a0b4c7;
    cursor: pointer;
    font-size: 1.1em;
    line-height: 1;
    padding: 0 2px;
    font-weight: bold;
}
.telemetry-pill .remove-pill:hover {
    color: #e10600;
}

.telemetry-pill.error-pill {
    background-color: rgba(225, 6, 0, 0.3);
    border-color: #e10600;
    color: #f0f0f0;
}
.telemetry-pill.error-pill .remove-pill {
    color: #f0f0f0;
}
.telemetry-pill.error-pill .remove-pill:hover {
    color: #ffdddd;
}

.empty-pills-info-message {
    font-family: 'Formula1-Bold', sans-serif;
    padding: 8px 12px;
    color: #8a9aa8;
    font-style: italic;
    width: 100%;
    text-align: center;
    font-size: 1.5rem;
}

.session-results-container {
    margin-top: 25px;
    border-top: 1px solid #333f4a;
    padding-top: 15px;
}

.panel-subtitle {
    font-family: 'Formula1-Bold', sans-serif;
    color: #cdd9e5;
    font-size: 1.1rem;
    margin-top: 0;
    margin-bottom: 15px;
    text-align: left;
}

#sessionResultsLoader {
    background-color: transparent;
    border-radius: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 20px 0;
}
#sessionResultsLoader p {
    color: #cdd9e5;
}

.session-results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: #cdd9e5;
}

.session-results-table th,
.session-results-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #333f4a;
}

.session-results-table th {
    font-family: 'Formula1-Bold', sans-serif;
    color: #a0b4c7;
    background-color: rgba(80, 102, 120, 0.1);
}

.session-results-table tbody tr:hover {
    background-color: rgba(80, 102, 120, 0.2);
}

.session-results-table td:nth-child(1) {
    width: 15%;
    text-align: center;
    font-weight: bold;
}
.session-results-table td:nth-child(2) {
    width: 55%;
}
.session-results-table td:nth-child(3) {
    width: 30%;
    text-align: right;
    font-family: monospace;
}

.no-results-message {
    font-family: 'Formula1-Bold', sans-serif;
    padding: 15px 10px;
    color: #8a9aa8;
    font-style: italic;
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
    background-color: rgba(80, 102, 120, 0.05);
    border-radius: 4px;
    margin-top:10px;
}

@media (min-width: 768px) {
  body {
    padding: 20px;
  }
  .note {
    padding: 20px 0;
  }
  .page-container {
    flex-direction: row;
    align-items: flex-start;
    gap: 15px;
  }
  .filters-panel {
    flex-basis: 250px;
    flex-shrink: 0;
    margin-bottom: 0;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 15px;
  }
  .charts-area {
    flex-grow: 1;
    min-width: 0;
  }
}

@media (min-width: 992px) {
  .page-container {
    gap: 20px;
  }
  .filters-panel {
    flex-basis: 280px;
    padding: 20px 15px;
  }
}

@media (min-width: 1200px) {
  body {
    padding: 25px;
  }
  .note {
    padding: 25px 0;
  }
  .page-container {
    gap: 25px;
  }
  .filters-panel {
    flex-basis: 320px;
    top: 25px;
    max-height: calc(100vh - 50px);
    padding: 20px 20px;
  }
}

@media (min-width: 1400px) {
  .filters-panel {
    flex-basis: 350px;
    padding: 20px 25px;
  }
}

html {
    scrollbar-width: thin;
    scrollbar-color: #506678 #0c1418;
}
.filters-panel {
    scrollbar-width: thin;
    scrollbar-color: #506678 #070D0F;
}

body::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

body::-webkit-scrollbar-track {
    background: #0c1418;
}

body::-webkit-scrollbar-thumb {
    background-color: #506678;
    border-radius: 5px;
    border: 2px solid #0c1418;
}

body::-webkit-scrollbar-thumb:hover {
    background-color: #a0b4c7;
    border-color: #0c1418;
}

.filters-panel::-webkit-scrollbar {
    width: 10px;
}

.filters-panel::-webkit-scrollbar-track {
    background: #070D0F;
}

.filters-panel::-webkit-scrollbar-thumb {
    background-color: #506678;
    border-radius: 5px;
    border: 2px solid #070D0F;
}

.filters-panel::-webkit-scrollbar-thumb:hover {
    background-color: #a0b4c7;
    border-color: #070D0F;
}

::-webkit-scrollbar-corner {
  background: #070D0F;
}

#allTelemetryChartsGrid > div:not(:first-child) .download-chart-button {
    top: -20px;
}

#allTelemetryChartsGrid .reset-zoom-button {
    top: -20px;
}

#allTelemetryChartsGrid > div:first-child .download-chart-button {
    top: -24px;
}

/* Dodaj to gdzieś w pliku charts.css, np. pod stylami .chart-container */

.chart-global-placeholder {
    display: none; /* Domyślnie ukryty */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    padding: 20px;
    text-align: center;
    border: 1px solid #333f4a; /* Użyj koloru z motywu */
    border-radius: 8px;
    background-color: rgba(7, 13, 15, 0.5); /* Użyj koloru z motywu */
    color: #cdd9e5; /* Użyj koloru z motywu */
    font-family: 'Formula1-Bold', sans-serif;
    font-size: 1.5em;
    font-weight: bold;
}
