/* Reset i podstawowe style */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--secondary-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

canvas {
    max-width: 100%;
}

/* =============================================
   F4.24 (2026-07-23) — Widoczny focus TYLKO dla klawiatury.
   :focus-visible = nawigacja Tab (obwódka brand); klik myszą jej nie pokazuje.
   Zastępuje rozproszone „outline:none" bez zamiennika (top10.css).
   ============================================= */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* =============================================
   F4.28 (2026-07-23) — prefers-reduced-motion (globalnie).
   Skraca/wyłącza animacje (tickery 120s, pulsy, flip 3D) i przejścia dla
   użytkowników preferujących brak ruchu. weather_icons.js ma własny wariant.
   ============================================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    /* Marquee: zatrzymaj w pozycji startowej (widoczny początek) zamiast
       przewinąć treść za krawędź i ją schować */
    .inline-ticker-content,
    .ticker-content {
        animation: none !important;
        transform: none !important;
    }
}

/* =============================================
   GLOBALNE NADPISANIA DLA DARK MODE
   ============================================= */

/* Linki */
a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Inputy i selecty */
input,
select,
textarea {
    background-color: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
}

input::placeholder {
    color: var(--text-muted);
}

/* Buttony */
button {
    color: var(--text-color);
}

/* Nagłówki */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-color);
}

/* Tabele */
table {
    color: var(--text-color);
}

th {
    background-color: var(--secondary-color);
    color: var(--text-muted);
}

td {
    border-color: var(--card-border);
}

/* Modals i popupy */
.modal,
.popup,
[class*="modal"],
[class*="popup"] {
    background-color: var(--card-bg);
    color: var(--text-color);
    border-color: var(--card-border);
}

/* F4.21 (2026-07-23): USUNIĘTO martwy duplikat scrollbara — identyczny selektor
   [data-theme="dark"] ::-webkit-scrollbar* jest w dark-mode-overrides.css (ładowany
   PÓŹNIEJ → wygrywał; ten był martwy). Jedno źródło = dark-mode-overrides.css. */

/* Wykresy Chart.js - tekst osi */
[data-theme="dark"] .chart-container,
[data-theme="dark"] .chart-title {
    color: var(--text-color);
}

/* Status Tiles & Badges */
.status-bg-red {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-bg-yellow {
    background-color: #fef3c7;
    color: #92400e;
}

.status-bg-green {
    background-color: #dcfce7;
    color: #166534;
}

[data-theme="dark"] .status-bg-red {
    background-color: #450a0a;
    color: #fca5a5;
    border: 1px solid #7f1d1d;
}

[data-theme="dark"] .status-bg-yellow {
    background-color: #451a03;
    color: #fdba74;
    border: 1px solid #78350f;
}

[data-theme="dark"] .status-bg-green {
    background-color: #052e16;
    color: #86efac;
    border: 1px solid #14532d;
}

/* Dark mode calendar / inputs */
[data-theme="dark"] input[type="date"] {
    color-scheme: dark;
}

/* Loader Animation */
.loader {
    border: 4px solid var(--card-border);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Brighten icons in dark mode */
[data-theme="dark"] #admin-gear,
[data-theme="dark"] #logout-btn,
[data-theme="dark"] #user-gear {
    filter: invert(1);
}

/* Detail Modal Styles */
.detail-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: var(--z-drawer); /* F4.22 (=1000) */
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.detail-modal-content {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.detail-modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--secondary-color);
    position: sticky;
    top: 0;
    z-index: var(--z-raised); /* F4.22 (=10) */
}

.detail-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.detail-close-btn:hover {
    color: var(--text-color);
}

.detail-body {
    padding: 20px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.detail-card {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    padding: 15px;
}

.detail-card h3 {
    margin-bottom: 15px;
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 8px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
    font-size: 13px;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-muted);
}

.detail-value {
    color: var(--text-color);
    font-weight: 500;
    text-align: right;
}

/* Service progress bar */
.service-progress {
    height: 8px;
    background: var(--card-border);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 5px;
}

.service-bar {
    height: 100%;
    background: var(--primary-gradient);
}

/* Clickable sparkline rows */
.sparkline-clickable {
    transition: background-color 0.2s ease;
}

.sparkline-clickable:hover {
    background-color: var(--primary-color);
    background-color: rgba(74, 222, 128, 0.1);
    border-radius: 4px;
}

.sparkline-clickable:active {
    background-color: rgba(74, 222, 128, 0.2);
}