/* =========================================================
   Sučelje aplikacije (pregled + uređivanje)
   ========================================================= */
:root {
  --bg: #0a0d1a;
  --panel: rgba(255, 255, 255, .055);
  --panel-2: rgba(255, 255, 255, .09);
  --border: rgba(255, 255, 255, .12);
  --text: #eef0ff;
  --muted: #9ea5c8;
  --a1: #8b5cf6;
  --a2: #22d3ee;
  --grad: linear-gradient(135deg, var(--a1), var(--a2));
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #fb7185;
  --radius: 16px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, .6);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}
body::before {
  content: ''; position: fixed; inset: -20%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 35% at 15% 10%, hsla(262, 83%, 60%, .35), transparent 70%),
    radial-gradient(35% 30% at 90% 15%, hsla(188, 86%, 53%, .22), transparent 70%),
    radial-gradient(40% 40% at 60% 100%, hsla(330, 80%, 60%, .14), transparent 70%);
  animation: drift 24s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate3d(3%, -2%, 0) scale(1.05); } }

a { color: inherit; }
button { font: inherit; color: inherit; }

/* ---------- gornja traka ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px clamp(12px, 3vw, 28px);
  background: rgba(10, 13, 26, .62);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; text-decoration: none; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--grad); font-weight: 800; font-size: 18px; color: #fff;
  box-shadow: 0 8px 24px -8px var(--a1);
}
.brand h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: .01em; }
.brand small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }

/* segmentirana kontrola */
.seg {
  display: inline-flex; padding: 4px; gap: 4px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border);
}
.seg button {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; cursor: pointer;
  font-weight: 600; color: var(--muted); transition: color .2s, background .25s, transform .15s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--grad); color: #fff; box-shadow: 0 6px 18px -8px var(--a1); }
.seg button:active { transform: scale(.96); }

/* prekidač */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; color: var(--muted); font-weight: 500; }
.switch input { display: none; }
.switch .track {
  width: 42px; height: 24px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--border);
  position: relative; transition: background .25s;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .25s cubic-bezier(.3, 1.4, .6, 1);
}
.switch input:checked + .track { background: linear-gradient(135deg, #f43f5e, #fb923c); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:checked ~ span { color: var(--text); }

/* gumbi */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel); cursor: pointer; text-decoration: none; font-weight: 600;
  transition: transform .15s, background .2s, box-shadow .25s, border-color .2s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); transform: translateY(-1px); border-color: rgba(255,255,255,.22); }
.btn:active { transform: translateY(0) scale(.97); }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 10px 28px -10px var(--a1); }
.btn.primary:hover { box-shadow: 0 14px 34px -10px var(--a1); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; }

/* info traka */
.infobar {
  margin: 18px auto 0; max-width: 980px; padding: 12px 16px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeUp .5s ease both;
}
.infobar .ico { font-size: 22px; }
.infobar .txt { flex: 1; min-width: 220px; color: var(--muted); font-size: 14px; }
.infobar .txt b { color: var(--text); }
.infobar code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 13px;
  background: rgba(0,0,0,.3); padding: 3px 8px; border-radius: 7px; color: #a5f3fc;
}
.qr { width: 84px; height: 84px; border-radius: 10px; background: #fff; padding: 5px; }

/* listovi */
.sheets {
  display: flex; flex-direction: column; align-items: center; gap: 28px;
  padding: 24px 12px 60px;
}
.sheets .page {
  zoom: var(--zoom, 1);
  border-radius: 4px;
  box-shadow: 0 30px 60px -25px rgba(0, 0, 0, .75), 0 0 0 1px rgba(255,255,255,.06);
  animation: fadeUp .55s cubic-bezier(.2, .8, .2, 1) both;
}
.sheets .page:nth-child(2) { animation-delay: .06s; }
.sheets .page:nth-child(3) { animation-delay: .12s; }
.sheets .page:nth-child(4) { animation-delay: .18s; }
.sheet-label {
  align-self: center; color: var(--muted); font-size: 13px; letter-spacing: .14em; text-transform: uppercase;
  display: flex; align-items: center; gap: 10px; margin-bottom: -12px;
}
.sheet-label::before, .sheet-label::after { content: ''; width: 40px; height: 1px; background: var(--border); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 12px 18px; border-radius: 12px; font-weight: 600;
  background: rgba(20, 24, 44, .92); border: 1px solid var(--border);
  box-shadow: var(--shadow); transition: opacity .25s, transform .25s;
  backdrop-filter: blur(12px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(52, 211, 153, .5); }
.toast.bad { border-color: rgba(251, 113, 133, .6); }

/* =========================================================
   Uređivanje
   ========================================================= */
.editor { max-width: 760px; margin: 0 auto; padding: 18px 14px 130px; }
.editor-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 16px; }
.editor-head h2 { margin: 0; font-size: 22px; flex: 1; }
.mode-pill {
  font-size: 12px; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--border); color: var(--muted);
}
.mode-pill.server { color: var(--ok); border-color: rgba(52, 211, 153, .35); }
.mode-pill.local { color: var(--warn); border-color: rgba(251, 191, 36, .35); }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 12px; overflow: hidden;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeUp .45s ease both;
  transition: border-color .2s;
}
.card[open] { border-color: rgba(139, 92, 246, .35); }
.card > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; user-select: none;
}
.card > summary::-webkit-details-marker { display: none; }
.card > summary .num {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--panel-2); font-weight: 800;
}
.card[open] > summary .num { background: var(--grad); color: #fff; }
.card > summary .ttl { flex: 1; font-weight: 600; line-height: 1.25; }
.card > summary .ttl small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; margin-top: 2px; }
.card > summary .chev { transition: transform .25s; color: var(--muted); }
.card[open] > summary .chev { transform: rotate(180deg); }
.status { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 99px; flex: none; }
.status.ok { background: rgba(52, 211, 153, .14); color: var(--ok); }
.status.warn { background: rgba(251, 191, 36, .14); color: var(--warn); }
.status.err { background: rgba(251, 113, 133, .16); color: var(--err); }

