/* GPS → JTSK Tracker — BlueberryS Digital brand */

:root {
  --bg: #000000;
  --surface: #121214;
  --surface-2: #1a1a1f;
  --border: #2a2a31;
  --text: #FFFFFF;
  --text-dim: #A0A0AA;
  --primary: #FF7043;
  --primary-dark: #d95a32;
  --accent: #F2D400;
  --info: #BA68C8;
  --danger: #ef4444;
  --ok: #4ade80;
  --warn: #fbbf24;
  --shadow: 0 6px 24px rgba(0,0,0,.45);
  --radius: 12px;
}

body[data-theme="day"] {
  --bg: #F7F7F8;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --border: #d4d4d8;
  --text: #111114;
  --text-dim: #4a4a52;
  --primary: #1B5E20;
  --primary-dark: #134218;
  --accent: #E65100;
  --info: #6a1b9a;
  --shadow: 0 4px 14px rgba(0,0,0,.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 14px 80px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #000; color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 8px;
  font-weight: 800; font-size: 14px;
  letter-spacing: .5px;
}
.brand .title { font-weight: 700; letter-spacing: .3px; }

.day-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-dim);
  cursor: pointer; user-select: none;
}
.day-toggle input { accent-color: var(--primary); }

/* card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 8px;
}
.h2 { margin: 0 0 10px; font-size: 15px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-dim); font-weight: 700; }

/* status */
.status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: 0 0 8px currentColor; }
.dot-ok { background: var(--ok); color: var(--ok); }
.dot-wait { background: var(--warn); color: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.dot-err { background: var(--danger); color: var(--danger); }
@keyframes pulse { 0%,100% {opacity:1;} 50% {opacity:.4;} }

.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}
.kv-grid > div { display: flex; flex-direction: column; }
.kv-grid .full { grid-column: 1 / -1; }
.kv-grid .k { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.kv-grid .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; word-break: break-all; }
.kv-grid .full .v { color: var(--accent); font-size: 22px; }

/* corrections */
.radio-row {
  display: flex; flex-wrap: wrap; gap: 10px 16px;
  margin-bottom: 10px;
}
.radio-row label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface-2);
}
.radio-row input { accent-color: var(--primary); }

.input-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.input-row > span { font-size: 14px; color: var(--text-dim); }
.input-row input {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 16px; width: 140px;
  font-variant-numeric: tabular-nums;
}

/* big measure button */
.btn-measure {
  width: 100%;
  min-height: 96px;
  background: var(--primary);
  color: #000;
  border: none;
  border-radius: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .05s ease, background .15s ease;
}
.btn-measure:active { transform: scale(0.985); background: var(--primary-dark); }
.btn-measure[disabled] { opacity: .45; cursor: not-allowed; }
.btn-measure .big { font-size: 22px; }
.btn-measure .small { font-size: 13px; opacity: .75; font-weight: 600; }

/* buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s ease, transform .05s ease;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #000; border-color: var(--primary); }
.btn-primary:hover:not([disabled]) { filter: brightness(1.08); }
.btn-accent { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-ghost.danger { color: var(--danger); border-color: var(--danger); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* table */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
thead th {
  text-align: right;
  padding: 6px 8px;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}
thead th:first-child { text-align: center; }
tbody td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
tbody td:first-child { text-align: center; font-weight: 700; color: var(--accent); }
tbody td:last-child { text-align: center; }
.del-btn {
  background: none; border: none; color: var(--danger); font-size: 18px;
  cursor: pointer; padding: 4px 8px;
}

/* update banner */
.update-banner {
  background: var(--primary);
  color: #000;
  padding: 12px 14px;
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  flex-wrap: wrap;
}
.update-banner.hidden { display: none; }
.update-banner .ub-text { flex: 1; min-width: 200px; }
.update-banner pre {
  margin: 4px 0 0; white-space: pre-wrap;
  font-family: inherit; font-size: 13px; opacity: .85;
}
.update-banner .ub-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.update-banner .btn { background: #000; color: #fff; border-color: #000; }
.update-banner .btn-ghost { background: transparent; color: #000; border-color: #000; }

/* dialog */
.dialog {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 18px;
  max-width: 480px;
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog h2 { margin: 0 0 10px; }
.dialog ul { padding-left: 18px; }
.dialog li { margin: 4px 0; }

/* footer */
.footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  padding-top: 4px;
}
.footer a { color: var(--info); text-decoration: none; }

@media (min-width: 520px) {
  .kv-grid { grid-template-columns: repeat(3, 1fr); }
}

/* active group strip */
.active-group-card { padding: 10px 14px; }
.ag-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ag-row .k { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.active-group-sel {
  flex: 1; min-width: 140px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 15px; font-weight: 600;
}

/* selection bar (above points table) */
.selection-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
}
.selection-bar.hidden { display: none; }
.selection-bar strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.sel-actions { display: flex; gap: 6px; flex-wrap: wrap; }

tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }

/* groups list */
.groups-list { display: flex; flex-direction: column; gap: 8px; }

.group-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
}
.group-row.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }

