/* ---------------------------------------------------------------- tlacitka */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, transform 80ms ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: 3px solid var(--amber-500);
  outline-offset: 2px;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn--secondary {
  background: var(--surface-2);
  border-color: var(--border);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
}

.btn--danger {
  background: var(--danger-100);
  color: var(--on-danger-tint);
  border-color: transparent;
}

.btn--block {
  width: 100%;
}

.btn--compact {
  min-height: 38px;
  padding: 0 var(--space-3);
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.icon-btn:active {
  background: rgba(127, 127, 127, 0.18);
}

.icon-btn:focus-visible {
  outline: 3px solid var(--amber-500);
  outline-offset: -3px;
}

.icon-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fab {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-2);
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.2, 0, 0, 1);
}

.fab:active {
  transform: scale(0.94);
}

.fab svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.fab.is-open svg {
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

.fab-mini {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-3) 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-2);
  cursor: pointer;
  white-space: nowrap;
}

.fab-mini span.dot {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--forest-100);
  color: var(--on-forest-tint);
  font-size: 0.8rem;
}

.fab-mini img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

/* ----------------------------------------------------------------- karty */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.stat {
  flex: none;
  min-width: 84px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-1);
  text-align: center;
}

.stat b {
  display: block;
  font-family: var(--font-numeric);
  font-size: 1.06rem;
  line-height: 1.2;
}

.stat small {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --------------------------------------------------------------- seznamy */

.record-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.record {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 64px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.record:focus-visible {
  outline: 3px solid var(--amber-500);
  outline-offset: 2px;
}

.record.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.record.is-done {
  opacity: 0.62;
}

.record h4 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 650;
}

.record p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.record-badge {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--species-color, var(--forest-500)) 18%, var(--surface));
  overflow: hidden;
}

.record-badge img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.record-badge.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.record-value {
  font-family: var(--font-numeric);
  font-size: 0.95rem;
  font-weight: 650;
  white-space: nowrap;
}

.empty-state {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--text-muted);
}

.empty-state strong {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--text);
}

/* ---------------------------------------------------------------- pilulky */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  font-size: 0.74rem;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
}

.pill.is-done {
  background: var(--forest-100);
  color: var(--on-forest-tint);
}

.pill.is-warn {
  background: var(--amber-100);
  color: var(--on-amber-tint);
}

.pill.is-danger {
  background: var(--danger-100);
  color: var(--on-danger-tint);
}

.pill .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--swatch, var(--forest-500));
}

/* --------------------------------------------------------------- formulare */

.field {
  display: block;
  margin-bottom: var(--space-3);
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font: inherit;
  color: var(--text);
  background: var(--surface);
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 3px solid var(--amber-500);
  outline-offset: -1px;
  border-color: var(--accent);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.field-hint {
  margin: -6px 0 var(--space-3);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.field-error {
  margin: -6px 0 var(--space-3);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--danger-600);
}

/* Prepinac mezi prumerem a obvodem. */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface-2);
  margin-bottom: var(--space-3);
}

.segmented button {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-weight: 650;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.photo-field input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-drop {
  display: grid;
  place-items: center;
  gap: var(--space-2);
  min-height: 132px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2) center / cover no-repeat;
  color: var(--text-muted);
  font-weight: 650;
  cursor: pointer;
  text-align: center;
  padding: var(--space-3);
}

.photo-drop.has-image {
  color: #ffffff;
  border-style: solid;
  border-color: transparent;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.photo-drop svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.estimate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  border-radius: var(--radius);
  background: var(--forest-100);
  color: var(--on-forest-tint);
  font-weight: 650;
}

.estimate b {
  font-family: var(--font-numeric);
  font-size: 1.2rem;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.form-actions .btn--block {
  grid-column: 1 / -1;
}

/* ------------------------------------------------------------------ taby */

.tab {
  flex: none;
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  font: inherit;
  font-weight: 650;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
}

.tab.is-active {
  background: var(--forest-700);
  color: var(--text-inverse);
}

.tab:focus-visible {
  outline: 3px solid var(--amber-500);
  outline-offset: 2px;
}

/* --------------------------------------------------------------- drawer */

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.is-active {
  background: var(--forest-100);
  color: var(--on-forest-tint);
}

.nav-item svg {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item .trail {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border-radius: var(--radius);
  cursor: pointer;
}

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

.switch-row input {
  flex: none;
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.switch-row .label {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.switch-row .label small {
  display: block;
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.account-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--forest-600);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  flex: none;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------------------------------------------------------------- bannery */

.banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  font-size: 0.88rem;
}

.banner.is-warn {
  background: var(--amber-100);
  color: var(--on-amber-tint);
}

.banner.is-info {
  background: var(--forest-100);
  color: var(--on-forest-tint);
}

.banner .grow {
  flex: 1;
  min-width: 0;
}

.banner strong {
  display: block;
}

.toast {
  pointer-events: auto;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--surface-inverse);
  color: var(--text-inverse);
  box-shadow: var(--shadow-3);
  font-size: 0.9rem;
  font-weight: 600;
  animation: toast-in 180ms ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.progress {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 160ms ease;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--forest-300);
  flex: none;
}

.status-dot.is-offline {
  background: var(--amber-300);
}

.status-dot.is-error {
  background: var(--danger-500);
}

/* --------------------------------------------------------- znacky v mape */

.map-pin {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 2px solid var(--pin-color, var(--forest-500));
  box-shadow: var(--shadow-1);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text);
}

.map-pin img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.map-pin.is-selected {
  outline: 3px solid var(--amber-500);
  outline-offset: 1px;
  transform: scale(1.12);
}

.map-pin.is-processed {
  opacity: 0.62;
  filter: grayscale(0.55);
}

.pile-pin {
  background: var(--amber-500);
  border-color: #fff;
  color: #2b1a04;
}

.pending-pin {
  background: var(--amber-300);
  border-color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.14);
  }
}

