/* =====================================================================================
   FILE BARU (5 Des 2026): gaya PEMINDAI DOKUMEN (assets/js/alat-pemindai.js, kelas .ps-*)
   Layar penuh di atas halaman. Kamera selalu gelap (seperti aplikasi kamera); editor ikut tema situs.
   Disalin & disesuaikan dari gaya alat/scan-dokumen.php (.sd-*).
===================================================================================== */
html.ps-lock, html.ps-lock body { overflow: hidden; }
.ps { position: fixed; inset: 0; z-index: 2600; }
.ps[hidden], .ps [hidden] { display: none !important; }

/* Kamera */
.ps-cam { position: absolute; inset: 0; background: #000; display: flex; flex-direction: column; }
.ps-cam video { flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.ps-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.ps-flash.is-on { animation: psflash .35s ease-out; }
@keyframes psflash { from { opacity: .85; } to { opacity: 0; } }
.ps-cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: .6rem; padding: calc(.6rem + env(safe-area-inset-top, 0px)) .75rem .6rem; background: linear-gradient(rgba(0, 0, 0, .65), transparent); }
.ps-tip { flex: 1 1 auto; text-align: center; color: #fff; font-size: .85rem; font-weight: 700; line-height: 1.35; text-shadow: 0 1px 3px #000; }
.ps-ico { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .45); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.ps-ico[aria-pressed="true"] { background: #fff; color: #000; }
.ps-cam-bot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .75rem; padding: 1rem .75rem calc(1rem + env(safe-area-inset-bottom, 0px)); background: #000; }
.ps-alt { justify-self: start; min-height: 44px; padding: .4rem .9rem; border-radius: 50px; border: 1px solid rgba(255, 255, 255, .35); background: transparent; color: #fff; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; }
.ps-alt.is-done { justify-self: end; background: var(--sol-accent, #268bd2); border-color: var(--sol-accent, #268bd2); }
.ps-alt:disabled { opacity: .4; cursor: default; }
.ps-shutter { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff; background: rgba(255, 255, 255, .25); box-shadow: 0 0 0 3px rgba(0, 0, 0, .5); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform .15s ease; }
.ps-shutter:active { transform: scale(.9); }
.ps-shutter:disabled { opacity: .4; }
.ps-cam button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Editor sudut */
.ps-ed { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); overflow-y: auto; -webkit-overflow-scrolling: touch; padding: max(.75rem, env(safe-area-inset-top, 0px)) .75rem max(.75rem, env(safe-area-inset-bottom, 0px)); }
.ps-box { max-width: 720px; margin: 0 auto; background: var(--sol-bg-card, #fff); color: var(--sol-text-main, #222); border-radius: 1rem; padding: .9rem; box-shadow: 0 12px 40px rgba(0, 0, 0, .4); }
.ps-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: .6rem; }
.ps-head strong { display: block; font-size: 1rem; line-height: 1.3; }
.ps-head span { display: block; font-size: .8rem; color: var(--sol-text-muted, #666); }
.ps-x { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--sol-border-soft, #ddd); background: transparent; color: inherit; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.ps-stagewrap { display: flex; justify-content: center; border-radius: .8rem; background: var(--sol-bg-main, #f3f3f3); border: 1px solid var(--sol-border-soft, #ddd); padding: .5rem; }
.ps-stage { position: relative; display: inline-block; line-height: 0; max-width: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.ps-stage canvas[data-r="view"] { display: block; max-width: 100%; max-height: 56vh; width: auto; height: auto; border-radius: .35rem; }
.ps-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; cursor: crosshair; }
.ps-svg polygon { fill: color-mix(in srgb, var(--sol-accent, #268bd2) 18%, transparent); stroke: var(--sol-accent, #268bd2); stroke-width: 2; vector-effect: non-scaling-stroke; }
.ps-svg .ps-shade { fill: rgba(0, 0, 0, .45); fill-rule: evenodd; stroke: none; }
.ps-svg circle { fill: rgba(255, 255, 255, .9); stroke: var(--sol-accent, #268bd2); stroke-width: 3; vector-effect: non-scaling-stroke; cursor: grab; }
.ps-svg circle:focus { outline: none; stroke: var(--sol-warning, #b58900); }
.ps-svg circle.is-on { fill: var(--sol-accent, #268bd2); }
.ps-loupe { position: absolute; top: 8px; left: 8px; width: 120px; height: 120px; border-radius: 50%; border: 3px solid var(--sol-accent, #268bd2); box-shadow: 0 6px 18px rgba(0, 0, 0, .45); background: #000; pointer-events: none; }
.ps-loupe.is-right { left: auto; right: 8px; }
.ps-hint { margin: .5rem 0 0; font-size: .8rem; line-height: 1.45; color: var(--sol-text-muted, #666); text-align: center; }
.ps-tools, .ps-filter { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; margin-top: .6rem; }
.ps-tools button, .ps-filter button { font: inherit; font-size: .8rem; font-weight: 700; min-height: 38px; padding: .3rem .8rem; border-radius: 50px; border: 1px solid var(--sol-border-soft, #ddd); background: var(--sol-bg-card, #fff); color: var(--sol-text-main, #222); cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; }
.ps-tools button:hover, .ps-filter button:hover { border-color: var(--sol-accent, #268bd2); color: var(--sol-accent, #268bd2); }
.ps-filter button.is-on { background: var(--sol-accent, #268bd2); border-color: var(--sol-accent, #268bd2); color: #fff; }
.ps-tools button:disabled { opacity: .45; cursor: default; }
.ps-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: .8rem; }

/* Sedang memproses */
.ps-busy { position: absolute; inset: 0; background: rgba(0, 0, 0, .7); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem; color: #fff; text-align: center; padding: 1rem; }
.ps-spin { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .3); border-top-color: #fff; animation: psspin .8s linear infinite; }
@keyframes psspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ps-spin { animation-duration: 2s; } .ps-flash.is-on { animation: none; } }
@media (max-width: 575.98px) { .ps-ed { padding-left: .4rem; padding-right: .4rem; } .ps-box { padding: .7rem; } .ps-stage canvas[data-r="view"] { max-height: 50vh; } }
@media print { .ps { display: none !important; } }