.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
}
.group-head .chev {
  width: 14px; display: inline-block; text-align: center;
  color: var(--text-dim); transition: transform .15s ease;
}
.group-row.open .group-head .chev { transform: rotate(90deg); }

.group-title {
  font-weight: 700;
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.group-title .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-title .pfx {
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: .5px;
  flex-shrink: 0;
}
.group-meta {
  font-size: 12px; color: var(--text-dim);
  display: flex; gap: 8px; align-items: center; flex-shrink: 0;
}
.group-meta .badge {
  background: var(--bg); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 6px; font-weight: 600;
}
.group-meta .badge.line { color: var(--info); border-color: var(--info); }
.group-meta .badge.closed { color: var(--accent); border-color: var(--accent); }

.group-body {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: none;
  background: var(--surface);
}
.group-row.open .group-body { display: block; }

.group-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 10px;
}
.group-actions .btn { padding: 6px 10px; font-size: 13px; }

.group-points {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.group-points li {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.group-points .gp-label { font-weight: 700; color: var(--accent); min-width: 40px; }
.group-points .gp-coords { flex: 1; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-points .gp-btns { display: flex; gap: 2px; }
.group-points .ic-btn {
  background: none; border: 1px solid var(--border);
  color: var(--text); border-radius: 6px;
  padding: 3px 7px; cursor: pointer; font-size: 13px;
  min-width: 28px;
}
.group-points .ic-btn:hover { background: var(--surface-2); }
.group-points .ic-btn.danger { color: var(--danger); border-color: var(--danger); }

.empty-msg { color: var(--text-dim); font-size: 13px; font-style: italic; padding: 6px 0; }

/* group/add dialogs */
.dialog .field {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 10px;
}
.dialog .field > span { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.dialog .field input {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 16px;
}
.dialog .check {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  cursor: pointer;
}
.dialog .check input { accent-color: var(--primary); }
.dialog-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 14px;
}

.atg-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 50vh; overflow-y: auto;
  margin: 8px 0;
}
.atg-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
}
.atg-row:hover { border-color: var(--primary); }
.atg-row .atg-info { display: flex; align-items: center; gap: 8px; }
.atg-row .pfx {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--accent); padding: 2px 6px; border-radius: 6px;
  font-weight: 700; font-size: 11px;
}
.atg-row.member { opacity: .5; pointer-events: none; }
.atg-row.member::after { content: 'už je v skupine'; font-size: 11px; color: var(--text-dim); }

.danger-card { padding: 10px; text-align: center; background: transparent; border: none; box-shadow: none; }

/* accuracy tiers */
.dot.acc-good { background: var(--ok);   color: var(--ok);   animation: none; }
.dot.acc-mid  { background: var(--warn); color: var(--warn); animation: none; }
.dot.acc-bad  { background: var(--danger); color: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
#acc.acc-good { color: var(--ok); }
#acc.acc-mid  { color: var(--warn); }
#acc.acc-bad  { color: var(--danger); }
tbody tr.acc-bad td:nth-child(5) { color: var(--danger); font-weight: 700; }
tbody tr.acc-mid td:nth-child(5) { color: var(--warn); }
tbody tr.acc-good td:nth-child(5) { color: var(--ok); }

/* measure progress (in-button overlay) */
.btn-measure { position: relative; overflow: hidden; }
.m-progress {
  position: absolute; left: 12px; right: 12px; bottom: 10px;
  display: flex; flex-direction: column; gap: 4px;
  pointer-events: none;
}
.m-progress.hidden { display: none; }
.m-progress-bar {
  height: 6px; width: 100%;
  background: rgba(0,0,0,.25);
  border-radius: 3px; overflow: hidden;
}
.m-progress-fill {
  height: 100%; width: 0%;
  background: #000;
  transition: width 80ms linear;
}
.m-progress-text {
  font-size: 12px; font-weight: 700; color: #000;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* hide the big label while collecting */
.btn-measure.collecting .big,
.btn-measure.collecting .small { visibility: hidden; }
.btn-measure.collecting { background: var(--accent); }

.hidden { display: none !important; }
