/* ==========================================================
   METAMON FLY — izgled aplikacije
   Navy podloga, veliki kontrastni brojevi, crna glavna dugmad.
   ========================================================== */

:root {
  --bg: #0f1f3d;          /* navy */
  --panel: #152a50;
  --panel-2: #1c335f;
  --line: #2b4475;
  --text: #e9eef3;
  --text-soft: #a8b6cc;
  --accent: #000000;       /* crna (umesto narandzaste) */
  --accent-hover: #1a1a1a;
  --ok: #2fb36d;
  --warn: #f0a020;
  --off: #7a8794;
  --danger: #ef4b4b;
  --radius: 10px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* IBM Plex Sans (SIL Open Font License) */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url("plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-display: swap; src: url("plex-sans-700.woff2") format("woff2"); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

a { color: inherit; }

.wordmark {
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 15px;
}
.wordmark { display: inline-flex; align-items: center; gap: 10px; }
.wordmark img { display: block; height: 30px; width: auto; }
.wordmark span {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  background: #000;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin-left: 0;
}

/* ---------- Dugmad ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 22px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: #3e4e5e; }
.btn-main { background: var(--accent); border-color: rgba(255,255,255,0.22); color: #fff; }
.btn-main:hover { background: var(--accent-hover); border-color: rgba(255,255,255,0.5); }
.btn:focus-visible, .zoom button:focus-visible, input:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ==========================================================
   1. LOGIN
   ========================================================== */
.login {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.login-card .wordmark img { height: 40px; }
.login-card .wordmark span { font-size: 15px; padding: 4px 11px; }
.login-card h1 {
  font-size: 26px;
  margin: 28px 0 6px;
  font-weight: 700;
}
.login-card p.lead { color: var(--text-soft); margin: 0 0 28px; line-height: 1.5; }
.login-card label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}
.login-card input {
  width: 100%;
  height: 52px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 17px;
  padding: 0 14px;
}
.login-card .btn { width: 100%; margin-top: 16px; height: 52px; }
.msg-error {
  margin-top: 14px;
  color: #ff8a8a;
  font-size: 15px;
  line-height: 1.45;
}
.login-foot {
  margin-top: 36px;
  font-size: 14px;
  color: var(--text-soft);
}
.login-foot a { color: var(--text-soft); }

/* ==========================================================
   ZAGLAVLJE (izbor, snimci)
   ========================================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}
.drone-name {
  color: var(--text-soft);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drone-name strong { color: var(--text); font-weight: 600; }

/* ==========================================================
   2. IZBOR
   ========================================================== */
.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.menu {
  width: 100%;
  max-width: 980px;
  margin: auto;
  padding: 48px 24px;
}
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 220px;
  padding: 26px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-decoration: none;
}
.tile:hover { border-color: #fff; }
.tile h2 { margin: 0; font-size: 28px; font-weight: 700; }
.tile .tile-info { color: var(--text-soft); font-size: 16px; display: flex; align-items: center; gap: 8px; }
.tile-icon { width: 44px; height: 44px; color: #fff; }
.menu-logout { margin-top: 28px; display: flex; justify-content: center; }

/* ---------- Status tackica ---------- */
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--off); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }

/* ==========================================================
   3. EKRAN LETA
   ========================================================== */
.flight {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 2fr 1fr;
}

/* --- Video (leve 2/3) --- */
.video-pane {
  position: relative;
  background: #000;
  overflow: hidden;
}
.video-frame {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-frame video, .video-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.25s ease;
}

.overlay-top, .overlay-bottom {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.overlay-top { top: 14px; }
.overlay-bottom { bottom: 16px; }
.overlay-top > *, .overlay-bottom > * { pointer-events: auto; }

.btn-back {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  height: 40px;
  padding: 0 14px 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(14, 20, 27, 0.72);
  font-weight: 600;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  backdrop-filter: blur(6px);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: 18px;
  background: rgba(14, 20, 27, 0.78);
  border: 1px solid rgba(255,255,255,0.14);
  font-weight: 700;
  font-size: 15px;
  backdrop-filter: blur(6px);
}
.status.online { color: #7ff0ae; }
.status.reconnect { color: #ffcf73; }
.status.offline { color: #c3ccd5; }

.zoom {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 12px;
  background: rgba(14, 20, 27, 0.78);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(6px);
}
.zoom button {
  min-width: 56px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}
.zoom button[aria-pressed="true"] { background: #fff; color: #000; }

/* Poruka preko videa (offline / ponovno povezivanje) */
.video-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
  background: rgba(10, 14, 19, 0.6);
}
.video-msg strong { font-size: 22px; }
.video-msg span { color: var(--text-soft); font-size: 15px; }
.video-msg.solid { background: var(--bg); }
.video-msg[hidden] { display: none; }
.overlay-top, .overlay-bottom { z-index: 2; }

/* --- Desna 1/3 --- */
.side {
  display: grid;
  grid-template-rows: 1fr 1fr;
  min-height: 0;
  border-left: 1px solid var(--line);
}

/* Telemetrija (gornja polovina) */
.telemetry {
  min-height: 0;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 8px;
  background: var(--panel);
}
.t-item {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--panel-2);
}
.t-label {
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
}
.t-value {
  font-size: clamp(16px, 2.6vh, 26px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t-value small { font-size: 0.6em; font-weight: 600; color: var(--text-soft); margin-left: 3px; }
.t-value.alert { color: var(--danger); }
.t-value.armed { color: var(--warn); }

/* Mapa (donja polovina) */
.map {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: #1c2733;
}
.map svg { width: 100%; height: 100%; display: block; }
.map-attrib {
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-size: 10px;
  color: rgba(233, 238, 243, 0.55);
}

/* ==========================================================
   4. SNIMCI
   ========================================================== */
.records {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}
.records h1 { font-size: 28px; margin: 0 0 6px; }
.records .lead { color: var(--text-soft); margin: 0 0 24px; }
.rec-list { display: flex; flex-direction: column; gap: 12px; }
.rec {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
}
.rec-title { font-size: 19px; font-weight: 700; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.rec-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; color: var(--text-soft); font-size: 15px; font-variant-numeric: tabular-nums; }
.rec-meta b { color: var(--text); font-weight: 600; }
.rec-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* ==========================================================
   OKRENITE TELEFON (posle logina, telefon uspravno)
   ========================================================== */
.rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px;
  text-align: center;
}
.rotate-hint svg { width: 72px; height: 72px; color: #fff; }
.rotate-hint strong { font-size: 22px; }
.rotate-hint span { color: var(--text-soft); line-height: 1.5; max-width: 300px; }

@media (orientation: portrait) and (max-width: 820px) {
  .needs-landscape .rotate-hint { display: flex; }
  body.needs-landscape { overflow: hidden; }
}

/* ==========================================================
   TELEFON HORIZONTALNO (mala visina ekrana)
   ========================================================== */
@media (max-height: 500px) {
  .topbar { height: 52px; padding: 0 16px; }
  .menu { padding: 20px 16px; }
  .tile { min-height: 0; padding: 18px; gap: 18px; }
  .tile h2 { font-size: 22px; }
  .tile-icon { width: 34px; height: 34px; }
  .menu-logout { margin-top: 16px; }
  .records { padding: 16px 16px 32px; }
  .records h1 { font-size: 22px; }
  .rec { padding: 12px 16px; }
  .rec-title { font-size: 16px; margin-bottom: 4px; }
  .rec-meta { font-size: 13px; }

  .telemetry { padding: 8px; gap: 5px; }
  .t-item { padding: 2px 8px; border-radius: 6px; }
  .t-label { font-size: 10px; }
  .t-value { font-size: 15px; }
  .btn-back { top: 8px; left: 8px; height: 34px; font-size: 14px; }
  .overlay-top { top: 8px; }
  .overlay-bottom { bottom: 8px; }
  .status { height: 30px; font-size: 13px; padding: 0 12px; }
  .zoom button { min-width: 44px; height: 32px; font-size: 14px; }
}

/* ==========================================================
   DODACI ZA PRAVU APLIKACIJU (jedna stranica, vise prikaza)
   ========================================================== */
.view[hidden] { display: none !important; }
.view.page { min-height: 100vh; min-height: 100dvh; }

.msg-info {
  margin-top: 14px;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.45;
}

.btn[disabled], .btn.cekanje {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}

.video-frame video { background: #000; }

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.18);
  border-top-color: #fff;
  animation: okret 0.9s linear infinite;
}
@keyframes okret { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.map-prazno {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Mapa (MapLibre + OpenFreeMap) ---------- */
#mapa-platno { position: absolute; inset: 0; }
.map-prazno[hidden] { display: none !important; }
.map .map-prazno {
  z-index: 2;
  pointer-events: none;
}
.map.ima-mapu .map-prazno {
  inset: auto 0 auto 0;
  top: 10px;
  bottom: auto;
  padding: 0;
}
.map.ima-mapu .map-prazno span {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 14px;
  background: rgba(14, 20, 27, 0.82);
  color: var(--text);
  font-size: 13px;
}
.map-prati {
  position: absolute;
  z-index: 3;
  right: 10px;
  bottom: 28px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(14, 20, 27, 0.85);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.map-prati[hidden] { display: none; }
.map-dron {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
}
.map-dron svg { width: 26px; height: 26px; }
.map-home {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #000;
  border: 2.5px solid #fff;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.t-value .t-sub { font-size: 0.55em; font-weight: 600; color: var(--text-soft); margin-left: 6px; }
@media (max-height: 500px) {
  .map-prati { height: 30px; font-size: 12px; bottom: 22px; right: 6px; }
  .map-dron { width: 32px; height: 32px; }
  .map-dron svg { width: 20px; height: 20px; }
}

/* Poslednja poznata pozicija (dron nije povezan) */
.map-dron.zastarelo { background: rgba(120, 130, 140, 0.25); }
.map-dron.zastarelo svg path { fill: #8a96a3; }

/* Zoom se prikazuje samo dok video radi */
.zoom[hidden] { display: none !important; }

/* IBM Plex je visi od sistemskog fonta: zbijeniji redovi u telemetriji */
.t-label { line-height: 1.2; }
.t-value { line-height: 1.15; }
@media (max-height: 500px) {
  .telemetry { gap: 4px; padding: 6px 8px; }
  .t-item { padding: 1px 8px; }
  .t-label { font-size: 10px; }
  .t-value { font-size: 14px; }
}
.t-value { -webkit-text-stroke: 0.5px currentColor; } .t-label { font-weight: 500; color: #c3cfe0; }

/* ==========================================================
   TAJMER LETA I FOTOGRAFIJA (verzija 2)
   ========================================================== */
.status-vreme {
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.status-vreme::before { content: "·"; margin: 0 8px 0 0; color: rgba(255,255,255,0.5); }
.status-vreme[hidden] { display: none; }

.btn-foto {
  position: absolute;
  right: 14px;
  bottom: 16px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(14, 20, 27, 0.78);
  backdrop-filter: blur(6px);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.btn-foto svg { width: 22px; height: 22px; flex: none; }
.btn-foto:hover { border-color: rgba(255,255,255,0.5); }
.btn-foto:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.btn-foto[hidden] { display: none; }
.btn-foto:disabled { cursor: default; }
.btn-foto.ceka, .btn-foto.snima { color: #ffcf73; }
.btn-foto.sacuvano { color: #7ff0ae; }
.btn-foto.neuspeh { color: #ff8a8a; }

/* Meni: tri kartice */
.menu-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 700px) and (min-height: 501px) { .menu-grid { grid-template-columns: 1fr; } }

/* Galerija fotografija */
.records { width: 100%; }
.foto-lista {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.foto-lista .rec-empty { grid-column: 1 / -1; }
.foto-kartica {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}
.foto-slika { display: block; background: #000; aspect-ratio: 16 / 9; }
.foto-slika img { display: block; width: 100%; height: 100%; object-fit: cover; }
.foto-info { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; }
.foto-info .rec-title { font-size: 17px; margin: 0; }
.foto-info .rec-meta { font-size: 14px; }
.foto-info .btn { height: 42px; }

@media (max-height: 500px) {
  .btn-foto { right: 8px; bottom: 8px; height: 40px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
  .btn-foto svg { width: 18px; height: 18px; }
  .status-vreme::before { margin-right: 6px; }
  .foto-lista { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
  .foto-info { padding: 10px 12px 12px; gap: 8px; }
  .foto-info .rec-title { font-size: 15px; }
  .foto-info .rec-meta { font-size: 12px; }
  .foto-info .btn { height: 36px; font-size: 14px; }
}

/* Ocena "Video signal" (pragovi su u app.js, SIGNAL_PRAGOVI_DBM) */
.t-value.signal-odlican { color: #7ff0ae; }
.t-value.signal-dobar { color: #ffcf73; }
.t-value.signal-los { color: #ff8a8a; }
