/* ============================================================
   AZYMATOR – nowy układ (ciemny, zdjęcie na pierwszym planie)
   Strona: OgrafAzymator.html, wersja 3.45.88
   Stary układ (OgrafFotka.html + AzymutStyle.css) działa bez zmian.

   Spis treści:
     1. Zmienne kolorów i podstawy
     2. Pasek górny
     3. Obszar roboczy: szyna, scena, widoki
     4. Panele wysuwane z szyny
     5. Formularze i przyciski
     6. Tabele
     7. Zdjęcie: pasek zoomu, kanwa, tooltip
     8. Mapa
     9. Refrakcja i radiosonda
    10. Modal, powiadomienie, ikona pomocy
    11. Telefon / wąski ekran
   ============================================================ */


/* ============================================================
   1. ZMIENNE KOLORÓW I PODSTAWY
   Wszystkie kolory pochodzą ze zmiennych, więc jasny motyw
   to później tylko druga lista wartości.
   ============================================================ */
:root {
  --bg: #14171c;
  --surface: #1d2229;
  --surface-2: #242b34;
  --rail: #181c22;
  --canvas-bg: #0d1014;
  --border: #2a313b;
  --border-strong: #3a4452;
  --text: #e6e9ee;
  --text-soft: #c9d0da;
  --muted: #9aa4b2;
  --accent: #4fd1e5;
  --accent-ink: #0d1a1d;
  --accent-soft: #26303b;
  --danger: #f08a8a;
  --danger-bg: #3a2326;
  --radius: 10px;
  --rail-w: 56px;
  --topbar-h: 48px;
  --panel-w: 380px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body.app {
  height: 100%;
}

body.app {
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

h2 { font-size: 1rem; }
h3 { font-size: 0.95rem; }

a { color: var(--accent); }

small { color: var(--muted); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ============================================================
   2. PASEK GÓRNY
   ============================================================ */
.topbar {
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 800;
}

.topbar-spacer { flex-grow: 1; }

.brand {
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.brand span {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.view-switch {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}

.view-switch button {
  border: 0;
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  padding: 7px 16px;
}

.view-switch button:hover {
  background: var(--surface-2);
}

.view-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 4px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
  opacity: 0.75;
}

/* Menu serwisu (dawne linki nagłówka) */
.site-menu {
  position: relative;
}

.site-menu summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-soft);
}

.site-menu summary::-webkit-details-marker { display: none; }
.site-menu summary:hover { background: var(--surface-2); }

.site-menu ul {
  position: absolute;
  top: 40px;
  left: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

.site-menu li a {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.site-menu li a:hover { background: var(--surface-2); }


/* ============================================================
   3. OBSZAR ROBOCZY: SZYNA, SCENA, WIDOKI
   ============================================================ */
.workspace {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
}

.rail {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--rail-w);
  z-index: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 10px;
  background: var(--rail);
  border-right: 1px solid var(--border);
}

.rail-btn {
  width: 48px;
  padding: 8px 0 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.rail-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.rail-btn[aria-expanded="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.stage {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: var(--rail-w);
}

/* Przypięty panel zmniejsza scenę (zdjęcie nie jest zasłonięte) */
.workspace.is-docked .stage {
  left: calc(var(--rail-w) + var(--dock-w, 0px));
}

/* Oba widoki leżą jeden na drugim. Ukryty ma visibility:hidden (nie display:none),
   dzięki czemu mapa Leaflet zachowuje swój rozmiar. */
.view {
  position: absolute;
  inset: 0;
  visibility: hidden;
}

.view.is-active {
  visibility: visible;
}

/* Mapa jest zawsze widoczna: w widoku zdjęcia jako miniatura w rogu (z nakładką, która
   przechwytuje kliknięcia i powiększa mapę), w widoku mapy na całą scenę. */
.view-map {
  visibility: visible;
}

.workspace[data-view="photo"] .view-map {
  inset: auto 16px 16px auto;
  width: 260px;
  height: 190px;
  z-index: 600;
  border: 2px solid var(--accent);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

.workspace[data-view="photo"] .view-map .leaflet-control-container {
  display: none;
}

.mini-cover {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 10;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

.mini-cover:hover { background: rgba(79, 209, 229, 0.12); }

.workspace[data-view="photo"] .mini-cover { display: block; }

/* Przycisk ukrywania miniatury (nad nakładką) i przycisk jej przywracania */
.mini-hide {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 20;
  display: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  background: rgba(13, 16, 20, 0.85);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
}

.mini-hide:hover { background: #000; border-color: var(--accent); }

.workspace[data-view="photo"] .mini-hide { display: block; }

.mini-show {
  display: none;
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 600;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.workspace[data-view="photo"][data-mini="hidden"] .mini-show { display: flex; align-items: center; justify-content: center; }

/* Ukryta miniatura zachowuje rozmiar (visibility), żeby mapa Leaflet go nie traciła */
.workspace[data-view="photo"][data-mini="hidden"] .view-map {
  visibility: hidden;
  pointer-events: none;
}

.mini-cover span,
.mini-thumb span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #0d1014;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

/* Miniatura zdjęcia w widoku mapy (nad atrybucją Leaflet w prawym dolnym rogu) */
.mini-thumb {
  display: none;
  position: absolute;
  right: 16px;
  bottom: 36px;
  z-index: 600;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--accent);
  border-radius: 12px;
  background: var(--canvas-bg);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

.mini-thumb canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 360px;
  cursor: pointer;
}

.workspace[data-view="map"] .mini-thumb { display: block; }
.workspace[data-view="map"] #viewPhoto { visibility: hidden; }


/* ============================================================
   4. PANELE WYSUWANE Z SZYNY
   ============================================================ */
.panel {
  position: absolute;
  top: 10px;
  left: calc(var(--rail-w) + 10px);
  bottom: 10px;
  width: var(--panel-w);
  max-width: calc(100% - var(--rail-w) - 20px);
  z-index: 750;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

.panel[hidden] { display: none; }

/* Panel przypięty przylega do szyny i nie zasłania sceny */
.workspace.is-docked .panel:not([hidden]) {
  top: 0;
  left: var(--rail-w);
  bottom: 0;
  border-radius: 0;
  box-shadow: none;
  border-width: 0 1px 0 0;
}

.panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 { flex-grow: 1; }

.panel-head button {
  padding: 4px 10px;
  font-size: 12px;
  background: transparent;
  color: var(--muted);
  border-color: var(--border-strong);
}

.panel-head button:hover { color: var(--text); background: var(--surface-2); }

.panel-head button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.panel-head .panel-close {
  font-size: 18px;
  line-height: 1;
  padding: 2px 9px;
}

.panel-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 14px 16px 18px;
}

.field-block {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 14px;
}

.field-block > label {
  flex: 1 0 100%;
  color: var(--text-soft);
  font-size: 13px;
}

.inline-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.help-line {
  margin: 0 0 12px;
  color: var(--text-soft);
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 12px;
}

.sekcja_inne {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.sekcja-ramka {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--bg);
}

.table-box > p {
  margin: 14px 0 0;
  font-weight: 600;
}


/* ============================================================
   5. FORMULARZE I PRZYCISKI
   ============================================================ */
input, select, button, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.4em 0.7em;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
}

input::placeholder { color: var(--muted); opacity: 0.8; }

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

input:disabled { background: var(--bg); color: var(--muted); }

input[type="radio"], input[type="checkbox"] {
  padding: 0;
  accent-color: var(--accent);
}

input[type="number"] { font-variant-numeric: tabular-nums; }

input[type="file"] {
  max-width: 100%;
  padding: 6px;
}

button {
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

button:hover {
  background: #2d3640;
  border-color: #4a5668;
}

.button, .close-btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  font-weight: 600;
  padding: 8px 18px;
}

.button:hover, .close-btn:hover {
  background: #7fe0f0;
  border-color: #7fe0f0;
}

.button-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.button-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.removeRowButton {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger-bg);
  padding: 4px 10px;
}

.removeRowButton:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.przegladaj-button {
  background: var(--bg);
  color: var(--text-soft);
  border: 1px dashed var(--border-strong);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.controls input[type="text"] { flex: 1 1 140px; min-width: 0; }

.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  color: var(--text-soft);
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 8px 12px;
  align-items: center;
  margin: 8px 0;
  color: var(--text-soft);
}

.form-grid input { width: 100%; }

.rotate-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--text-soft);
}

.rotate-controls input[type="number"] { width: 90px; }
.rotate-controls .radio-row { margin-bottom: 0; }

.waypoints-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}


/* ============================================================
   6. TABELE
   ============================================================ */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 0.6em;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

th, td {
  border: 1px solid var(--border);
  padding: 0.4em 0.6em;
  text-align: right;
}

th {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  text-align: center;
}

tr:nth-child(even) td { background: rgba(255, 255, 255, 0.025); }
tr:hover td { background: rgba(79, 209, 229, 0.08); }

#base-point-table input[type="number"],
#marker-data-table input[type="number"],
#azimuthTableBody input[type="number"] {
  width: 96px;
  padding: 4px 6px;
  margin: 0;
  display: block;
}

#pointReportBox summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

#pointReportBox .button { margin-top: 10px; }

#pointReportNote {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}


/* ============================================================
   7. ZDJĘCIE: PASEK ZOOMU, KANWA, TOOLTIP
   ============================================================ */
.photo-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--rail);
  border-bottom: 1px solid var(--border);
}

