/* Webová aplikácia PT Štítky – len to, čo je špecifické pre aplikáciu. Tokeny a prvky sú v design.css. */

:root { --nav-h: 64px; --app-w: 780px; }

/* ---------- hlavička a záložky ---------- */
.app-header .page-header-inner { max-width: var(--app-w); gap: var(--s-2); }
.app-header .brand span { white-space: nowrap; }
.header-links { margin-left: auto; display: flex; gap: var(--s-1); }

.tabs { display: flex; gap: 4px; }
.tabs button { gap: 8px; border: 0; background: transparent; color: var(--muted); font-weight: 650; }
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent-ink); background: var(--accent-soft); }
.tabs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* desktop: záložky v hlavičke, mobil: spodná navigácia */
@media (min-width: 720px) {
  .tabs { margin-left: var(--s-4); }
  .tabs button { min-height: 40px; padding: 0 var(--s-3); border-radius: 10px; }
}
@media (max-width: 719px) {
  .tabs {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    padding: 6px var(--s-3) calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--border);
    justify-content: space-around;
  }
  .tabs button { flex: 1; max-width: 200px; flex-direction: column; gap: 2px; min-height: 52px; font-size: var(--fs-xs); border-radius: 14px; }
  .tabs button[aria-selected="true"] { background: transparent; }
  .tabs button[aria-selected="true"] svg { background: var(--accent-soft); border-radius: 999px; padding: 2px 14px; width: 52px; height: 26px; }
  body.has-tabs main { padding-bottom: calc(var(--nav-h) + var(--s-6) + env(safe-area-inset-bottom)); }
  body.has-tabs .toast-wrap { bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); }
  body.has-tabs .bulk { bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); }
}
/* záložky s „position: fixed“ nesmú byť vnútri prvku s backdrop-filter – na mobile ho hlavička nemá */
@media (max-width: 719px) { .app-header { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); } }

/* priebeh tlače – tenký pás pod hlavičkou */
.progress { height: 3px; background: transparent; overflow: hidden; position: absolute; left: 0; right: 0; bottom: -1px; }
.progress span { display: block; height: 100%; width: 40%; background: var(--accent); animation: slide 1.1s ease-in-out infinite; border-radius: 2px; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ---------- obsah ---------- */
main {
  max-width: var(--app-w);
  margin: 0 auto;
  padding: var(--s-4) var(--s-4) calc(var(--s-7) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
@media (min-width: 720px) { main { padding-top: var(--s-5); } }
#tab-print, #tab-library, #lib-browse, #server-parts { gap: var(--s-4); }

.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head h2 { margin-right: auto; }
.card > p { margin: 0; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 0 var(--s-1); }
.section-title h2 { font-size: var(--fs-xl); }

/* hlásenie – plávajúce dole */
.toast-wrap {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; padding: 0 var(--s-3); pointer-events: none;
}
.toast { pointer-events: auto; max-width: 560px; width: 100%; box-shadow: var(--sh-3); cursor: pointer; background: var(--surface); animation: pop .2s ease-out; }
.toast[data-kind="ok"] { background: color-mix(in srgb, var(--ok-soft) 70%, var(--surface)); }
.toast[data-kind="error"] { background: color-mix(in srgb, var(--error-soft) 70%, var(--surface)); }

/* prázdne stavy */
.empty-state {
  margin: 0; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  padding: var(--s-6) var(--s-4); border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); color: var(--muted);
}
.empty-state b { color: var(--text); }
.empty-state svg { width: 56px; height: 56px; margin-bottom: var(--s-2); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
p.empty-state { font-size: var(--fs-sm); }

/* ---------- prihlásenie (neprihlásený vidí len toto) ---------- */
.auth-card { max-width: 460px; width: 100%; margin: var(--s-5) auto 0; padding: var(--s-5); box-shadow: var(--sh-2); }
.auth-foot { text-align: center; }

/* ---------- tlačiareň ---------- */
.printer-card .dot { width: 12px; height: 12px; }
.printer-card .dot[data-on="1"] { animation: ping 2.4s ease-out infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 45%, transparent); } 70%, 100% { box-shadow: 0 0 0 9px transparent; } }
#printer-text { font-weight: 550; }
.printer-card[data-state="on"] .badge { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.printer-card[data-state="warn"] .badge { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.printer-card[data-state="warn"] .dot { background: var(--warn); animation: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent); }

/* ---------- úlohy na tlač ---------- */
#jobs { display: flex; flex-direction: column; gap: var(--s-4); }
.job h3 { font-size: var(--fs-lg); overflow-wrap: anywhere; }
.job .meta { margin-top: -6px; }

/* náhľad štítku = kus pásky */
.preview {
  background: var(--surface-2);
  border-radius: var(--r);
  padding: var(--s-4) var(--s-3);
  overflow-x: auto;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.preview canvas, .preview img {
  display: block; max-width: 100%;
  image-rendering: pixelated;
  background: var(--tape);
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--tape-edge), 0 6px 14px rgb(0 0 0 / .12);
}
.preview canvas { width: 100%; max-height: 160px; object-fit: contain; }
.preview .loading { font-size: var(--fs-sm); }

.opts { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); align-items: center; }
.opts label { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); }
input[type="number"] { width: 80px; }
.tape-warn { margin: 0; padding: 8px 12px; border-radius: var(--r-sm); background: var(--warn-soft); color: var(--warn); font-weight: 650; font-size: var(--fs-sm); }
.upload { display: flex; flex-direction: column; gap: var(--s-3); }
.upload .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }

