/* Alati za PDF: odabir datoteke, radni prostor, stranice i postavljeni elementi (Potpiši PDF, Spoji PDF, Uredi PDF) */

.small { font-size: 0.92rem; }

/* ---------- Odabir dokumenta ---------- */
.dropzone {
  display: grid; justify-items: center; text-align: center; gap: 0.35rem;
  padding: clamp(2.5rem, 7vw, 4.5rem) 1.25rem;
  border: 2px dashed var(--line-strong); border-radius: 16px;
  color: var(--ink-soft);
  transition: border-color 0.15s, background-color 0.15s;
}
.dropzone.is-over { border-color: var(--pen); background-color: color-mix(in srgb, var(--pen) 7%, var(--paper)); }
.dz-icon { width: 3.25rem; height: auto; margin-bottom: 0.75rem; color: var(--ink-soft); }
.dz-sheet { fill: var(--surface); }
.dz-ink { stroke: var(--pen); }
.dz-title { font-size: clamp(1.35rem, 3vw, 1.7rem); font-weight: 750; font-stretch: 88%; color: var(--ink); }
.dropzone .btn { margin-top: 0.4rem; }
.dz-status { min-height: 1.5em; margin-top: 0.6rem; max-width: 30rem; color: var(--ink); }
.dz-status.is-error { color: var(--red); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .dropzone { transition: none; } }

/* ---------- Radni prostor ---------- */
.workspace { display: grid; gap: 1.5rem; align-items: start; }
@media (min-width: 900px) {
  .workspace { grid-template-columns: minmax(300px, 22.5rem) minmax(0, 1fr); gap: 2rem; }
  .panel { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; overscroll-behavior: contain; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 1.25rem;
}
.step + .step { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.step-title { display: flex; align-items: center; gap: 0.6rem; font-size: 1.1rem; font-weight: 700; margin-bottom: 0.85rem; }
.step-num {
  display: inline-grid; place-items: center; flex: none;
  width: 1.65rem; height: 1.65rem; border-radius: 50%;
  border: 1.5px solid var(--pen); color: var(--pen);
  font-size: 0.85rem; font-weight: 750;
}
.doc-name { font-weight: 600; overflow-wrap: anywhere; }
.doc-name .muted { font-weight: 400; }

/* Kartice */
.tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px;
  padding: 3px; margin-bottom: 0.9rem;
  background: var(--surface-2); border-radius: 10px;
}
.tabs [role="tab"] {
  border: 0; background: none; cursor: pointer;
  padding: 0.5rem 0.25rem; border-radius: 8px;
  font-weight: 600; font-size: 0.95rem; color: var(--ink-soft);
}
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"] {
  background: var(--surface); color: var(--pen);
  box-shadow: 0 1px 2px rgba(20, 32, 70, 0.12);
}
.tabpanel { display: grid; gap: 0.85rem; }

/* Polje za crtanje: uvijek bijelo, kao papir */
.pad-wrap {
  position: relative; aspect-ratio: 5 / 2;
  background: #fff; border: 1px solid var(--line-strong); border-radius: 10px;
  touch-action: none; overflow: hidden;
}
.pad-wrap::after {
  content: ""; position: absolute; left: 8%; right: 8%; bottom: 26%;
  border-bottom: 1.5px dashed #c4cde0; pointer-events: none;
}
#pad { width: 100%; height: 100%; cursor: crosshair; touch-action: none; position: relative; z-index: 1; }
.pad-hint {
  position: absolute; left: 0; right: 0; bottom: calc(26% + 0.5rem);
  text-align: center; color: #96a0b5; font-size: 0.95rem; pointer-events: none;
}
.pad-actions { display: flex; justify-content: space-between; gap: 1rem; }

