/* Stav kamer a Mapa – přehled kamer (mřížka, mapa, tabulka, detail). */

/* Kroužek odpočtu obnovy */
.ikona-tl .kruh {
  position: absolute;
  inset: 2px;
  width: 30px;
  height: 30px;
  transform: rotate(-90deg);
  pointer-events: none;
}
.ikona-tl .kruh circle {
  fill: none;
  stroke: var(--akcent);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
.ikona-tl.toci .sipka { animation: toc 0.9s linear infinite; }
@keyframes toc { to { transform: rotate(360deg); } }

.hlaseni {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--nefunguje);
  border-radius: 12px;
  background: rgba(255, 69, 58, 0.1);
}

/* Souhrnné karty = zároveň filtry */
.kpi {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.7fr);
  gap: 12px;
}
.kpi-karta {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--okraj);
  border-radius: var(--radius);
  background: var(--karta);
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
button.kpi-karta:hover { transform: translateY(-1px); box-shadow: var(--stin); }
.kpi-karta[aria-pressed="true"] { border-color: var(--barva, var(--akcent)); box-shadow: inset 0 0 0 1px var(--barva, var(--akcent)); }
.kpi-karta .popisek { display: flex; align-items: center; gap: 7px; font-size: 0.8rem; color: var(--text-2); }
.kpi-karta .hodnota { font-size: 1.95rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-graf { cursor: default; }
.kpi-graf .hlava { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.graf { position: relative; height: 46px; margin-top: 4px; }
.graf svg { display: block; width: 100%; height: 100%; overflow: visible; }
.graf .plocha { fill: var(--akcent); opacity: 0.16; }
.graf .cara { fill: none; stroke: var(--akcent); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.graf .ukazatel { stroke: var(--text-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.graf-popis { min-height: 1.1em; font-size: 0.75rem; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Nástroje: hledání, řazení */
.nastroje { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 16px 0 14px; }
.hledani { position: relative; flex: 1 1 240px; max-width: 420px; }
.hledani svg { position: absolute; top: 50%; left: 11px; transform: translateY(-50%); color: var(--text-2); }
.hledani input { width: 100%; padding-left: 34px; }
.pocitadlo { margin-left: auto; font-size: 0.85rem; color: var(--text-2); }

/* ---------- Mřížka ---------- */
.mrizka { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.kamera {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--okraj);
  border-radius: var(--radius);
  background: var(--karta);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.kamera:hover { transform: translateY(-2px); box-shadow: var(--stin); }
.kamera.s-problem, .kamera.s-nefunguje { border-color: var(--barva); box-shadow: inset 0 0 0 1px var(--barva); }
.kamera.s-problem:hover, .kamera.s-nefunguje:hover { box-shadow: inset 0 0 0 1px var(--barva), var(--stin); }
.foto { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--karta-2); }
.foto img { display: block; width: 100%; height: 100%; object-fit: cover; transition: opacity 0.35s ease; }
.foto img[data-nacteno="ne"] { opacity: 0; }
.foto.nacita::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.07) 50%, transparent 80%);
  background-size: 200% 100%;
  animation: lesk 1.4s linear infinite;
}
@keyframes lesk { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.kamera.s-nefunguje .foto img { filter: grayscale(0.9) brightness(0.65); }
.foto .pilulka { position: absolute; top: 10px; left: 10px; max-width: calc(100% - 20px); }
.cas-foto {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(8, 12, 18, 0.65);
  color: #fff;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.cas-foto:empty { display: none; }
.telo { padding: 11px 13px 12px; }
.nazev { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.nazev span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.telo .pas { margin-top: 10px; }
.pas-popis { display: flex; justify-content: space-between; margin-top: 5px; font-size: 0.72rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pas-popis b { font-weight: 600; color: var(--text); }
.s-problem .pas-popis b, .s-problem .procenta { color: var(--problem); }
.s-nefunguje .pas-popis b, .s-nefunguje .procenta { color: var(--nefunguje); }
.prazdne { grid-column: 1 / -1; padding: 40px 20px; text-align: center; color: var(--text-2); }

/* ---------- Mapa ---------- */
.mapa-obal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  height: clamp(460px, calc(100vh - 330px), 980px);
}

/* Pohled Mapa: hlavička, souhrn, nástroje i mapa se vejdou na výšku okna, mapa vyplní zbytek. */
body.mapa-na-vysku main {
  flex: 0 0 auto; /* pevná výška okna, patička až pod ní */
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--lista-v, 58px));
  height: calc(100dvh - var(--lista-v, 58px));
  min-height: 520px;
  padding-top: 12px;
  padding-bottom: 14px;
}
body.mapa-na-vysku .hlavicka { margin-bottom: 10px; }
body.mapa-na-vysku .hlavicka h1 { font-size: 1.35rem; }
body.mapa-na-vysku .hlavicka p { display: none; }
body.mapa-na-vysku .kpi-karta { padding: 8px 14px; gap: 1px; }
body.mapa-na-vysku .kpi-karta .hodnota { font-size: 1.45rem; }
body.mapa-na-vysku .graf { height: 26px; margin-top: 2px; }
body.mapa-na-vysku .graf-popis { display: none; }
body.mapa-na-vysku .nastroje { margin: 10px 0; }
body.mapa-na-vysku .mapa-obal { flex: 1 1 0; min-height: 260px; height: auto; grid-template-rows: minmax(0, 1fr); }
body.mapa-na-vysku .vysvetleni { display: none; }
#mapa {
  position: relative;
  z-index: 0; /* vlastní vrstva, ať ovládání mapy nepřekrývá horní lištu */
  overflow: hidden;
  border: 1px solid var(--okraj);
  border-radius: var(--radius);
  background: var(--karta-2);
}
.mapa-seznam { overflow: auto; border: 1px solid var(--okraj); border-radius: var(--radius); background: var(--karta); }
.polozka { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--okraj); cursor: pointer; }
.polozka:hover, .polozka.vybrana { background: var(--karta-2); }
.polozka .jm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.polozka .vek { font-size: 0.78rem; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mapa-chyba { display: grid; place-items: center; height: 100%; padding: 20px; text-align: center; color: var(--text-2); }
.leaflet-container { font-family: inherit; background: var(--karta-2); }
[data-theme="dark"] #mapa .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9) saturate(0.6); }
[data-theme="dark"] .leaflet-bar a { background: var(--karta); color: var(--text); border-color: var(--okraj); }
[data-theme="dark"] .leaflet-control-attribution { background: rgba(16, 22, 30, 0.8); color: var(--text-2); }
[data-theme="dark"] .leaflet-control-attribution a { color: var(--akcent); }
.znacka-obal { background: none; border: 0; }
.znacka {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
  border: 2.5px solid #fff;
  border-radius: 50%;
  background: var(--barva);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.znacka.s-problem::after, .znacka.s-nefunguje::after {
  content: '';
  position: absolute;
  inset: -8px;
  border: 2px solid var(--barva);
  border-radius: 50%;
  animation: puls 1.8s ease-out infinite;
}
@keyframes puls { from { transform: scale(0.55); opacity: 0.9; } to { transform: scale(1.5); opacity: 0; } }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--karta); color: var(--text); }
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { margin: 10px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-2); }
.popup .snimek { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--karta-2); }
.popup .nazev { margin: 9px 0 3px; font-size: 0.95rem; }
.popup .vlajka, .polozka .vlajka { width: 18px; height: 13px; }
.popup .radek { display: flex; align-items: center; gap: 7px; font-size: 0.8rem; color: var(--text-2); }
.popup .pas { margin-top: 8px; height: 6px; }
.popup .akce { display: flex; gap: 6px; margin-top: 10px; }
.popup .akce .tl { flex: 1; padding: 7px; font-size: 0.82rem; }