/* tlačiarne v účte */
.bridges { display: flex; flex-direction: column; gap: var(--s-2); }
.bridges > p { margin: 0; }
.bridge {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border);
}
.bridge > span:nth-child(2) { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.bridge button { min-height: 36px; padding: 0 12px; font-size: var(--fs-xs); }
.pair { margin: 0; padding: var(--s-3) var(--s-4); border-radius: var(--r); background: var(--accent-soft); color: var(--text); font-size: var(--fs-sm); }
.pair strong { display: inline-block; font-family: var(--font-mono); font-size: 1.5rem; letter-spacing: .18em; color: var(--accent-ink); margin: 0 4px; }

/* vlastný obrázok, import */
.file-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; align-self: flex-start;
  min-height: var(--control-h); padding: 0 var(--s-4); border-radius: var(--r);
  border: 1.5px dashed var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 600; font-size: var(--fs-sm);
}
.file-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.file-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.file-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }

/* účet */
.account { display: flex; flex-direction: column; gap: var(--s-3); }
.account p { margin: 0; }
.account strong { overflow-wrap: anywhere; }
.row.copy input { flex: 1 1 200px; min-width: 0; font-family: var(--font-mono); font-size: var(--fs-sm); }

/* ---------- knižnica ---------- */
.search-row { flex-wrap: nowrap; }
.search { position: relative; flex: 1; min-width: 0; }
.search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search input { width: 100%; padding-left: 38px; background: var(--surface-2); border-color: transparent; }
.search input:focus { background: var(--surface); }
@media (max-width: 420px) { #lib-new { padding: 0 var(--s-3); } }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: -4px 0; }
.crumbs .sep { color: var(--muted); padding: 0 2px; }
.crumb { border: 0; background: none; min-height: 34px; padding: 0 8px; color: var(--accent); font-weight: 650; box-shadow: none; }
.crumb:hover { background: var(--accent-soft); }
.crumb[aria-current="page"] { color: var(--text); }
.tools { gap: 6px; }

.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: var(--s-2); }
.folders:empty { display: none; }
.folder { justify-content: flex-start; gap: 12px; text-align: left; min-height: 56px; border-radius: var(--r); white-space: normal; border-color: var(--border); box-shadow: var(--sh-1); }
.folder-icon { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.folder-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.folder-name { flex: 1; font-weight: 650; overflow-wrap: anywhere; }
.folder .muted { background: var(--surface-2); border-radius: 999px; padding: 1px 9px; font-weight: 650; font-size: var(--fs-xs); }

.lib-list { display: flex; flex-direction: column; gap: var(--s-2); }
.list-head { margin: var(--s-2) var(--s-1) 0; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: var(--fs-xs); }
.lrow {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 6px 8px 6px 12px; box-shadow: var(--sh-1);
  transition: border-color .15s;
}
.lrow:hover { border-color: var(--border-strong); }
.lrow:has(> input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.lbody {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: flex-start; gap: 12px;
  border: 0; background: none; padding: 4px 0; text-align: left; min-height: 48px; white-space: normal; font-weight: 400; box-shadow: none;
}
.lbody:hover { background: none; }
.thumb {
  height: 36px; width: auto; max-width: 40%; flex: none;
  image-rendering: pixelated; background: var(--tape); border-radius: 3px; object-fit: contain;
  box-shadow: 0 0 0 1px var(--tape-edge);
}
.linfo { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.linfo strong { overflow-wrap: anywhere; font-weight: 650; }
.linfo .muted { overflow-wrap: anywhere; font-size: var(--fs-xs); }

.bulk {
  position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--accent);
  box-shadow: var(--sh-3);
}
.bulk span { margin-right: auto; font-weight: 700; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); margin-left: 4px; opacity: .6; }
.menu[open] summary::after { transform: rotate(-135deg) translateY(-1px); }
.menu[open] { flex-basis: 100%; }
.menu-body {
  display: flex; flex-direction: column; gap: 6px; padding: var(--s-3); margin-top: var(--s-2);
  background: var(--surface-2); border-radius: var(--r); border: 1px solid var(--border);
}
.menu-body button, .menu-body .file-btn { justify-content: flex-start; width: 100%; align-self: stretch; border-style: solid; border-width: 1px; }
.menu-body p { margin: 0; }

/* ---------- editor ---------- */
.ed-meta { display: grid; gap: var(--s-3); }
@media (min-width: 640px) { .ed-meta { grid-template-columns: 1fr 1fr; } .ed-meta .field:first-child { grid-column: 1 / -1; } }
.editor .field { font-weight: 600; }
.editor .opts label { color: var(--text); }
.editor .opts .grow { flex: 1 1 220px; }
.editor .opts .grow input { flex: 1; min-width: 0; }
.ed-lines { display: flex; flex-direction: column; gap: 6px; }
.ed-line { display: flex; gap: 6px; align-items: center; }
.ed-line input { flex: 1; min-width: 0; }
.ed-line select { width: 78px; padding: 0 6px; }
.toggle { min-width: var(--control-h); padding: 0; font-weight: 800; }
.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.ed-preview { display: flex; flex-direction: column; gap: 6px; }
.ed-preview .preview { min-height: 96px; justify-content: center; }
.editor .preview img, .saved img { max-height: 180px; }
.saved { display: flex; flex-direction: column; gap: 6px; }
.saved p, .note p, #ed-preview-wrap p { margin: 0; }
.note { padding: var(--s-3) var(--s-4); border-radius: var(--r); background: var(--info-soft); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.ed-actions { padding-top: var(--s-2); border-top: 1px solid var(--border); }
#ed-delete { margin-left: auto; }

.dialog-actions { justify-content: flex-end; }
#lib-move select { width: 100%; }
.job-opts { display: flex; flex-direction: column; gap: var(--s-3); }
