/*
 * MiniLink PDF tool (MINI-003B, MINI-003B-S2): styles for pages/pdf.php only. Uses the tokens and
 * components of minilink.css (loaded first); nothing here changes another page.
 */
.pdf-op h4 { font: 500 12px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; margin: 22px 0 10px; }
.pdf-lead { max-width: 62ch; }
.pdf-nojs { padding: 12px 14px; border: 1.5px dashed var(--ink); background: var(--paper-2); }
.pdf-note { max-width: 70ch; }

/* MINI-003B-S2-UX: upload zone (button + drag and drop). The native file input stays in the page, visually hidden but
   focusable; its label is the visible button. */
.pdf-drop { position: relative; margin-top: 18px; padding: clamp(22px, 4vw, 40px) clamp(14px, 3vw, 32px); border: 2px dashed var(--ink); background: #fff; text-align: center; transition: background .15s; }
.pdf-drop.is-dragover { background: var(--lime); border-style: solid; }
.pdf-drop.is-dragover .pdf-drop-sub, .pdf-drop.is-dragover .pdf-drop-brief, .pdf-drop.is-dragover .form-hint, .pdf-drop.is-dragover .pdf-privacy { color: var(--ink); }
.pdf-drop-icon { display: block; margin: 0 auto 10px; }
.pdf-drop-title { margin: 0; font: 400 clamp(19px, 3.4vw, 28px)/1.15 var(--display); text-transform: uppercase; overflow-wrap: anywhere; }
.pdf-drop-sub { margin: 8px 0 20px; color: var(--muted); }
.pdf-file-input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.btn.pdf-pick { min-height: 52px; padding: 0 30px; font-size: 13px; cursor: pointer; }
.pdf-file-input:focus-visible + .pdf-pick { outline: 3px solid var(--ink); outline-offset: 3px; box-shadow: 0 0 0 6px var(--lime); }
.pdf-file-input:disabled + .pdf-pick { background: var(--paper-2); color: var(--muted); border-style: dashed; cursor: not-allowed; }
.pdf-drop-brief { margin: 14px 0 0; font: 500 13px/1.4 var(--mono); }
.pdf-drop .form-hint { max-width: 62ch; margin: 8px auto 0; }
.pdf-privacy { max-width: 62ch; margin: 12px auto 0; font-size: 14px; color: var(--muted); }
.pdf-drop.is-compact { margin-top: 12px; padding: 10px 14px; border-width: 1.5px; background: var(--paper-2); }
.pdf-drop.is-compact.is-dragover { background: var(--lime); }
.pdf-drop-compact { margin: 0; font-size: 14px; }

.pdf-error { margin: 16px 0 0; padding: 12px 14px; border: 1.5px solid var(--err); background: #fde8e4; color: var(--err); font-size: 15px; }
.pdf-error ul { margin: 6px 0 0; padding-left: 20px; }
.pdf-field-error { margin-top: 8px; padding: 10px 12px; border: 1.5px solid var(--err); background: #fde8e4; color: var(--err); font-size: 15px; }
.pdf-field-error ul { margin: 0; padding-left: 20px; }
.input[aria-invalid="true"] { border-color: var(--err); box-shadow: 0 0 0 2px var(--err); }

.pdf-empty { margin: 0; color: var(--muted); }
.pdf-list { list-style: none; display: grid; gap: 10px; margin: 0 0 4px; }
.pdf-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; padding: 12px; border: 1.5px solid var(--ink); background: #fff; }
.pdf-item-main { display: flex; align-items: center; gap: 12px; flex: 1 1 220px; min-width: 0; }
.pdf-item-main > div { min-width: 0; display: flex; flex-direction: column; }
.pdf-item-index { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border: 1.5px solid var(--ink); border-radius: 50%; background: var(--lime); font: 500 12px var(--mono); }
.pdf-item-name { overflow-wrap: anywhere; }
.pdf-item-meta { font-size: 14px; color: var(--muted); }
.pdf-item-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.pdf-btn-sm { min-height: 44px; padding: 0 12px; font-size: 11px; background: #fff; }
.btn.pdf-btn-sm:hover:not(:disabled) { background: var(--ink); color: var(--lime); }
.btn.pdf-btn-sm:disabled { background: var(--paper-2); color: var(--muted); }

.pdf-doc { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; margin: 16px 0 0; padding: 14px 16px; border: 1.5px solid var(--ink); border-left: 8px solid var(--lime); background: #fff; }
.pdf-doc-text { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; font-weight: 700; }
.pdf-op .field { margin-top: 16px; }

.pdf-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.pdf-status { min-height: 1.5em; margin-top: 14px; font: 500 13px/1.5 var(--mono); }
.pdf-op [aria-busy="true"] .pdf-status { background: linear-gradient(90deg, transparent, rgba(215, 251, 86, .6), transparent); background-size: 200% 100%; animation: pdf-busy 1.4s linear infinite; }
@keyframes pdf-busy { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.pdf-result { margin-top: 22px; padding: 18px; border: 1.5px solid var(--ink); background: var(--lime); box-shadow: 4px 5px 0 var(--ink); }
.pdf-result:focus-visible { outline-offset: 4px; }
.pdf-result h4 { margin-top: 0; }
.pdf-result p { margin: 0; }
.btn.btn-lime.pdf-download { background: #fff; }
.btn.btn-lime.pdf-download:hover { background: var(--ink); color: var(--lime); }

@media (max-width: 560px) {
  .pdf-actions .btn { width: 100%; }
  .pdf-item-actions { width: 100%; }
  .pdf-item-actions .btn { flex: 1 1 auto; }
  .pdf-drop { padding: 12px; }
}

/*
 * MINI-003B-S2: page organizer (pages/pdf.php, tab "Organizează pagini"). Only classes used by the organizer;
 * nothing above is changed.
 */
.pdf-organizer { margin-top: 18px; }
.pdf-field-hint { margin-top: 8px; font-size: 15px; color: var(--muted); }
.pdf-field-hint:empty { display: none; }
.pdf-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 14px 0 0; }
.pdf-selcount { font: 500 13px/1.4 var(--mono); }
.pdf-mode { margin: 16px 0 0; }
.pdf-radio { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.pdf-radio input { width: 20px; height: 20px; flex: none; accent-color: var(--ink); }
.pdf-plan { margin: 12px 0 0; padding: 10px 12px; border: 1.5px solid var(--ink); background: #fff; font: 500 13px/1.5 var(--mono); overflow-wrap: anywhere; }
.pdf-plan:empty { display: none; }
.pdf-preview-note { padding: 10px 12px; border: 1.5px dashed var(--ink); background: var(--paper-2); }

.pdf-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 20px; margin: 18px 0 0; padding: 0; }
.pdf-card { position: relative; display: flex; flex-direction: column; border: 1.5px solid var(--ink); background: #fff; cursor: grab; }
.pdf-card.is-selected { background: var(--lime); box-shadow: 4px 5px 0 var(--ink); }
.pdf-card.is-dragging { opacity: .45; }
.pdf-card.drop-before::before, .pdf-card.drop-after::after { content: ""; position: absolute; top: -2px; bottom: -2px; width: 6px; background: var(--coral); border: 1.5px solid var(--ink); }
.pdf-card.drop-before::before { left: -11px; }
.pdf-card.drop-after::after { right: -11px; }
.pdf-card-pick { position: relative; display: block; flex: 1 1 auto; padding: 8px; cursor: pointer; }
.pdf-card-check { position: absolute; top: 14px; left: 14px; z-index: 2; width: 24px; height: 24px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.pdf-thumb-frame { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; overflow: hidden; border: 1px solid var(--line); background: var(--paper-2); }
.pdf-thumb-inner { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.pdf-thumb-canvas { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.pdf-thumb-fallback { font: 500 30px var(--mono); color: var(--muted); }
.pdf-thumb-note { position: absolute; left: 6px; right: 6px; bottom: 6px; font-size: 12px; line-height: 1.3; text-align: center; color: var(--muted); }
.pdf-card.is-loading .pdf-thumb-frame::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(215, 251, 86, .55), transparent); background-size: 200% 100%; animation: pdf-busy 1.4s linear infinite; }
.pdf-card-caption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding-top: 8px; font-size: 14px; }
.pdf-card-pos { font: 500 12px var(--mono); color: var(--muted); }
.pdf-card.is-selected .pdf-card-pos { color: var(--ink); }
.pdf-card-rot { font: 500 12px var(--mono); padding: 1px 6px; border: 1.5px solid var(--ink); background: var(--coral); }
.pdf-card-tools { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1.5px solid var(--ink); }
.btn.pdf-card-btn { min-height: 44px; padding: 0; border: 0; border-right: 1px solid var(--ink); font-size: 18px; letter-spacing: 0; }
.btn.pdf-card-btn:last-child { border-right: 0; }

@media (max-width: 560px) {
  .pdf-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .pdf-toolbar .btn { flex: 1 1 auto; }
}
@media (max-width: 480px) {
  /* narrow phones: always two columns; the four page buttons wrap two by two to keep touch targets wide */
  .pdf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pdf-card-tools { grid-template-columns: repeat(2, 1fr); }
  .btn.pdf-card-btn:nth-child(2) { border-right: 0; }
  .btn.pdf-card-btn:nth-child(n+3) { border-top: 1px solid var(--ink); }
}
@media (prefers-reduced-motion: reduce) {
  .pdf-card.is-loading .pdf-thumb-frame::after { animation: none; }
}

/*
 * MINI-003B-S2-UX: order and spacing of the organizer (document, thumbnails, selection, operation, summary and
 * button, result), the enlarged-preview icon on every page and the enlarged preview itself (native <dialog>).
 */
.pdf-block { margin-top: 34px; padding-top: 22px; border-top: 1.5px solid var(--line); }
.pdf-block > h4:first-child { margin-top: 0; }
.pdf-block-pages { margin-top: 26px; }
.pdf-skip-row { margin: 12px 0 0; }
.pdf-op h4[tabindex="-1"]:focus-visible { outline-offset: 6px; }
.pdf-block-run .pdf-actions { margin-top: 16px; }
.btn.pdf-run { min-height: 56px; padding: 0 34px; font-size: 14px; }

.pdf-card-zoom { display: none; position: absolute; top: 12px; right: 12px; z-index: 3; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 1.5px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer; }
.pdf-grid.has-preview .pdf-card-zoom { display: inline-flex; }
.pdf-card-zoom:hover:not(:disabled) { background: var(--ink); color: var(--lime); }
.pdf-card-zoom:disabled { background: var(--paper-2); color: var(--muted); border-style: dashed; cursor: not-allowed; }
@media (pointer: coarse) {
  .pdf-card-zoom { width: 44px; height: 44px; }
}

html.pdf-lb-lock { overflow: hidden; }
.pdf-lb { width: min(1100px, calc(100vw - 32px)); height: min(920px, calc(100vh - 32px)); height: min(920px, calc(100dvh - 32px)); max-width: none; max-height: none; margin: auto; padding: 0; border: 2px solid var(--ink); background: var(--ink); color: var(--paper); overflow: hidden; }
.pdf-lb[open] { display: flex; flex-direction: column; }
.pdf-lb::backdrop { background: rgba(25, 27, 23, .86); }
.pdf-lb :focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; box-shadow: none; }
.pdf-lb-head, .pdf-lb-foot { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.pdf-lb-head { border-bottom: 1.5px solid rgba(242, 240, 232, .35); }
.pdf-lb-foot { flex-wrap: wrap; row-gap: 8px; border-top: 1.5px solid rgba(242, 240, 232, .35); }
.pdf-lb-heading { min-width: 0; }
.pdf-lb-title { margin: 0; font: 400 clamp(17px, 3vw, 22px)/1.2 var(--display); text-transform: uppercase; }
.pdf-lb-pos { margin: 2px 0 0; font: 500 13px/1.4 var(--mono); color: var(--lime); overflow-wrap: anywhere; }
.pdf-lb-group { display: flex; align-items: center; gap: 8px; }
.btn.pdf-lb-btn { min-width: 44px; min-height: 44px; padding: 0 12px; border-color: var(--paper); background: var(--paper); color: var(--ink); }
.btn.pdf-lb-btn:hover:not(:disabled) { background: var(--lime); }
.btn.pdf-lb-btn:disabled { background: transparent; color: rgba(242, 240, 232, .55); border: 1.5px dashed rgba(242, 240, 232, .55); }
.pdf-lb-zoom { min-width: 4.5ch; text-align: center; font: 500 14px var(--mono); color: var(--lime); }
.pdf-lb-body { position: relative; flex: 1 1 auto; min-height: 0; display: flex; background: #2b2d28; }
.pdf-lb-stage { flex: 1 1 auto; display: flex; min-width: 0; padding: 16px; overflow: auto; overscroll-behavior: contain; }
.pdf-lb-host { margin: auto; flex: none; }
.pdf-lb-canvas { display: block; background: #fff; box-shadow: 0 4px 18px rgba(0, 0, 0, .5); }
.pdf-lb-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: calc(100% - 32px); margin: 0; padding: 10px 14px; background: var(--ink); border: 1.5px solid var(--lime); color: var(--paper); font: 500 13px/1.4 var(--mono); text-align: center; pointer-events: none; }
.pdf-lb-live { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 640px) {
  .pdf-lb { width: 100vw; height: 100vh; height: 100dvh; border: 0; }
  .pdf-lb-head, .pdf-lb-foot { padding: 10px 12px; }
  .pdf-lb-stage { padding: 8px; }
  .pdf-lb-foot { justify-content: space-between; }
}
