/* pdfexport («پیش‌نمایش و خروجی») — layout, settings sidebar, paper pages, modal (PDFX.open). Prefix: pdf-, pg-, rc-, zi-, pv-in, pdfx-. */

/* ── frame: settings sidebar at the side; beside it, row 1 = name, row 2 = page size / zoom / pager / actions, then pages ── */
.pdf { position: relative; display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0; }
.pdf-body { flex: 1; min-height: 0; display: flex; position: relative; }
.pdf-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.pdf-hd { display: flex; align-items: center; gap: 8px 10px; padding: 10px 14px 8px; min-width: 0; }
.pdf-name { font-family: "Morabba"; font-size: 17px; line-height: 1.4; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* row 2, LTR: download/print/send left · pager centred (RTL group: ‹ · current · «از» · total input · ›) · zoom right */
.pdf-tb { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); min-width: 0; }
.pdf-paper { width: 100%; height: 32px; font-size: 13px; }
.pdf-zoom, .pdf-pg, .pdf-acts { display: flex; align-items: center; gap: 4px; font-size: 12.5px; flex-wrap: nowrap; }
.pdf-pg { margin-inline: auto; }
.pdf-acts { gap: 6px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.pdf-tb > * { min-width: 0; }
.pdf-setbtn { display: none; margin-inline-start: auto; }
.zi-w { display: inline-flex; align-items: center; gap: 1px; }
.zi, .pt-in { width: 52px; height: 28px; text-align: center; font: inherit; font-size: 12.5px; font-variant-numeric: tabular-nums; border: 1px solid var(--border); border-radius: 6px; padding: 0 4px; background: var(--card); color: inherit; }
.pt-in { width: 44px; }
.pt-in:disabled { opacity: .5; }
.pv-cur { min-width: 16px; text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pt-l { white-space: nowrap; color: var(--muted-foreground); }
.pg-blank { min-height: 40px; }

/* ── row-2 secondary buttons (download, print, send): one style, all states ── */
.pdf-acts .btn { background: var(--background); border: 1px solid var(--border); color: var(--foreground); white-space: nowrap; padding: 0 8px; }
.pdf-acts .btn:hover { background: var(--muted); }
.pdf-acts .btn:active { background: color-mix(in srgb, var(--muted) 70%, var(--border)); transform: translateY(1px); }
.pdf-acts .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.pdf-acts .btn[disabled] { background: var(--background); color: var(--foreground); opacity: .5; }

/* ── settings sidebar ── */
.pdf-set { width: 258px; flex: none; border-inline-end: 1px solid var(--border); background: var(--muted); padding: 12px; overflow: auto; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.pdf-sec { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pdf-sh { font-size: 12.5px; font-weight: 600; color: var(--muted-foreground); }
.pdf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pdf-chip { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--card); border-radius: 10px; padding: 6px 8px; font: inherit; font-size: 11.5px; color: inherit; cursor: pointer; min-width: 74px; }
.pdf-chip[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent); }
.pdf-add { align-self: flex-start; }
.pdf-col { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12.5px; min-width: 0; }
.pdf-col > .pdf-o { flex: 1; min-width: 0; }
.pdf-cl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pdf-mv { display: flex; gap: 2px; flex: none; }
.pdf-orow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; min-width: 0; }
.pdf-o { display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; font-size: 13px; }
.pdf-o.dis { opacity: .45; pointer-events: none; }
.pdf-sw-t { width: 30px; height: 17px; border-radius: 99px; background: var(--input); position: relative; flex: none; transition: background .2s; }
.pdf-sw-t i { position: absolute; top: 2px; inset-inline-start: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: inset-inline-start .2s; }
.pdf-sw-t.on { background: var(--primary); }
.pdf-sw-t.on i { inset-inline-start: 15px; }

/* ── template / receipt library dialog ── */
.dlg.pdf-libd { width: min(400px, calc(100% - 24px)); }
.pdf-lib { display: grid; gap: 8px; margin: 6px 0 12px; }
.pdf-lib-i { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); background: var(--card); border-radius: 10px; padding: 8px 10px; font: inherit; text-align: start; cursor: pointer; color: inherit; }
.pdf-lib-i:disabled { opacity: .6; cursor: default; }
.pdf-lib-i > span:nth-child(2) { flex: 1; min-width: 0; }
.pdf-lib-i b { display: block; font-size: 13px; }
.pdf-lib-i small { font-size: 11.5px; color: var(--muted-foreground); }
.dlg.pdf-libd .foot { display: flex; gap: 8px; align-items: center; }
.dlg.pdf-libd .foot > [data-imp] { display: inline-flex; gap: 5px; align-items: center; }

