/* ============================================================
   eProtokoły — motyw jasny/ciemny (wszystkie ekrany)
   Przełączany atrybutem html[data-theme="light|dark"] (js/theme.js).

   Strategie:
   - INSPEKTOR (natywnie ciemny): wariant jasny przez nadpisanie zmiennych.
   - ADMIN (natywnie jasny): wariant ciemny przez nadpisania (override).
   - PORTAL (natywnie jasny, dużo styli inline): wariant ciemny przez filtr
     invert (data-theme-style="invert") — czyste, czytelne, bez chowania tekstu.
   - SUPERADMIN: natywnie ciemny (zablokowany, bez zmian).
   ============================================================ */

[data-theme-toggle] { transition: background .15s ease; }
[data-theme-toggle]:hover { background: rgba(127,127,127,.32) !important; }

/* ---------- INSPEKTOR: natywnie CIEMNY → wariant JASNY ---------- */
html[data-theme="light"] {
  --bg:        #eef1f7;
  --bg2:       #e3e8f1;
  --surface:   rgba(0,0,0,.045);
  --surface-h: rgba(0,0,0,.08);
  --border:    rgba(0,0,0,.12);
  --text:      #1e293b;
  --muted:     #566072;
}
html[data-theme="light"] #ins-topbar,
html[data-theme="light"] .inspector-page [style*="rgba(15,17,21"] {
  background: rgba(255,255,255,.92) !important;
  border-bottom: 1px solid rgba(0,0,0,.08) !important;
}
html[data-theme="light"] #inspector-context {
  background: rgba(0,0,0,.04) !important;
  border-color: rgba(0,0,0,.10) !important;
  color: #1e293b !important;
}
html[data-theme="light"] #inspector-context select {
  background: #fff !important; color: #1e293b !important; border-color: rgba(0,0,0,.2) !important;
}
html[data-theme="light"] #inspector-context option { background: #fff; color: #1e293b; }

/* Inspektor — wariant CIEMNY (domyślny): siatka lokali / karty formularza
   mają wymuszone białe tło — przyciemnij w trybie nocnym. */
html[data-theme="dark"] #inspector-grid > div,
html[data-theme="dark"] #inspector-form > div {
  background: #161a22 !important;
  color: #e8eaed !important;
}

/* ---------- ADMIN: natywnie JASNY → wariant CIEMNY (override) ----------
   (wykluczamy strony w trybie invert, np. portal — tam działa filtr) */
html[data-theme="dark"]:not([data-theme-style="invert"]) body { background: #0f1115 !important; color: #e8eaed !important; }

/* Paski menu admina (2. linia: selektor paneli #e8f0fe, 3. linia: zakładki #f1f3f4) */
html[data-theme="dark"]:not([data-theme-style="invert"]) [style*="#e8f0fe"],
html[data-theme="dark"]:not([data-theme-style="invert"]) [style*="#f1f3f4"],
html[data-theme="dark"]:not([data-theme-style="invert"]) [style*="#f1f3f5"],
html[data-theme="dark"]:not([data-theme-style="invert"]) [style*="#ecf0f1"] {
  background: #161a22 !important;
  border-color: #2a2f3a !important;
}
html[data-theme="dark"]:not([data-theme-style="invert"]) [style*="#2c3e50"] { color: #e8eaed !important; }
html[data-theme="dark"]:not([data-theme-style="invert"]) .list { border-color: #2a2f3a !important; background: #161a22 !important; }
html[data-theme="dark"]:not([data-theme-style="invert"]) .panel { color: #e8eaed; }
html[data-theme="dark"]:not([data-theme-style="invert"]) table { color: #e8eaed; }
html[data-theme="dark"]:not([data-theme-style="invert"]) th { background: #1a1d26 !important; color: #e8eaed !important; }
html[data-theme="dark"]:not([data-theme-style="invert"]) td { border-color: #2a2f3a !important; }

html[data-theme="dark"]:not([data-theme-style="invert"]) input:not([type=checkbox]):not([type=radio]):not([type=file]),
html[data-theme="dark"]:not([data-theme-style="invert"]) select,
html[data-theme="dark"]:not([data-theme-style="invert"]) textarea {
  background: #1a1d26 !important; color: #e8eaed !important; border-color: #2a2f3a !important;
}

/* Karty/sekcje admina z jasnym tłem inline → przyciemnij */
html[data-theme="dark"]:not([data-theme-style="invert"]) [style*="background:#fff"],
html[data-theme="dark"]:not([data-theme-style="invert"]) [style*="background: #fff"],
html[data-theme="dark"]:not([data-theme-style="invert"]) [style*="background:#ffffff"],
html[data-theme="dark"]:not([data-theme-style="invert"]) [style*="background:#f9f9f9"],
html[data-theme="dark"]:not([data-theme-style="invert"]) [style*="background:#f8fafc"] {
  background: #161a22 !important;
  border-color: #2a2f3a !important;
}

/* ---------- PORTAL i inne strony jasne: tryb ciemny przez FILTR INVERT ----------
   Odwraca białe→ciemne i ciemny tekst→jasny automatycznie (czytelne, bez
   chowania pól). Media/mapy/iframe/przycisk odwracamy ponownie, by wyglądały
   normalnie. */
html[data-theme="dark"][data-theme-style="invert"] body {
  filter: invert(1) hue-rotate(180deg);
  background: #ffffff; /* po inwersji = ciemne */
  min-height: 100vh;
}
html[data-theme="dark"][data-theme-style="invert"] img,
html[data-theme="dark"][data-theme-style="invert"] iframe,
html[data-theme="dark"][data-theme-style="invert"] video,
html[data-theme="dark"][data-theme-style="invert"] .leaflet-container,
html[data-theme="dark"][data-theme-style="invert"] [data-theme-toggle] {
  filter: invert(1) hue-rotate(180deg);
}