/* Napiši */
.font-choices { border: 0; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.font-choices legend { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.35rem; padding: 0; }
.font-choice {
  display: flex; align-items: center; gap: 0.7rem; cursor: pointer;
  padding: 0.35rem 0.75rem; min-height: 3.3rem;
  background: #fff; border: 1px solid var(--line-strong); border-radius: 10px;
}
.font-choice:has(input:checked) { border-color: var(--pen); box-shadow: 0 0 0 1px var(--pen); }
.font-choice input { accent-color: var(--pen); flex: none; }
.font-preview {
  font-size: 1.65rem; line-height: 1.2; color: #1f3a9e;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.font-preview[data-font="Great Vibes"] { font-family: "Great Vibes", cursive; font-size: 1.85rem; }
.font-preview[data-font="Dancing Script"] { font-family: "Dancing Script", cursive; }
.font-preview[data-font="Caveat"] { font-family: "Caveat", cursive; font-size: 1.9rem; }

/* Slika */
.btn-outline {
  min-height: 2.9rem; padding: 0.6rem 1rem; cursor: pointer;
  background: var(--surface); color: var(--pen);
  border: 1.5px solid var(--pen); border-radius: 10px; font-weight: 650;
}
.btn-outline:hover { background: color-mix(in srgb, var(--pen) 7%, var(--surface)); }
.check { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.check input { accent-color: var(--pen); width: 1.05rem; height: 1.05rem; }
.img-preview {
  display: grid; place-items: center; min-height: 6rem; padding: 0.75rem;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #eef1f6 25%, transparent 25%, transparent 75%, #eef1f6 75%),
    linear-gradient(45deg, #eef1f6 25%, transparent 25%, transparent 75%, #eef1f6 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.img-preview img { max-height: 8rem; width: auto; }
.field-error { color: var(--red); font-weight: 600; font-size: 0.95rem; }
.field-error:empty { display: none; }

/* Boja tinte */
.ink { border: 0; padding: 0; margin: 0; display: flex; align-items: center; gap: 1.1rem; }
.ink legend { float: left; font-weight: 600; font-size: 0.95rem; margin-right: 0.25rem; padding: 0; }
.ink label { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.ink input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch { width: 1.35rem; height: 1.35rem; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-strong); }
.swatch-blue { background: #1f3a9e; }
.swatch-black { background: #111827; }
.ink input:checked + .swatch { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--pen); }
.ink input:focus-visible + .swatch { outline: 3px solid color-mix(in srgb, var(--pen) 60%, transparent); outline-offset: 4px; }

/* Pladanj s gotovim potpisima */
.tray { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.tray li { position: relative; }
.tray-item {
  display: grid; place-items: center;
  width: 6.4rem; height: 3.7rem; padding: 0.35rem 0.5rem; cursor: pointer;
  background: #fff; border: 1px solid var(--line-strong); border-radius: 10px;
}
.tray-item img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.tray-item[aria-pressed="true"] { border-color: var(--pen); box-shadow: 0 0 0 2px var(--pen); }
.tray-remove {
  position: absolute; top: -0.5rem; right: -0.5rem;
  width: 1.5rem; height: 1.5rem; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; padding: 0;
  background: var(--surface); color: var(--ink-soft);
  border: 1px solid var(--line-strong); font-size: 1rem; line-height: 1;
}
.tray-remove:hover { color: var(--red); border-color: var(--red); }

/* Traka za preuzimanje */
.actionbar { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); display: grid; gap: 0.75rem; }
.action-status { font-size: 0.95rem; min-height: 1.5em; color: var(--ink-soft); }
.action-status.is-armed { color: var(--pen); font-weight: 600; }
.action-status.is-done { color: var(--ink); font-weight: 600; }
.action-status.is-error { color: var(--red); font-weight: 600; }
.actionbar .btn { width: 100%; }
.label-short { display: none; }

@media (max-width: 899px) {
  body.has-actionbar { padding-bottom: 5.5rem; }
  .actionbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    margin: 0; border-top: 1px solid var(--line);
    padding: 0.7rem 16px calc(0.7rem + env(safe-area-inset-bottom));
    background: var(--surface);
    grid-template-columns: 1fr auto; align-items: center;
    box-shadow: 0 -6px 20px rgba(20, 32, 70, 0.08);
  }
  .action-status { font-size: 0.9rem; line-height: 1.35; }
  .actionbar .btn { width: auto; }
  .label-long { display: none; }
  .label-short { display: inline; }
}

/* ---------- Stranice dokumenta ---------- */
.pages { display: grid; gap: 1.75rem; min-width: 0; }
.page-figure { margin: 0; }
.page {
  position: relative; width: 100%;
  background: #fff; box-shadow: var(--sheet-shadow);
  border-radius: 2px;
}
.page canvas { width: 100%; height: 100%; border-radius: 2px; }
.page-layer { position: absolute; inset: 0; }
.page-label { margin-top: 0.5rem; text-align: center; font-size: 0.88rem; color: var(--ink-soft); }
.pages.is-armed .page { cursor: copy; outline: 2px dashed color-mix(in srgb, var(--pen) 55%, transparent); outline-offset: 5px; }

/* Postavljeni potpis */
.placed {
  position: absolute; cursor: grab;
  touch-action: none; user-select: none; -webkit-user-select: none;
  outline: 1.5px dashed transparent; outline-offset: 2px;
}
.placed:hover { outline-color: color-mix(in srgb, var(--pen) 45%, transparent); }
.placed.is-selected { outline-color: #1f3a9e; }
.placed:active { cursor: grabbing; }
.placed img { width: 100%; height: auto; pointer-events: none; }
.placed:focus-visible { outline: 2px solid #1f3a9e; border-radius: 0; }

.resize-handle {
  position: absolute; right: -9px; bottom: -9px;
  width: 16px; height: 16px; border-radius: 4px;
  background: #fff; border: 2px solid #1f3a9e;
  cursor: nwse-resize; display: none;
}
.placed.is-selected .resize-handle { display: block; }
@media (pointer: coarse) {
  .resize-handle { width: 26px; height: 26px; right: -13px; bottom: -13px; border-radius: 50%; }
}

.placed-tools {
  position: absolute; left: 0; bottom: 100%; margin-bottom: 8px;
  display: none; gap: 4px; z-index: 5;
}
.placed.is-selected .placed-tools { display: flex; }
.placed.tools-below .placed-tools { bottom: auto; top: 100%; margin: 14px 0 0; }
.placed.tools-right .placed-tools { left: auto; right: 0; }
.placed-tools button {
  border: 0; cursor: pointer; white-space: nowrap;
  padding: 0.4rem 0.65rem; border-radius: 7px;
  background: #18213a; color: #fff; font-size: 0.82rem; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.placed-tools button:hover { background: #1f3a9e; }