/* ── modal preview (PDFX.open) ── */
.dlg.pdfx-dlg { width: min(1040px, calc(100% - 24px)); height: min(640px, 88%); max-height: 92%; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.pdfx-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex: none; }
.pdfx-top > b { flex: 1; min-width: 0; font-family: "Morabba"; font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdfx-host { flex: 1; min-height: 0; display: flex; }
.pdfx-host > .pdf { flex: 1; min-width: 0; }

/* ── paper pages: white ── */
.pdf-view { flex: 1; min-height: 0; overflow: auto; position: relative; background: #fff; padding: 14px 16px; }
.pdf-pages { display: grid; justify-items: center; gap: 14px; }
.pdf-pw { position: relative; flex: none; }
.pdf-page { position: absolute; top: 0; left: 0; transform-origin: top left; background: #fff; color: #222; border: 1px solid #e4e4e4; box-shadow: 0 2px 10px rgb(0 0 0 / .12); direction: rtl; font-size: 10px; line-height: 1.7; overflow: hidden; padding: 30px 34px 40px; font-family: inherit; }
.pdf-page.receipt { padding: 14px 12px; font-size: 9.5px; }
.pg-logo { width: 30px; height: 30px; object-fit: contain; flex: none; border-radius: 6px; }
.pg-logo.big { width: 46px; height: 46px; border-radius: 12px; }
.pg-sigimg { max-width: 110px; max-height: 40px; margin-top: 14px; object-fit: contain; }
.pg-html { font-size: 10px; line-height: 1.9; color: #333; }
.pg-html h1, .pg-html h2, .pg-html h3 { font-family: "Morabba"; color: #222; }
.pg-tb th, .pg-tb td { text-align: start; }
.pg-tb td.t, .pg-tb th.t { text-align: start; }
.pg-tb td.n, .pg-tb th.n { text-align: end; font-variant-numeric: tabular-nums; }
.pg-tb td { word-break: break-word; }
.rc.brand .rc-hr { border-top-color: var(--bp); }
.rc.brand .rc-t.big { color: var(--bp); border-top-color: var(--bp); }

/* ── responsive: settings become a drawer on mobile ── */
[data-dev="tablet"] .pdf-set { width: 200px; }
[data-dev="mobile"] .pdf-setbtn { display: inline-flex; }
[data-dev="mobile"] .pdf-tb { gap: 6px 8px; padding: 6px 8px; }
[data-dev="mobile"] .pdf-pg { margin-inline: 0 auto; }
[data-dev="mobile"] .pdf-body { position: relative; }
[data-dev="mobile"] .pdf-set { display: none; position: absolute; inset-block: 0; inset-inline-start: 0; width: min(290px, 86%); max-height: none; z-index: 4; border: 0; border-inline-end: 1px solid var(--border); box-shadow: var(--shadow-pop); }
[data-dev="mobile"] .pdf.set-open .pdf-set { display: flex; }
[data-dev="mobile"] .pdf-view { min-height: 320px; padding: 10px; overflow-x: hidden; }
.pdf-view .pdf-page .pg-hd { overflow: hidden; }
.pdf-view .pdf-pages { min-width: 0; max-width: 100%; overflow: hidden; }
.pdf-view .pdf-pw { max-width: 100%; overflow: hidden; }
[data-dev="mobile"] .pdf-name { font-size: 15px; }
[data-dev="mobile"] .pdfx-dlg { width: calc(100% - 16px) !important; height: 92%; }
[data-dev="mobile"] .pdfx-top > b { font-size: 14px; }
[data-dev="mobile"] .pdf-acts .btn { padding-inline: 8px; }
/* zoom − / +: one small size for both */
.pdf-zoom [data-z] { width: 22px; height: 22px; min-width: 22px; padding: 0; font-size: 14px; font-weight: 600; line-height: 1; display: inline-grid; place-items: center; }
/* the page area updates instantly — no animation when any option changes */
.pdf-view, .pdf-view * { transition: none !important; animation: none !important; }

/* ── dark mode: only the surroundings turn dark; the paper stays white with light-theme tokens ── */
:root.dark .pdf-view { background: var(--background); }
:root.dark .pdf-page { --background: #faf9f6; --foreground: #1b1b1a; --card: #fffefa; --card-foreground: #1b1b1a; --muted: #f3f1ec; --muted-foreground: #65645f; --border: #dbd8d1; --input: #c7c3b9; --secondary: #efede8; background: #fff; color: #222; color-scheme: light; }