.draw-vertex {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: #fff;
  border: 2px solid var(--amber-500);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--amber-600);
  box-shadow: var(--shadow-1);
}

.draw-vertex.is-last {
  background: var(--amber-500);
  color: #fff;
}

/* --------------------------------------------------------------- legenda */

.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.82rem;
}

.legend-swatch {
  width: 22px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  flex: none;
}

.legend-row .count {
  margin-left: auto;
  font-family: var(--font-numeric);
  color: var(--text-muted);
}

/* ---------------------------------------------------------------- detail */

.detail-photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 0;
  padding: 0;
  cursor: zoom-in;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.metric {
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  text-align: center;
}

.metric b {
  display: block;
  font-family: var(--font-numeric);
  font-size: 1.06rem;
}

.metric span {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.detail-actions .btn {
  flex: 1 1 40%;
}

/* ------------------------------------------------------- prohlizec fotky */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  background: rgba(6, 12, 8, 0.94);
  padding: var(--space-4);
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox .icon-btn {
  position: absolute;
  top: calc(var(--space-3) + var(--safe-top));
  right: var(--space-3);
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
}

/* -------------------------------------------------------- import z fotek */

.import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--space-2);
}

.import-tile {
  position: relative;
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  padding: 0;
  cursor: pointer;
}

.import-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.import-tile.is-selected {
  border-color: var(--accent);
}

.import-tile.no-gps {
  opacity: 0.55;
}

.import-tile .flag {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
}

.import-tile .check {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.72rem;
  font-weight: 700;
}

/* ------------------------------------------------------------- pomocnici */

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stack-lg {
  gap: var(--space-4);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.muted {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.section-title {
  margin: var(--space-4) 0 var(--space-2);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.divider {
  height: 1px;
  margin: var(--space-3) 0;
  background: var(--border);
  border: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------- ovladani mapy Leaflet */

/*
  Spodni panel prekryva spodni cast mapy, takze ovladani zoomu i podpis
  zdroje musime zvednout nad nej. Vyska panelu se meni tazenim, proto se
  ridime toutez promennou.
*/
.leaflet-bottom {
  bottom: var(--sheet-height, 42vh);
  transition: bottom 220ms cubic-bezier(0.2, 0, 0, 1);
}

@media (min-width: 900px) {
  .leaflet-bottom {
    bottom: 0;
  }
}

.leaflet-control-zoom a {
  width: 42px;
  height: 42px;
  line-height: 42px;
  font-size: 1.3rem;
  color: var(--text);
  background: var(--surface);
  border-bottom-color: var(--border);
}

.leaflet-control-zoom a:hover,
.leaflet-control-zoom a:focus {
  background: var(--surface-2);
  color: var(--text);
}

.leaflet-bar {
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}

.leaflet-control-attribution {
  padding: 2px 8px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--text-muted);
  font-size: 0.68rem;
  border-radius: var(--radius-sm) 0 0 0;
}

.leaflet-control-attribution a {
  color: var(--text-muted);
}

/* Leaflet kresli popisky svetle, na tmavem podkladu by zmizely. */
.leaflet-container {
  background: var(--surface-2);
  font-family: var(--font);
}

/* ----------------------------------------------------- legendy vrstev */

.legend-box {
  margin: 0 var(--space-3) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.legend-box summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-muted);
  cursor: pointer;
}

.legend-box[open] summary {
  border-bottom: 1px solid var(--border);
}

/*
  Legendy z WMS jsou obrazky s pevnou sirkou a nekdy pres tisic pixelu
  na vysku, takze potrebuji vlastni posuvnik. Bily podklad je nutny:
  vetsina legend ma cerny text na pruhlednem pozadi, ktery by v tmavem
  rezimu zmizel.
*/
.legend-image {
  max-height: 260px;
  overflow: auto;
  padding: var(--space-2);
  background: #ffffff;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.legend-image img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Latinsky nazev dreviny v detailu. Kurziva je u botanickych jmen zvykem. */
.species-latin {
  margin: -6px 0 0;
  font-style: italic;
}
