/* LocalCards — style.css (redizajn 2026-09). Iba CSS, systémové písmo, žiadne externé zdroje. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #111827;
  --muted: #5b6472;
  --border: #d8dde5;
  --primary: #1e3a8a;
  --primary-fg: #ffffff;
  --danger: #b91c1c;
  --danger-fg: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 6px 16px rgba(15, 23, 42, .06);
  --tap: 48px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f1f5f9;
    --muted: #a3b0c2;
    --border: #334155;
    --primary: #7fb2f5;
    --primary-fg: #0b1220;
    --danger: #f87171;
    --danger-fg: #0b1220;
    --ok: #4ade80;
    --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 16px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

/* ---------- základ ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
  overscroll-behavior-y: contain;
}
h1, h2, p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, canvas, video { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* ikony v app.js nemajú inline stroke atribúty — obrysový štýl dáva CSS */
svg { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  min-height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(8px, calc(50% - 320px)) 0;
  background: var(--card-bg, var(--bg));
  color: var(--card-fg, var(--text));
}
.topbar h1 {
  flex: 1; min-width: 0;
  font-size: 18px; font-weight: 600; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .brand { text-align: center; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.icon-btn {
  display: grid; place-items: center;
  width: var(--tap); height: var(--tap); flex: none;
  border: 0; border-radius: 12px; background: none; color: inherit;
  cursor: pointer; transition: background-color 150ms;
}
.icon-btn:hover, .icon-btn:active { background: color-mix(in srgb, currentColor 12%, transparent); text-decoration: none; }
.icon-btn:empty { pointer-events: none; }
.star-btn.is-on svg, .star-btn[aria-pressed="true"] svg { fill: currentColor; }

/* ---------- hľadanie ---------- */
.searchbar { padding: 8px max(16px, calc(50% - 304px)) 4px; }
.searchbar input {
  width: 100%; min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--border); border-radius: 24px;
  background: var(--surface); appearance: none;
}
.searchbar input::placeholder { color: var(--muted); }

/* ---------- stránka ---------- */
.page { padding: 8px max(16px, calc(50% - 304px)) 32px; display: grid; gap: 16px; align-content: start; }
#list { padding-bottom: calc(132px + env(safe-area-inset-bottom)); }
.cards-section { display: grid; gap: 10px; }
.cards-section h2, .group > h2, .group > legend {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 0 2px;
}
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 480px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* dlaždica = fyzická karta */
.tile {
  display: grid;
  grid-template: "logo star" auto "name name" 1fr / minmax(0, 1fr) auto;
  aspect-ratio: 1.6;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--card-bg, var(--primary));
  color: var(--card-fg, var(--primary-fg));
  box-shadow: var(--shadow);
  transition: transform 150ms, box-shadow 150ms;
}
.tile:hover { text-decoration: none; }
.tile:active { transform: scale(.97); box-shadow: none; }
.tile-logo { grid-area: logo; display: grid; place-items: center; width: 40px; height: 40px; }
.tile-logo img { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: #fff; padding: 3px; }
.tile-logo .initial { font-size: 30px; font-weight: 700; line-height: 1; }
.tile-name {
  grid-area: name; align-self: end;
  font-size: 15px; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-star { grid-area: star; display: grid; place-items: center; width: 24px; height: 24px; opacity: .9; }
.tile-star svg { width: 18px; height: 18px; fill: currentColor; }

/* FAB + stav zálohy */
.fab {
  position: fixed; left: 50%; z-index: 20;
  bottom: calc(48px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 24px;
  border-radius: 26px;
  background: var(--primary); color: var(--primary-fg);
  font-weight: 600; white-space: nowrap;
  box-shadow: var(--shadow);
  transition: transform 150ms;
}
.fab:hover { text-decoration: none; }
.fab:active { transform: translateX(-50%) scale(.97); }
.status {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 13px; color: var(--muted); text-align: center;
  padding: 8px 16px;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status[data-kind="ok"]::before { background: var(--ok); }
.status[data-kind="waiting"]::before { background: var(--warn); }
.status[data-kind="error"] { color: var(--danger); }
.status[data-kind="error"]::before { background: var(--danger); }
.status[data-kind="running"]::before { background: var(--primary); animation: pulse 1.2s ease-in-out infinite; }
/* na domovskej obrazovke je stav prilepený dole (v appke je v main#view, v mockupe priamo v body) */
#view > .status, body > .status {
  position: fixed; left: 0; right: 0; z-index: 15;
  bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
}
#view > .status[data-kind="none"], body > .status[data-kind="none"] { display: none; }
@keyframes pulse { 50% { opacity: .3; } }

/* prázdny stav */
.empty { padding: 56px 24px; text-align: center; color: var(--muted); display: grid; gap: 6px; }
.empty p:first-child { color: var(--text); font-size: 18px; font-weight: 600; }

/* ---------- detail karty ---------- */
.detail { padding-top: 16px; }
.code-box {
  display: grid; place-items: center; gap: 8px;
  min-height: 160px; padding: 20px;
  background: #fff; color: #000;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.code-box:hover { text-decoration: none; }
.code-box canvas { width: 100%; height: auto; image-rendering: pixelated; }
.code-box img { max-height: 320px; object-fit: contain; }
.code-error { color: var(--danger); font-size: 14px; text-align: center; }
.hint { font-size: 13px; color: var(--muted); }
.center { text-align: center; }
.code-value {
  font-family: var(--mono); font-size: 22px; font-weight: 600; letter-spacing: .06em;
  text-align: center; user-select: all;
}
.meta { color: var(--muted); font-size: 14px; text-align: center; }
.meta b { color: var(--text); font-weight: 600; }
.thumbs { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.thumb { display: grid; gap: 6px; justify-items: center; font-size: 13px; color: var(--muted); }
.thumb img { width: 112px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.notes {
  padding: 14px 16px; white-space: pre-wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.share-btn { margin-top: 8px; }

/* ---------- fullscreen kódu ---------- */
body.full-mode { background: #fff; color: #000; color-scheme: light; }
.full {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #fff;
}
.full-close {
  position: absolute; z-index: 1;
  top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right));
  color: #000;
}
.full-stage { flex: 1; display: grid; place-items: center; min-height: 0; padding: 72px 16px 16px; }
.full-stage canvas, .full-stage img { max-width: 100%; max-height: 100%; width: 100%; height: auto; object-fit: contain; image-rendering: pixelated; }
.full-caption { padding: 0 24px calc(28px + env(safe-area-inset-bottom)); text-align: center; display: grid; gap: 6px; }
.full-caption .code-value { color: #000; font-size: 26px; }
.full-name { color: #4b5563; font-size: 15px; }

/* ---------- formulár ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field textarea, .field select {
  width: 100%; min-height: var(--tap);
  padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); appearance: none;
  transition: border-color 150ms;
}
.field input:focus-visible, .field textarea:focus-visible, .field select:focus-visible { border-color: var(--primary); outline-offset: 0; }
.field textarea { resize: vertical; line-height: 1.4; }
.field select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px;
}
.group {
  margin: 0; min-width: 0;
  padding: 16px;
  display: grid; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.group > legend { float: left; width: 100%; margin-bottom: 4px; }
.group > legend + * { clear: both; }
.form .group .field input, .form .group .field textarea, .form .group .field select, .settings .group .field input { background: var(--bg); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px;
  font-weight: 600; text-align: center; cursor: pointer;
  background: var(--surface); color: var(--text);
  transition: background-color 150ms, transform 150ms;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-fg); }
.btn.secondary { border-color: var(--border); background: var(--surface); color: var(--primary); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.btn.danger { background: var(--danger); color: var(--danger-fg); }
.form .btn.danger, .settings .btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.big { min-height: 56px; font-size: 17px; }
.btn.small { min-height: var(--tap); padding: 0 14px; font-size: 14px; border-radius: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.preview { display: grid; place-items: center; min-height: 96px; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: 12px; }
.preview:empty, .preview:has(canvas[width="0"]) { display: none; }
.preview canvas { max-width: 100%; height: auto; image-rendering: pixelated; }

.imgfield { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; align-items: start; }
.imgfield > :first-child { width: 72px; height: 72px; display: grid; place-items: center; overflow: hidden; background: var(--bg); border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); }
/* contain, nie cover — logo a screenshot QR sa nesmú orezať */
.imgfield img { width: 100%; height: 100%; object-fit: contain; }
.imgmeta { display: grid; gap: 6px; }
.imgmeta .label { font-weight: 600; }

.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch {
  width: 44px; height: 44px; padding: 0;
  border: 2px solid var(--border); border-radius: 50%;
  background: var(--primary); cursor: pointer;
  transition: transform 150ms;
}
.swatch:active { transform: scale(.94); }
.swatch[aria-pressed="true"], .swatch.is-on, .swatch.is-selected, .swatch.selected { border-color: var(--text); box-shadow: inset 0 0 0 3px var(--surface); }
.swatch.custom { display: grid; place-items: center; background: conic-gradient(#ef4444, #f59e0b, #22c55e, #3b82f6, #a855f7, #ef4444); }
.swatch.custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--primary); flex: none; }

.form-error {
  padding: 12px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger); font-weight: 600; font-size: 14px;
}
.form > .btn.primary.big { margin-top: 8px; }

/* ---------- nastavenia ---------- */
.settings .group .status { justify-content: flex-start; padding: 0; text-align: left; }
.settings .group .btn { width: 100%; }
.settings .group .row .btn { width: auto; flex: 1; }

/* konto a prenos kariet */
.account-name b { color: var(--text); font-weight: 600; }
.auth-form { display: grid; gap: 12px; }
.pick-actions { display: flex; gap: 8px; }
.pick-list { display: grid; gap: 4px; max-height: 50vh; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.pick-list li { display: flex; }
.pick-list .check { flex: 1; min-height: 44px; padding: 0 6px; border-radius: 10px; }
.pick-list .check:active { background: var(--bg); }
.code-display {
  padding: 16px; border-radius: 12px; background: var(--bg);
  font-family: var(--mono); font-size: 28px; font-weight: 700; letter-spacing: .12em;
  text-align: center; user-select: all;
}
details.advanced { border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; }
details.advanced summary { cursor: pointer; font-weight: 600; color: var(--muted); min-height: 32px; display: flex; align-items: center; }
details.advanced .field { margin-top: 10px; }

/* ---------- dialóg ---------- */
dialog {
  width: min(92vw, 400px); padding: 0; border: 0;
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(15, 23, 42, .55); }
.dialog-body { display: grid; gap: 10px; padding: 22px 20px 16px; }
.dialog-body h2 { font-size: 19px; font-weight: 700; }
.dialog-body p { color: var(--muted); white-space: pre-line; }
.dialog-body .form-error { color: var(--danger); }
.dialog-body .code-display { color: var(--text); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; z-index: 40;
  bottom: calc(116px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  max-width: min(92vw, 600px); min-height: var(--tap); padding: 10px 16px;
  border-radius: 12px;
  background: #1f2937; color: #f9fafb;
  box-shadow: var(--shadow); font-size: 15px;
  transition: opacity 150ms;
}
.toast .action, .toast button {
  min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px;
  background: transparent; color: #93c5fd; font-weight: 600; cursor: pointer;
}
.toast:empty, .toast[hidden] { display: none; }

/* ---------- skener ---------- */
.scan-overlay { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; display: grid; }
.scan-overlay video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; top: 50%; left: 50%;
  width: min(80vw, 320px); height: min(50vw, 220px);
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, .85); border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45);
}
.scan-hint {
  position: absolute; left: 16px; right: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  padding: 10px 14px; border-radius: 12px;
  background: rgba(0, 0, 0, .6); text-align: center; font-size: 15px;
}
.scan-overlay .btn.scan-cancel {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: auto; min-height: var(--tap); padding: 0 24px;
  border: 1px solid rgba(255, 255, 255, .5); border-radius: 24px;
  background: rgba(0, 0, 0, .5); color: #fff; font-weight: 600; cursor: pointer;
}

/* ---------- pohyb ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
