/* --- Ogólne style i dostępność --- */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f0f2f5; /* Jasne tło dla kontrastu */
    color: #333; /* Ciemny tekst dla czytelności */
}

/* Podstawowe style dla kontenerów widżetów */
.air-quality-widget,
.air-quality-details-widget {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 25px;
    max-width: 400px; /* Ograniczenie szerokości dla widgetu głównego */
    margin: 20px auto;
    text-align: center;
    border: 1px solid #e0e0e0;
}

.air-quality-details-widget {
    max-width: 800px; /* Szerszy dla szczegółów */
}

.widget-title {
    font-size: 1.8em;
    color: #2c3e50;
    margin-bottom: 20px;
}

/* --- Style dla air-quality-widget.html --- */
.air-quality-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    margin: 0 auto 20px auto;
    color: #fff;
    font-weight: bold;
    font-size: 1.2em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease;
    padding: 10px; /* Padding dla treści w kółku */
}

.air-quality-display i {
    font-size: 3.5em; /* Rozmiar ikonki buźki */
    margin-bottom: 5px;
}

.aq-index {
    font-size: 1.0em;
    margin: 0;
}

.aq-status {
    font-size: 1.1em;
    margin-top: 5px;
    font-weight: normal;
}

.aq-recommendation {
    font-size: 0.95em;
    color: #555;
    margin-top: 20px;
    line-height: 1.4;
}

