/* =============================================================================
 * NIMOS-Teren PWA — styles.css  [FE]
 * "Šumska tinta" (forest ink) theme. Mobile-first, large touch targets,
 * high contrast for daylight/sun readability. No build step, plain CSS vars.
 * ============================================================================= */

:root {
  /* Forest ink palette — deep greens on a near-white, high-contrast canvas. */
  --ink:        #14231a;   /* primary text (very dark green-black) */
  --ink-soft:   #3a4a40;
  --muted:      #5d6b62;
  --forest:     #1f5132;   /* brand green */
  --forest-dk:  #143a23;
  --forest-lt:  #2e7d4f;
  --bark:       #6b4f2a;
  --bg:         #f4f6f2;   /* paper */
  --surface:    #ffffff;
  --border:     #d4ddd4;
  --line:       #e6ece6;

  /* Severity / status colors (strong, sun-readable). */
  --critical:   #b3261e;
  --high:       #d9730d;
  --medium:     #b8860b;
  --low:        #2e7d4f;
  --info:       #4a6572;
  --ok:         #1f7a3d;
  --error:      #b3261e;
  --warn-bg:    #fdf3da;
  --warn-fg:    #7a5a00;

  --radius: 14px;
  --tap: 52px;               /* minimum touch target height */
  --shadow: 0 2px 8px rgba(20, 35, 26, 0.10);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 17px;             /* larger base for field readability */
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

#nt-app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- status bar (online/offline + queue) --------------------------------- */
#nt-status {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: calc(6px + var(--safe-top)) 14px 6px;
  background: var(--forest-dk); color: #eaf3ec;
  font-size: 13px; font-weight: 600;
  letter-spacing: .2px;
}
.status-left { display: flex; align-items: center; gap: 6px; flex: 1; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-dot.online  { background: #5fd38a; box-shadow: 0 0 0 3px rgba(95,211,138,.25); }
.status-dot.offline { background: #e57373; box-shadow: 0 0 0 3px rgba(229,115,115,.25); }
.status-queue {
  background: rgba(255,255,255,.14); padding: 3px 10px; border-radius: 999px;
}
.status-queue.has-pending { background: var(--high); color: #fff; }
.status-user { opacity: .8; margin-left: 10px; max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- app bar ------------------------------------------------------------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--forest); color: #fff;
  box-shadow: var(--shadow);
}
.appbar-title { font-size: 19px; font-weight: 700; margin: 0; flex: 1; }
.appbar-logo { font-size: 22px; }
.appbar-btn {
  min-width: var(--tap); min-height: 44px;
  background: rgba(255,255,255,.16); color: #fff; border: 0;
  border-radius: 10px; font-size: 22px; line-height: 1; cursor: pointer;
}
.appbar-btn.back { font-size: 28px; font-weight: 700; }

/* ---- main view ----------------------------------------------------------- */
#nt-view { flex: 1; padding: 14px 14px calc(28px + var(--safe-bottom)); max-width: 720px; margin: 0 auto; width: 100%; }

/* ---- cards & lists ------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.list { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.list-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.task-card { cursor: pointer; border-left: 6px solid var(--forest-lt); }
.task-card:active { transform: scale(.995); }
.task-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.task-type { font-weight: 700; font-size: 17px; }
.task-status { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--muted); }
.task-meta { font-size: 14px; color: var(--ink-soft); }
.task-meta.muted { color: var(--muted); }
.task-coords { font-size: 13px; color: var(--bark); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---- badges (severity) --------------------------------------------------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: .4px; color: #fff;
}
.sev-critical { background: var(--critical); }
.sev-high     { background: var(--high); }
.sev-medium   { background: var(--medium); }
.sev-low      { background: var(--low); }
.sev-info     { background: var(--info); }

/* ---- key/value rows ------------------------------------------------------ */
.kv { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); min-width: 42%; font-size: 14px; }
.kv .v { color: var(--ink); font-weight: 600; flex: 1; }

/* ---- buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 18px;
  border: 0; border-radius: 12px; font-size: 17px; font-weight: 700;
  cursor: pointer; user-select: none;
}
.btn:disabled { opacity: .6; }
.btn-block { width: 100%; margin-top: 12px; }
.btn-primary { background: var(--forest); color: #fff; }
.btn-primary:active { background: var(--forest-dk); }
.btn-secondary { background: var(--bark); color: #fff; }
.btn-ghost { background: transparent; color: var(--forest); border: 2px solid var(--forest); }
.fab-row { display: flex; gap: 10px; margin-top: 16px; }
.fab-row .btn { flex: 1; }

/* ---- forms --------------------------------------------------------------- */
.field-label { display: block; font-size: 14px; font-weight: 700; color: var(--ink-soft); margin: 12px 0 6px; }
.field-input {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  font-size: 17px; color: var(--ink);
  background: #fff; border: 2px solid var(--border); border-radius: 12px;
}
.field-input:focus { outline: none; border-color: var(--forest-lt); box-shadow: 0 0 0 3px rgba(46,125,79,.18); }
.field-area { resize: vertical; min-height: 84px; }
.field-select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--forest) 50%), linear-gradient(135deg, var(--forest) 50%, transparent 50%); background-position: calc(100% - 20px) center, calc(100% - 14px) center; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
.field-row { margin-bottom: 4px; }

