/* Lauka režīms (fieldmode): kartes poga, statusa josla un bezsaistes baneris. */

/* Vispārīga kartes pogas kaste (saskan ar .geo-btn stilu styles.css) */
.map-btn {
  background: var(--paper, #f6f4ee); border: 1px solid var(--line, #ddd8c8); border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12); overflow: hidden;
}
.map-btn button {
  border: none; background: none; width: 34px; height: 34px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink, #22301f); cursor: pointer;
  transition: background .12s, color .12s;
}
.map-btn button:hover { background: var(--paper-2, #efece2); }
@media (prefers-reduced-motion: reduce) {
  .map-btn button { transition: none; }
}

/* Lauka pogas stāvokļi: izslēgts / seko pozīcijai / seko, bet karte netiek pārcelta */
.field-btn button svg { width: 18px; height: 18px; }
.field-btn[data-state="following"] button {
  background: var(--green-bright, #2e7d5b); color: #fff;
}
.field-btn[data-state="watching"] button {
  color: var(--green-bright, #2e7d5b);
}
.field-btn[data-state="watching"] button svg { opacity: .85; }

/* Statusa josla apakšā, karte centrā virs attribution - lai nepārklātos ar leģendu (apakšā
   kreisajā) un zoom pogām (apakšā labajā) */
.field-status {
  position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); z-index: 1001;
  background: rgba(246, 244, 238, .95); border: 1px solid var(--line, #ddd8c8);
  border-radius: 8px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  color: var(--ink, #22301f); box-shadow: 0 2px 10px rgba(0, 0, 0, .1);
  max-width: min(420px, calc(100% - 160px)); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.field-status.field-inside { color: var(--green, #1e4d3b); border-color: var(--green-bright, #2e7d5b); }
.field-status.field-error { color: var(--red, #b3402e); border-color: var(--red, #b3402e); }

/* Bezsaistes baneris - pašā kartes augšā, tāpat kā .demo-banner apakšā redzamais joslas paņēmiens */
.field-offline {
  position: absolute; top: 8px; left: 8px; right: 8px; z-index: 1001;
  background: var(--gold, #b99649); color: #fff; text-align: center;
  padding: 7px 10px; font-size: 13px; font-weight: 600; border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}

/* Bezsaistē kartes flīzes nerāda (nedrīkst kešot) - balts fons, redzamas tikai robežas */
body.zp-offline .leaflet-tile-pane { display: none; }
body.zp-offline .leaflet-container { background: #fff; }

/* Zilais pozīcijas punkts un precizitātes aplis */
.field-pos-dot { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35)); }
@media (prefers-reduced-motion: no-preference) {
  .field-pos-dot { transition: transform .25s ease-out; }
}
@media (prefers-reduced-motion: reduce) {
  .field-pos-dot { transition: none; }
}

/* Mobilais (390 px un šaurāks) */
@media (max-width: 390px) {
  .field-status {
    left: 6px; right: 6px; bottom: 22px; transform: none; max-width: none;
    font-size: 12.5px; padding: 6px 10px; white-space: normal;
  }
  .field-offline { left: 6px; right: 6px; font-size: 12.5px; padding: 6px 8px; }
  .map-btn button { width: 38px; height: 38px; }
}

/* ==================== C2: apakšējā izvelkamā lapa (bottom sheet, <=768 px) ====================
   3 stāvokļi (data-state uz .field-sheet): collapsed (statusa rinda + grip), half, full
   (ritināms saturs). Uz platākiem ekrāniem (desktop) lapa netiek rādīta - paliek esošā .field-status
   "pill" un .field-btn poga bez izmaiņām. */

.field-sheet {
  display: none; position: absolute; left: 0; right: 0; bottom: 0; z-index: 1003;
  background: var(--paper, #f6f4ee); border-top: 1px solid var(--line, #ddd8c8);
  border-radius: 16px 16px 0 0; box-shadow: 0 -4px 18px rgba(0, 0, 0, .18);
  flex-direction: column; touch-action: none; overflow: hidden;
}
@media (prefers-reduced-motion: no-preference) {
  .field-sheet { transition: height .22s ease-out; }
}
.field-sheet.dragging { transition: none; }

.field-sheet-grip {
  flex: none; padding: 10px 0 8px; display: flex; align-items: center; justify-content: center;
  cursor: grab; touch-action: none;
}
.field-sheet-grip::before {
  content: ""; width: 40px; height: 4px; border-radius: 2px; background: var(--line, #ddd8c8);
}
.field-sheet-status {
  flex: none; padding: 0 16px 10px; font-weight: 700; font-size: 14px; color: var(--ink, #22301f);
}
.field-sheet-status.field-inside { color: var(--green, #1e4d3b); }
.field-sheet-status.field-error { color: var(--red, #b3402e); }

.field-sheet-body {
  flex: 1 1 auto; overflow-y: auto; padding: 0 16px 16px; -webkit-overflow-scrolling: touch;
}
.field-sheet[data-state="collapsed"] { height: auto; }
.field-sheet[data-state="collapsed"] .field-sheet-body { display: none; }
.field-sheet[data-state="half"] { height: 46vh; }
.field-sheet[data-state="full"] { height: 86vh; }

.fs-name { font-family: var(--font-head, inherit); font-size: 16px; font-weight: 700; color: var(--ink, #22301f); }
.fs-meta { font-size: 12.5px; color: var(--ink-soft, #5c6a58); margin-top: 2px; }
.fs-chips { margin-top: 6px; }
.fs-chip {
  display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px;
  background: var(--paper-2, #efece2); color: var(--ink, #22301f);
}
.fs-chip.active { background: #e3f3ea; color: var(--green, #1e4d3b); }
.fs-chip.expiring, .fs-chip.upcoming { background: #fbe9d6; color: #8a4d10; }
.fs-chip.expired { background: #f1e3e0; color: var(--red, #b3402e); }
.fs-chip.vacant { background: var(--paper-2, #efece2); color: var(--ink-soft, #5c6a58); }
.fs-lease { font-size: 12.5px; margin-top: 4px; }
.fs-sub-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
  color: var(--ink-soft, #5c6a58); margin: 12px 0 6px; }
.fs-stand {
  display: flex; flex-wrap: wrap; gap: 2px 8px; padding: 7px 0; border-bottom: 1px dashed var(--line, #ddd8c8);
  cursor: pointer;
}
.fs-stand:last-of-type { border-bottom: none; }
.fs-stand-title { font-weight: 700; font-size: 13px; }
.fs-stand-desc { font-size: 12.5px; color: var(--ink-soft, #5c6a58); }
.fs-stand-vol { font-size: 12.5px; color: var(--ink-soft, #5c6a58); margin-left: auto; }
.fs-lad { font-size: 13px; padding: 6px 0; }

.field-sheet-actions { display: flex; gap: 8px; margin-top: 14px; }
.field-sheet-actions button { flex: 1; position: relative; }
.field-sheet-actions button:disabled { opacity: .5; cursor: default; }
.field-note-badge {
  position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 9px; background: var(--red, #b3402e); color: #fff; font-size: 10.5px; font-weight: 700;
  line-height: 16px; text-align: center;
}

.field-sheet-noteform { margin-top: 12px; }
.field-note-msg { font-size: 12.5px; margin-top: 6px; color: var(--ink-soft, #5c6a58); }

/* Piezīmju/foto saraksts (arī Vēstures cilnē, card.js - card.css nav šī uzdevuma darbības jomā,
   tāpēc stili turēti šeit) */
.note-row {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--line, #ddd8c8);
}
.note-row:last-of-type { border-bottom: none; }
.note-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex: none; }
.note-body { flex: 1; min-width: 0; }
.note-meta { font-size: 12px; color: var(--ink-soft, #5c6a58); }
.note-text { font-size: 13px; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }

body.role-viewer .field-btn-note,
body.role-viewer #notes-form-slot { display: none !important; }

/* Mobilais (<=768 px): lapa rādās, vecā "pill" un bezsaistes baneris pārceļas augšpusē/pazūd,
   lai neklātos ar lapu apakšā. */
@media (max-width: 768px) {
  .field-sheet { display: flex; }
  .field-status { display: none; }
}