.zoom-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.zoom-controls button { min-width: 2.4em; padding: 3px 10px; }

#zoomLabel {
  min-width: 3.5em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

.zoom-hint {
  color: var(--muted);
  font-size: 12px;
}

/* Ramka nie może być na samym canvasie (border) – wliczałaby się do
   getBoundingClientRect() i przesuwała współrzędne kliknięć. Dlatego outline. */
canvas {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
  border: 0;
  cursor: crosshair;
}

/* Wrapper przewija się w obu osiach; stały pasek zapobiega migotaniu rozmiaru
   przy pojawianiu się paska przewijania */
#canvasWrapper {
  position: absolute;
  top: 44px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  background: var(--canvas-bg);
}

#tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.88);
  color: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  padding: 4px 8px;
}


/* ============================================================
   8. MAPA
   ============================================================ */
#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  z-index: 0;   /* osobny kontekst warstw: elementy Leaflet nie wchodzą nad miniatury */
}


/* ============================================================
   9. REFRAKCJA I RADIOSONDA
   ============================================================ */
.refraction-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.refraction-fieldset {
  margin: 12px 0 0;
  padding: 10px 14px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.refraction-fieldset legend {
  padding: 0 6px;
  font-weight: 600;
  color: var(--text);
}

.radiosonde-box {
  display: grid;
  gap: 8px;
  margin: 6px 0 0;
}

.radiosonde-box p { margin: 0; font-size: 0.9rem; color: var(--text-soft); }
.radiosonde-box .button { justify-self: start; }

.layer-top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
}