.card-body { padding: 4px 16px 16px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; line-height: 1.45; }
.row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); margin-bottom: 10px; }
.row.two { grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 13px; border-radius: 11px;
  border: 1px solid var(--border); background: rgba(0, 0, 0, .28); color: var(--text);
  font: inherit; font-size: 16px; /* 16px sprječava zumiranje na iPhoneu */
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.input:focus { outline: none; border-color: var(--a1); box-shadow: 0 0 0 4px rgba(139, 92, 246, .22); background: rgba(0,0,0,.4); }
.input.num { text-align: center; font-weight: 700; font-size: 18px; }
.input.upper { text-transform: uppercase; letter-spacing: .04em; }
textarea.input { resize: vertical; min-height: 78px; line-height: 1.4; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
select.input option { background: #161a2e; }

.preview { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.chip {
  font-size: 13px; padding: 5px 10px; border-radius: 99px; background: rgba(34, 211, 238, .1);
  color: #a5f3fc; border: 1px solid rgba(34, 211, 238, .25);
}
.msgs { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.msgs li { font-size: 13px; padding: 8px 10px; border-radius: 10px; line-height: 1.35; }
.msgs li.warn { background: rgba(251, 191, 36, .1); color: #fde68a; }
.msgs li.err { background: rgba(251, 113, 133, .12); color: #fecdd3; }

/* slova rečenice */
.letters { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 4px; }
.lt {
  min-width: 30px; padding: 5px 4px 3px; border-radius: 8px; text-align: center;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--border);
  font-weight: 700; font-size: 15px; line-height: 1.1;
}
.lt i { display: block; font-style: normal; font-size: 10px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.lt.h1 { background: rgba(139, 92, 246, .3); border-color: var(--a1); }
.lt.h2 { background: rgba(34, 211, 238, .22); border-color: var(--a2); }
.lt.h3 { background: rgba(251, 146, 60, .25); border-color: #fb923c; }
.lt.gap { background: transparent; border-color: transparent; min-width: 8px; }

/* artikli */
.items { display: grid; gap: 8px; margin-bottom: 12px; }
.item { display: grid; grid-template-columns: 1fr 92px; gap: 8px; align-items: center; }
.item .eur { position: relative; }
.item .eur::after { content: '€'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.item .eur .input { padding-right: 26px; }

/* novčanice u editoru */
.notes-edit { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px; }
.note-pick {
  border-radius: 14px; padding: 10px; border: 2px solid var(--border); background: rgba(0,0,0,.2);
  display: flex; flex-direction: column; gap: 8px; align-items: stretch; transition: border-color .2s, box-shadow .2s;
}
.note-pick.correct { border-color: var(--ok); box-shadow: 0 0 0 4px rgba(52, 211, 153, .15); }
.note-pick .page-note { zoom: .38; align-self: center; }
.note-pick .mark {
  border: 0; border-radius: 9px; padding: 8px; font-size: 13px; font-weight: 700; cursor: pointer;
  background: var(--panel-2); color: var(--muted);
}
.note-pick.correct .mark { background: rgba(52, 211, 153, .2); color: var(--ok); }

/* donja traka za spremanje */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(10, 13, 26, .78); border-top: 1px solid var(--border);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.savebar-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.savebar .state { flex: 1; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.savebar .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.savebar .dirty .dot { background: var(--warn); box-shadow: 0 0 10px var(--warn); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

@media (max-width: 640px) {
  .topbar { gap: 10px; }
  .brand small { display: none; }
  .topbar .actions { width: 100%; display: flex; gap: 8px; }
  .topbar .actions .btn { flex: 1; }
  .seg button { padding: 8px 11px; }
  .sheets { padding: 16px 8px 40px; gap: 18px; }
  .notes-edit { grid-template-columns: 1fr; }
  .note-pick { flex-direction: row; align-items: center; }
  .note-pick .input { flex: 1; }
}