/* Kolory dla różnych poziomów jakości powietrza (zgodnie z GIOŚ) */
.aq-very-good { background-color: #4CAF50; /* Zielony */ } /* Bardzo dobry */
.aq-good { background-color: #8BC34A; /* Jasnozielony */ } /* Dobry */
.aq-moderate { background-color: #FFEB3B; /* Żółty */ color: #333; } /* Umiarkowany */
.aq-sufficient { background-color: #FFC107; /* Pomarańczowy */ color: #333; } /* Dostateczny */
.aq-bad { background-color: #FF5722; /* Ciemnopomarańczowy */ } /* Zły */
.aq-very-bad { background-color: #F44336; /* Czerwony */ } /* Bardzo zły */
.aq-unknown { background-color: #B0BEC5; /* Szary */ } /* Brak danych */

/* Kontrast dla tekstu na żółtym/pomarańczowym tle */
.aq-moderate .aq-index,
.aq-moderate .aq-status,
.aq-moderate i,
.aq-sufficient .aq-index,
.aq-sufficient .aq-status,
.aq-sufficient i {
    color: #333;
}


/* --- Style dla air-quality-details.html --- */
.pollutant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 25px;
}

.pollutant-card {
    background-color: #f7f7f7;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    text-align: left;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease;
}

.pollutant-card:hover {
    transform: translateY(-3px);
}

.pollutant-card h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.3em;
    color: #2c3e50;
}

.pollutant-value {
    font-size: 1.6em;
    font-weight: bold;
    color: #444;
    margin-bottom: 10px;
}

.pollutant-bar {
    width: 100%;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    margin-bottom: 8px;
    overflow: hidden; /* Ważne dla border-radius fill */
}

.pollutant-fill {
    height: 100%;
    background-color: #4CAF50; /* Domyślny zielony */
    border-radius: 4px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.pollutant-status-text {
    font-size: 0.9em;
    color: #666;
    margin-top: 0;
}

/* Kolory dla paska postępu w zależności od statusu */
.pollutant-card.pollutant-ok .pollutant-fill {
    background-color: #4CAF50; /* Zielony, w normie */
}

.pollutant-card.pollutant-exceeded .pollutant-fill {
    background-color: #FF5722; /* Pomarańczowy/czerwony, przekroczenie */
}

.pollutant-card.pollutant-unknown .pollutant-fill {
    background-color: #B0BEC5; /* Szary, brak danych */
}

/* --- Style dla przycisków i spinnerów (wspólne) --- */
.refresh-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    margin-top: 20px;
    transition: background-color 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.refresh-button:hover {
    background-color: #0056b3;
}

.refresh-button:focus {
    outline: 2px solid #0056b3; /* Widoczny focus */
    outline-offset: 2px;
}

.refresh-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Spinner ładowania */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #555;
    font-size: 0.9em;
    position: absolute; /* Użyj absolute, aby przykryć widżet podczas ładowania */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9); /* Półprzezroczyste tło */
    border-radius: 8px;
    z-index: 10;
}

.loading-spinner[aria-hidden="true"] {
    display: none;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

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

.no-data, .error-message {
    color: #c0392b;
    font-weight: bold;
    margin-top: 20px;
}

/* --- Responsywność --- */
@media (max-width: 600px) {
    .air-quality-widget,
    .air-quality-details-widget {
        padding: 15px;
        margin: 10px auto;
        border-radius: 5px;
    }

    .widget-title {
        font-size: 1.5em;
    }

    .air-quality-display {
        width: 120px;
        height: 120px;
    }

    .air-quality-display i {
        font-size: 3em;
    }

    .aq-index {
        font-size: 1.5em;
    }

    .pollutant-grid {
        grid-template-columns: 1fr; /* Jedna kolumna na małych ekranach */
    }
}

/* --- Dostępność - Focus States --- */
*:focus {
    outline: 2px solid #0056b3; /* Wyraźne obramowanie dla fokusu klawiaturą */
    outline-offset: 2px;
}

/* Kontrast dla elementów interfejsu (np. ikon Font Awesome na różnych tłach) */
.fas {
    /* Upewnij się, że ikony mają wystarczający kontrast z tłem,
       jeśli ich kolor jest domyślny i tło jest jasne */
    color: inherit; /* Domyślnie dziedziczy kolor z rodzica */
}
/* Jeśli ikonki mają być zawsze ciemne na jasnym tle */
.air-quality-display.aq-moderate i,
.air-quality-display.aq-sufficient i {
    color: #333; /* Ciemny kolor dla buziek na jasnym tle */
}

/* --- Style dla tabeli indeksów jakości powietrza --- */

.aqi-table-container {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 25px;
    max-width: 900px; /* Maksymalna szerokość dla tabeli */
    margin: 20px auto;
    border: 1px solid #e0e0e0;
    overflow-x: auto; /* Pozwala na przewijanie tabeli na małych ekranach */
}

.widget-title { /* Upewnij się, że ta klasa jest spójna z innymi tytułami */
    font-size: 1.8em;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center; /* Wyśrodkowanie nagłówka tabeli */
}


.aqi-standards-table {
    width: 100%;
    border-collapse: collapse; /* Usuwa podwójne obramowania komórek */
    margin-top: 20px;
    font-size: 0.9em;
    table-layout: fixed; /* Równe szerokości kolumn */
}

.aqi-standards-table th,
.aqi-standards-table td {
    border: 1px solid #e0e0e0; /* Delikatne obramowanie */
    padding: 10px 12px;
    text-align: center;
    vertical-align: middle;
    color: #333; /* Domyślny ciemny tekst dla wszystkich komórek danych */
}

.aqi-standards-table th {
    background-color: #f0f2f5;
    color: #2c3e50;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.95em;
}

/* Usuwamy to, co powodowało białe tło i brak cieniowania */
/* .aqi-standards-table tbody tr:nth-child(odd) { background-color: #fcfcfc; } */
/* .aqi-standards-table tbody tr:hover { background-color: #f5f5f5; } */

/* Kolorowanie Wierszy Tabeli zgodnie z poziomem jakości powietrza */
/* Używamy klas zdefiniowanych dla widżetu głównego, ale teraz dla całego wiersza */
.aqi-level-row.aqi-very-good { background-color: #4CAF50; color: #FFFFFF; } /* Zielony, biały tekst */
.aqi-level-row.aqi-good { background-color: #8BC34A; color: #FFFFFF; } /* Jasnozielony, biały tekst */
.aqi-level-row.aqi-moderate { background-color: #FFEB3B; color: #333333; } /* Żółty, ciemny tekst */
.aqi-level-row.aqi-sufficient { background-color: #FFC107; color: #FFFFFF; } /* Pomarańczowy, biały tekst */
.aqi-level-row.aqi-bad { background-color: #FF5722; color: #FFFFFF; } /* Ciemnopomarańczowy, biały tekst */
.aqi-level-row.aqi-very-bad { background-color: #F44336; color: #FFFFFF; } /* Czerwony, biały tekst */

/* Nadpisanie koloru tekstu dla jaśniejszych teł (aby zapewnić kontrast) */
/* Dotyczy komórek z danymi numerycznymi w wierszach o jasnym tle */
.aqi-level-row.aqi-moderate td {
    color: #333333; /* Ciemny tekst dla komórek w wierszu "Umiarkowany" */
}

/* Styl dla nazwy indeksu w pierwszej kolumnie (aby była spójna z kolorem tła wiersza) */
.aqi-level-row .aqi-level-name {
    font-weight: bold;
    /* Kolor tekstu jest dziedziczony z klasy aqi-level-row */
}

/* Dodatkowe style dla nazw zanieczyszczeń w nagłówkach (subscript) */
.aqi-standards-table th sup,
.aqi-standards-table th sub {
    font-size: 0.7em; /* Zmniejszenie rozmiaru dla indeksów górnych/dolnych */
    vertical-align: super;
}

.aqi-standards-table th sub {
    vertical-align: sub;
}

.aqi-source-note {
    font-size: 0.8em;
    color: #777;
    text-align: center;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px dashed #eee;
}

/* Responsywność dla tabeli */
@media (max-width: 768px) {
    .aqi-standards-table {
        display: block;
        width: auto; /* Pozwala na przewijanie */
    }

    .aqi-standards-table thead, 
    .aqi-standards-table tbody, 
    .aqi-standards-table th, 
    .aqi-standards-table td, 
    .aqi-standards-table tr { 
        display: block; 
    }
    
    .aqi-standards-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .aqi-standards-table tr {
        border: 1px solid #ccc;
        margin-bottom: 10px;
        border-radius: 5px;
    }
    
    .aqi-standards-table td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%; /* Miejsce na etykietę */
        text-align: right;
    }
    
    .aqi-standards-table td:before {
        content: attr(data-label); /* Wyświetla nagłówek kolumny jako etykietę */
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        color: #555;
    }
    /* Specjalne formatowanie dla pierwszej kolumny (nazwa indeksu) */
    .aqi-standards-table tr td:first-child {
        text-align: center;
        padding-left: 12px;
        /* Kolory tła są już ustawione przez .aqi-level-row */
        /* Kolor tekstu jest już ustawiony przez .aqi-level-row */
        border-bottom: 1px solid #ccc;
    }
}

/* Uzupełnienie klas dla kolorów, jeśli nie były zdefiniowane w style.css dla tabeli */
/* Te kolory powinny być już w style.css z widżetów, ale dla pewności */
.aq-very-good { background-color: #4CAF50; } 
.aq-good { background-color: #8BC34A; } 
.aq-moderate { background-color: #FFEB3B; } 
.aq-sufficient { background-color: #FFC107; } 
.aqi-bad { background-color: #FF5722; } 
.aqi-very-bad { background-color: #F44336; }


/* --- Style dla widżetu wykresów (air-quality-charts.html) --- */

.air-quality-charts-widget {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 20px;
    max-width: 1200px;
    margin: 20px auto;
    border: 1px solid #e0e0e0;
    text-align: center; 
}

.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); /* Zmniejszono min. szerokość kafelka */
    gap: 15px; /* Zmniejszono odstępy */
    margin-top: 20px;
    margin-bottom: 20px;
    justify-content: center; 
    align-items: start;
}

.chart-card {
    background-color: #f7f7f7;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 8px; /* Zmniejszono padding kafelka */
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    display: flex; 
    flex-direction: column;
    align-items: center;
    justify-content: space-between; 
    /* Dodaj jawne ustawienie wysokości dla Chart-card, jeśli canvas nadal go rozpycha */
    /* Zazwyczaj nie jest to potrzebne, ale w przypadku opornych rozciągnięć może pomóc */
    /* height: 250px; /* Przykład stałej wysokości, jeśli to konieczne. Dostosuj. */ 
}

.chart-card h3 {
    margin: 0 0 5px 0; 
    font-size: 0.9em; /* Jeszcze mniejsza czcionka tytułu */
    color: #2c3e50;
}

.chart-card canvas {
    max-width: 100%; 
    height: 120px !important; /* WAŻNE: Wymuszenie wysokości CSS z !important */
    /* Dodatkowe zabezpieczenie: min-height */
    min-height: 120px !important; 
    display: block; /* Upewnij się, że canvas jest elementem blokowym */
}

.chart-info {
    font-size: 0.7em; /* Jeszcze mniejsza czcionka informacji */
    color: #777;
    margin-top: 5px; 
    margin-bottom: 0; 
}

/* ... (resztę stylów możesz zostawić bez zmian) ... */

/* Responsywność dla wykresów */
@media (max-width: 768px) {
    .charts-container {
        grid-template-columns: 1fr;
        gap: 10px; /* Jeszcze mniejsze odstępy na mobilnych */
    }
    .air-quality-charts-widget {
        padding: 10px;
        margin: 10px auto;
        max-width: 100%; 
    }
    .chart-card {
        padding: 5px; /* Mniejszy padding na mobilnych */
    }
    .chart-card canvas {
        height: 100px !important; /* Jeszcze mniejsza wysokość na mobilnych i wymuszenie */
        min-height: 100px !important;
    }
    .chart-card h3 {
        font-size: 0.85em; 
    }
}