/* chip group (verification status, big tap chips) */
.btn-group-wrap { margin-bottom: 6px; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 46px; padding: 0 16px; border-radius: 999px;
  border: 2px solid var(--border); background: #fff; color: var(--ink);
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.chip.active { background: var(--forest); color: #fff; border-color: var(--forest); }

/* ---- login --------------------------------------------------------------- */
.login-screen { display: flex; flex-direction: column; gap: 18px; padding-top: 18px; }
.login-brand { text-align: center; }
.login-logo { font-size: 56px; }
.login-title { margin: 6px 0 0; color: var(--forest-dk); font-size: 28px; }
.login-sub { margin: 4px 0 0; color: var(--muted); }
.login-card .field-input { margin-bottom: 12px; }
.login-hint { font-size: 12px; color: var(--muted); margin: 12px 0 0; line-height: 1.5; }

/* ---- map ----------------------------------------------------------------- */
.map-container { height: 280px; border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; border: 1px solid var(--border); }
.map-fallback {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; background: linear-gradient(160deg, #e8efe6, #d8e4d6); color: var(--ink); text-align: center; padding: 16px;
}
.map-fallback-pin { font-size: 40px; }
.map-fallback-title { font-weight: 700; }
.map-fallback-coords { font-variant-numeric: tabular-nums; font-size: 18px; color: var(--forest-dk); }
.map-fallback-link { color: var(--forest); font-weight: 700; margin-top: 6px; }

/* ---- capture / photos ---------------------------------------------------- */
.gps-card { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }
.gps-card.ok { color: var(--forest-dk); border-color: var(--forest-lt); }
.section-title { margin: 16px 0 8px; font-size: 16px; color: var(--ink-soft); }
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.photo-cell { display: flex; flex-direction: column; gap: 4px; }
.photo-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: #eef; }
.photo-thumb.photo-synced { display: flex; align-items: center; justify-content: center; font-size: 28px; color: var(--ok); background: #eaf6ee; }
.photo-meta { font-size: 11px; color: var(--muted); }

/* ---- outbox -------------------------------------------------------------- */
.outbox-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.outbox-type { font-weight: 700; }
.outbox-status { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; color: #fff; }
.outbox-status.ok { background: var(--ok); }
.outbox-status.error { background: var(--error); }
.outbox-status.pending { background: var(--high); }

/* ---- misc states --------------------------------------------------------- */
.empty-state { text-align: center; color: var(--muted); padding: 28px 12px; }
.warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid #e8d49a; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-weight: 600; }
.loading { text-align: center; padding: 30px 0; color: var(--muted); }
.spinner { width: 34px; height: 34px; margin: 0 auto 10px; border: 4px solid var(--line); border-top-color: var(--forest); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- toasts -------------------------------------------------------------- */
.toast-host { position: fixed; left: 0; right: 0; bottom: calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none; padding: 0 14px; }
.toast {
  max-width: 92%; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 15px; font-weight: 600; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { background: var(--ok); }
.toast.error { background: var(--error); }

/* ---- larger screens (tablet) --------------------------------------------- */
@media (min-width: 640px) {
  body { font-size: 17px; }
  .map-container { height: 340px; }
}