.layer-top-row input[type="number"] { width: 90px; }

/* Wykres profilu radiosondy (obramowanie przez outline, jak przy kanwie) */
#sondeProfileCanvas {
  width: 100%;
  max-width: 640px;
  height: auto;
  cursor: default;
  outline: 1px solid var(--border);
  background: #fff;
}

.sonde-profile-info {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}


/* ============================================================
   10. MODAL, POWIADOMIENIE, IKONA POMOCY
   ============================================================ */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--surface);
  color: var(--text);
  padding: 24px;
  max-width: 420px;
  margin: 16px;
  text-align: center;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-content p { margin-top: 0; }

.notification {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 14px 22px;
  max-width: 90vw;
  font-size: 15px;
  font-weight: 500;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: none;
  opacity: 0;
  z-index: 11000;
  transition: opacity 0.5s ease;
}

.notification.show {
  display: block;
  opacity: 1;
}

.help-icon {
  display: inline-block;
  color: var(--accent);
  margin-left: 5px;
  cursor: pointer;
}

.help-icon::before {
  content: "?";
  display: inline-block;
  width: 1.3em;
  height: 1.3em;
  line-height: 1.3em;
  text-align: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  font-style: normal;
  font-weight: bold;
  font-size: 0.9em;
}


/* ============================================================
   11. TELEFON / WĄSKI EKRAN
   ============================================================ */
@media (max-width: 800px) {
  .brand span, .zoom-hint { display: none; }
  .brand { display: none; }
  .view-switch button { padding: 7px 10px; }
  .topbar-actions { gap: 4px; }

  .topbar { gap: 8px; padding: 0 8px; }

  .topbar-actions button { padding: 6px 8px; font-size: 12px; }

  /* Na wąskim ekranie panel zajmuje całą scenę (bez przypinania) */
  .panel {
    left: calc(var(--rail-w) + 4px);
    right: 4px;
    width: auto !important;
    max-width: none;
  }

  .workspace.is-docked .stage { left: var(--rail-w); }
  .workspace.is-docked .panel:not([hidden]) { left: calc(var(--rail-w) + 4px); }
  .panel-pin { display: none; }
}