/* ---------- Tabulka ---------- */
.tabulka-obal { overflow: auto; border: 1px solid var(--okraj); border-radius: var(--radius); background: var(--karta); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  background: var(--karta-2);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
th[data-razeni] { cursor: pointer; user-select: none; }
th[data-razeni]:hover { color: var(--text); }
th[aria-sort="ascending"]::after { content: ' ↑'; }
th[aria-sort="descending"]::after { content: ' ↓'; }
td { padding: 9px 12px; border-top: 1px solid var(--okraj); white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--karta-2); }
td.sl-pas { width: 38%; min-width: 220px; }
td .nazev { font-weight: 500; }
td .id { color: var(--text-2); font-size: 0.78rem; font-weight: 400; }
.stav-text { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.tab-odkaz { color: var(--text-2); text-decoration: none; }
.tab-odkaz:hover { color: var(--akcent); }

/* ---------- Detail kamery ---------- */
.zavoj { position: fixed; inset: 0; z-index: 1999; background: rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
.zavoj.otevreny { opacity: 1; pointer-events: auto; }
.detail {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  width: min(780px, 100%);
  height: 100%;
  overflow-y: auto;
  background: var(--bg-2);
  border-left: 1px solid var(--okraj);
  box-shadow: -24px 0 48px rgba(0, 0, 0, 0.35);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.3s;
}
.detail.otevreny { transform: none; visibility: visible; transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s; }
.detail-hlava {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--okraj);
}
.detail-hlava .titulek { flex: 1; min-width: 0; }
.detail-hlava h2 { display: flex; align-items: center; gap: 8px; margin: 0; overflow: hidden; font-size: 1.12rem; white-space: nowrap; text-overflow: ellipsis; }
.detail-stav { display: flex; align-items: center; gap: 7px; margin-top: 2px; font-size: 0.85rem; color: var(--text-2); }
.detail-telo { display: flex; flex-direction: column; gap: 16px; padding: 16px; }
.detail-foto { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 12px; background: #000; }
.detail-foto img { display: block; width: 100%; height: 100%; object-fit: contain; }
.detail-foto .cas-foto { padding: 4px 10px; font-size: 0.85rem; }
.prehravac { display: flex; align-items: center; gap: 10px; }
.prehravac input[type="range"] { flex: 1; min-width: 0; accent-color: var(--akcent); }
.pas.velky { height: 22px; border-radius: 6px; cursor: crosshair; }
.osa { position: relative; height: 16px; margin-top: 5px; font-size: 0.7rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.osa span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.pas-napoveda { min-height: 1.1em; margin-top: 2px; font-size: 0.75rem; color: var(--text-2); }
.cisla { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0; }
.cisla div { padding: 10px 12px; border: 1px solid var(--okraj); border-radius: 12px; background: var(--karta); }
.cisla dt { font-size: 0.75rem; color: var(--text-2); }
.cisla dd { margin: 2px 0 0; font-size: 1.02rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.detail-akce { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Úzké obrazovky ---------- */
@media (max-width: 1100px) {
  .kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi-graf { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .mapa-obal { grid-template-columns: 1fr; height: auto; }
  #mapa { height: 62vh; min-height: 360px; }
  .mapa-seznam { max-height: 46vh; }
  /* Mapa na výšku i na mobilu: mapa nahoře, seznam pod ní v menší části */
  body.mapa-na-vysku .mapa-obal { grid-template-rows: minmax(0, 1fr) minmax(0, 34%); gap: 10px; }
  body.mapa-na-vysku #mapa { height: auto; min-height: 0; }
  body.mapa-na-vysku .mapa-seznam { max-height: none; }
  body.mapa-na-vysku .kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  body.mapa-na-vysku .kpi-graf { display: none; }
  body.mapa-na-vysku .kpi-karta { padding: 6px 9px; }
  body.mapa-na-vysku .kpi-karta .popisek { font-size: 0.7rem; }
  body.mapa-na-vysku .kpi-karta .hodnota { font-size: 1.2rem; }
  body.mapa-na-vysku .pocitadlo { display: none; }
  body.mapa-na-vysku .nastroje { flex-wrap: nowrap; gap: 8px; }
  body.mapa-na-vysku .hledani { flex: 1 1 auto; min-width: 0; }
  body.mapa-na-vysku #razeni { flex: 0 1 150px; min-width: 0; }
}
@media (max-width: 700px) {
  .segment .txt { display: none; }
  .segment button { padding: 7px 10px; }
  .kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-karta .hodnota { font-size: 1.6rem; }
  .pocitadlo { width: 100%; margin-left: 0; }
  .mrizka { grid-template-columns: 1fr; }
}

/* Vysvětlení stavů pod přehledem */
.vysvetleni { margin-top: 22px; font-size: 0.88rem; color: var(--text-2); }
.vysvetleni summary { color: var(--text); font-weight: 500; cursor: pointer; }
.vysvetleni ul { margin: 8px 0 0; padding-left: 18px; }
.vysvetleni li { margin: 3px 0; }
