/* ============================================================
   AUTO UNIVERSE — CORE CSS (Nivo 0)
   Zajednički temelj za sve aplikacije. Boje NIKAD hardkodovane
   ovde — dolaze iz trade config-a preko CSS varijabli (app.js).
   UX pravila: 1 ekran = 1 odluka • max 3 akcije • veliki font,
   velika dugmad • Apple Notes estetika, ne SAP.
   ============================================================ */

:root {
  /* fallback vrednosti — pregaze se iz config-a pri boot-u */
  --c-primary: #D5281B;
  --c-accent:  #1C1F24;
  --c-bg:      #F4F3EF;
  --c-surface: #FFFFFF;
  --c-ok:      #1E8A4C;
  --c-locked:  #9AA0A6;

  --radius: 14px;
  --nav-h: 64px;
  --topbar-h: 52px;
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-accent);
  font-size: 17px; /* veliki font — telefon u masnoj ruci */
}

/* ---------- Topbar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--c-accent);
  color: #fff;
}
.topbar-brand {
  font-weight: 800;
  letter-spacing: 0.12em;
  font-size: 15px;
  border-left: 4px solid var(--c-primary);
  padding-left: 10px;
}
.topbar-badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  background: var(--c-primary); color: #fff;
  padding: 3px 8px; border-radius: 6px;
}

/* ---------- Screen ---------- */
.screen {
  padding: calc(var(--topbar-h) + 16px) 16px calc(var(--nav-h) + 24px);
  max-width: 640px;
  margin: 0 auto;
}
.screen h1 { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.screen .sub { color: #6b7075; font-size: 15px; margin-bottom: 20px; }

/* ---------- Kartice i liste ---------- */
.card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.card h2 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.card .empty { color: #8a8f94; font-size: 15px; }

/* ---------- Dugmad — velika, jasna ---------- */
.btn {
  display: block; width: 100%;
  min-height: 54px;
  border: none; border-radius: var(--radius);
  font-size: 17px; font-weight: 700; font-family: var(--font);
  cursor: pointer;
}
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-secondary { background: var(--c-surface); color: var(--c-accent); border: 2px solid var(--c-accent); }
.btn:active { transform: scale(0.98); }
.btn[disabled] { background: var(--c-locked); cursor: default; }

/* ---------- Bottom nav ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--c-surface);
  border-top: 1px solid #e3e2de;
}
.nav-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  background: none; border: none; cursor: pointer;
  color: #7a7f84; font-family: var(--font);
}
.nav-btn .nav-ico { font-size: 20px; line-height: 1; }
.nav-btn .nav-label { font-size: 11px; font-weight: 600; }
.nav-btn.active { color: var(--c-primary); }
.nav-btn-primary .nav-ico {
  background: var(--c-primary); color: #fff;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.nav-btn-primary.active .nav-ico { background: var(--c-accent); }

/* ---------- Pristupačnost ---------- */
.btn:focus-visible, .nav-btn:focus-visible { outline: 3px solid var(--c-primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Sesija 2: forme, liste, statistika ---------- */

.search {
  width: 100%; min-height: 50px;
  border: 2px solid #e3e2de; border-radius: var(--radius);
  padding: 0 14px; font-size: 17px; font-family: var(--font);
  margin-bottom: 14px; background: var(--c-surface);
}
.search:focus { outline: none; border-color: var(--c-primary); }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; font-weight: 700; color: #6b7075; margin-bottom: 4px; }
.field input, .field select {
  width: 100%; min-height: 48px;
  border: 2px solid #e3e2de; border-radius: 10px;
  padding: 0 12px; font-size: 17px; font-family: var(--font);
  background: #fff;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--c-primary); }

.chk { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-size: 16px; }
.chk input { width: 20px; height: 20px; }

.statrow { display: flex; gap: 10px; margin-bottom: 16px; }
.stat {
  flex: 1; background: var(--c-surface); border: none; border-radius: var(--radius);
  padding: 14px 8px; text-align: center; cursor: pointer; font-family: var(--font);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.stat b { display: block; font-size: 26px; color: var(--c-primary); }
.stat span { font-size: 12px; font-weight: 600; color: #6b7075; }

.vehrow, .rowmain {
  display: block; width: 100%; text-align: left;
  border: none; cursor: pointer; font-family: var(--font); background: none;
}
.vehrow b, .rowmain b { display: block; font-size: 17px; }
.vehrow .muted, .rowmain .muted { font-size: 14px; color: #8a8f94; }
.muted { color: #8a8f94; font-weight: 400; }

.contactrow { display: flex; align-items: center; gap: 10px; }
.contactrow .rowmain { flex: 1; padding: 0; }

.ownerrow {
  display: flex; align-items: center; justify-content: space-between;
  text-decoration: none; color: inherit;
}
.callpill {
  background: var(--c-ok); color: #fff; text-decoration: none;
  font-weight: 700; font-size: 14px;
  padding: 8px 14px; border-radius: 999px; white-space: nowrap;
}

.techrow {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid #f0efeb; font-size: 15px;
}
.techrow:last-child { border-bottom: none; }
.techrow span { color: #6b7075; }
.techrow b { text-align: right; }

.secttitle { font-size: 18px; font-weight: 800; margin: 18px 0 10px; }

.evt-head { display: flex; justify-content: space-between; font-size: 16px; }
.evt-head span { color: #8a8f94; font-size: 14px; }
.evt-km { font-size: 14px; color: #6b7075; }
.evt-total { font-weight: 700; margin-top: 4px; }

.linkback {
  background: none; border: none; color: var(--c-primary);
  font-size: 16px; font-weight: 700; font-family: var(--font);
  padding: 0; margin-bottom: 10px; cursor: pointer;
}

.btn-danger { background: #fff; color: #B3261E; border: 2px solid #B3261E; }
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }

.filelabel { display: flex; align-items: center; justify-content: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px);
  transform: translateX(-50%);
  background: var(--c-accent); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-size: 15px; font-weight: 600; z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

/* ---------- Sesija 3: WO Snap tok ---------- */

.wo-progress { display: flex; gap: 6px; margin-bottom: 14px; }
.wo-progress .dot {
  flex: 1; height: 5px; border-radius: 3px; background: #e3e2de;
}
.wo-progress .dot.on { background: var(--c-primary); }
.wo-progress .dot.done { background: var(--c-ok); }

.wo-steptitle { font-size: 18px; font-weight: 800; margin-bottom: 12px; }
.wo-body { margin-bottom: 12px; }

.wo-nav { display: flex; gap: 10px; }
.wo-half { flex: 1; }

textarea {
  width: 100%; border: 2px solid #e3e2de; border-radius: 10px;
  padding: 10px 12px; font-size: 17px; font-family: var(--font); resize: vertical;
}
textarea:focus { outline: none; border-color: var(--c-primary); }

.btn.sm { min-height: 40px; font-size: 15px; width: auto; padding: 0 16px; margin-top: 6px; }

.photogrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.photothumb { position: relative; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden; }
.photothumb img { width: 100%; height: 100%; object-fit: cover; }
.photothumb button {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 14px; cursor: pointer;
}

.itemrow { padding: 8px 0; border-bottom: 1px solid #f0efeb; }
.itemrow:last-child { border-bottom: none; }
.itemrow .it-name {
  width: 100%; min-height: 42px; border: 2px solid #e3e2de; border-radius: 8px;
  padding: 0 10px; font-size: 16px; font-family: var(--font); margin-bottom: 6px;
}
.itemrow-bm { display: flex; gap: 6px; margin-bottom: 6px; }
.it-brand, .it-partno {
  flex: 1; min-width: 0; min-height: 38px; border: 2px solid #e3e2de; border-radius: 8px;
  padding: 0 8px; font-size: 13px; font-family: var(--font); background: #fff; color: #555;
}
.itemrow-line { display: flex; gap: 6px; align-items: center; }
.itemrow-line select, .itemrow-line input {
  min-height: 42px; border: 2px solid #e3e2de; border-radius: 8px;
  padding: 0 6px; font-size: 15px; font-family: var(--font); background: #fff;
}
.it-kind { flex: 0 0 68px; }
.it-qty { flex: 1; min-width: 0; }
.it-price { flex: 1.4; min-width: 0; }
.it-cur { flex: 0 0 66px; }
.it-del {
  flex: 0 0 38px; min-height: 42px; border: none; border-radius: 8px;
  background: #fff; color: #B3261E; border: 2px solid #f0d5d3; font-size: 16px; cursor: pointer;
}
.wo-runningtotal { text-align: right; margin-top: 10px; font-size: 17px; }

.sigpad {
  width: 100%; height: 150px; background: #fff;
  border: 2px dashed #cfceca; border-radius: 10px; touch-action: none;
}

/* ---------- Sesija 4: licenca + podsetnici ---------- */

.lic-ok { color: var(--c-ok); font-weight: 700; font-size: 16px; }
.locked-card { text-align: center; }

/* AU Core connected badge (inline u .sub) */
.hub-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; padding: 2px 7px;
  border-radius: 10px; background: #d1fae5; color: #065f46;
  vertical-align: middle; margin-left: 4px;
}

/* AU Core dashboard card (posle login-a u Settings) */
.hub-dashboard { margin: .4rem 0 .6rem; }
.hub-row { display: flex; align-items: center; gap: 6px; margin: .25rem 0; font-size: .9rem; }
.hub-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-ok, #1D9E75); flex-shrink: 0;
  box-shadow: 0 0 0 2px #d1fae5;
}

.remrow { display: flex; align-items: center; gap: 10px; }
.remrow .rowmain { flex: 1; padding: 0; }
.remrow.rem-due { border-left: 4px solid #B3261E; }
.remrow.rem-soon { border-left: 4px solid #E08A00; }
.remrow.rem-upcoming { border-left: 4px solid #cfceca; }
.remrow.rem-done { opacity: 0.55; }

.rembadge {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid #e3e2de; background: #fff; color: #9aa0a6;
  font-size: 18px; cursor: pointer;
}
.rembadge.due { border-color: #B3261E; color: #B3261E; }
.rembadge.soon { border-color: #E08A00; color: #E08A00; }
.rembadge.done { background: var(--c-ok); border-color: var(--c-ok); color: #fff; cursor: default; }

/* Retroaktivni (naknadno unet) događaj + trust prikaz — dele Garage i Driver */
.evt.retro { opacity: .78; border-left: 3px solid var(--c-locked, #9AA0A6); }
.evt .trust { font-size: 13px; color: #6b7075; }
.evt .retro-tag {
  display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 10px;
  background: #EEF2F4; color: #64748B; margin-left: 6px;
}
