/* جود — الماسح الضوئي (styles for assets/js/scanner.js) */

.jsc { --jsc-brand: var(--st-brand, #4f46e5); }

/* ---------- main panel ---------- */
.jsc-actions { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: center; }
.jsc-actions .btn { border-radius: 999px; padding-inline: 1.5rem; }
/* The native-camera button only makes sense on touch devices; on a desktop
   the "capture" attribute is ignored and it duplicates "import images". */
@media (hover: hover) and (pointer: fine) { .jsc-phone { display: none !important; } }

.jsc-engine { margin-top: 1rem; text-align: center; }

.jsc-empty {
  margin-top: 1.5rem; padding: 2.5rem 1rem; text-align: center;
  border: 2px dashed var(--st-border, #cbd5e1); border-radius: 16px;
  color: var(--st-text-muted, #64748b); background: var(--st-surface-2, #f8fafc);
}
.jsc-empty i { font-size: 3rem; display: block; margin-bottom: .5rem; color: var(--jsc-brand); opacity: .8; }

.jsc-pages {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.jsc-page {
  background: var(--st-surface, #fff); border: 1px solid var(--st-border, #e2e8f0);
  border-radius: 12px; padding: .5rem; display: flex; flex-direction: column; gap: .5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.jsc-thumb {
  position: relative; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden;
  background: var(--st-surface-2, #f1f5f9); cursor: zoom-in;
  display: flex; align-items: center; justify-content: center;
}
.jsc-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.jsc-spin {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.55);
}
.jsc-err {
  position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--st-danger, #dc2626); color: #fff; font-weight: 800; font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
}
.jsc-num {
  position: absolute; bottom: 6px; right: 6px; min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 999px; background: rgba(15,23,42,.75); color: #fff;
  font-size: .75rem; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.jsc-bar { display: flex; justify-content: space-between; gap: 2px; }
.jsc-bar .btn { flex: 1; padding: .25rem 0; }

.jsc-export {
  margin-top: 1.5rem; padding: 1.25rem; border-radius: 14px;
  background: var(--st-surface-2, #f8fafc); border: 1px solid var(--st-border, #e2e8f0);
}
.jsc-export .jsc-dl { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.jsc-ocr { padding-inline-start: 1.75rem; }

/* ---------- shared modal base ---------- */
html.jsc-lock, html.jsc-lock body { overflow: hidden; }
.jsc-modal {
  position: fixed; inset: 0; z-index: 2000; background: rgba(8,10,25,.94);
  display: flex; align-items: center; justify-content: center;
}
.jsc-x { position: absolute; top: 12px; right: 12px; z-index: 2; border-radius: 50%; width: 44px; height: 44px; }
.jsc-preview img { max-width: 94vw; max-height: 90vh; object-fit: contain; background: #fff; box-shadow: 0 10px 40px rgba(0,0,0,.5); }

/* ---------- crop editor ---------- */
.jsc-crop { flex-direction: column; align-items: stretch; justify-content: stretch; }
.jsc-crop__head { color: #fff; text-align: center; font-weight: 700; padding: 14px 12px 6px; }
.jsc-crop__stage {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.jsc-crop__cv { touch-action: none; cursor: crosshair; box-shadow: 0 6px 30px rgba(0,0,0,.5); }
.jsc-loupe {
  position: absolute; top: 12px; right: 12px; width: 130px; height: 130px;
  pointer-events: none; opacity: 0; transition: opacity .12s;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.6));
}
.jsc-loupe.is-on { opacity: 1; }
.jsc-loupe.is-left { right: auto; left: 12px; }
.jsc-crop__foot {
  display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
}
.jsc-crop__foot .btn { border-radius: 999px; }

/* ---------- live camera ---------- */
.jsc-cam { position: fixed; inset: 0; z-index: 2000; background: #000; color: #fff; }
.jsc-cam__view { position: absolute; inset: 0; }
.jsc-cam__view video, .jsc-cam__view canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}
.jsc-cam__view canvas { pointer-events: none; }
.jsc-cam__hint {
  position: absolute; left: 50%; top: 72px; transform: translateX(-50%);
  background: rgba(0,0,0,.55); padding: .4rem .9rem; border-radius: 999px;
  font-size: .9rem; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
.jsc-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.jsc-flash.is-on { animation: jscFlash .35s ease-out; }
@keyframes jscFlash { from { opacity: .85; } to { opacity: 0; } }

.jsc-cam__top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  background: linear-gradient(rgba(0,0,0,.55), transparent);
}
.jsc-cam__bottom {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 18px 20px calc(22px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0,0,0,.65));
}
.jsc-round, .jsc-pill {
  border: 0; color: #fff; background: rgba(255,255,255,.16); backdrop-filter: blur(6px);
  height: 44px; display: inline-flex; align-items: center; justify-content: center;
}
.jsc-round { width: 44px; border-radius: 50%; font-size: 1.15rem; }
.jsc-pill { border-radius: 999px; padding: 0 1rem; font-weight: 700; font-size: .9rem; }
.jsc-round.is-on, .jsc-pill.is-on { background: #facc15; color: #111; }
.jsc-last {
  justify-self: start; width: 54px; height: 70px; border-radius: 8px;
  border: 2px solid rgba(255,255,255,.85); background: rgba(255,255,255,.1) center / cover no-repeat;
  position: relative;
}
.jsc-last span {
  position: absolute; top: -8px; left: -8px; min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 999px; background: var(--jsc-brand); font-size: .75rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.jsc-shutter {
  width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; background: transparent;
  padding: 5px; display: flex;
}
.jsc-shutter span { flex: 1; border-radius: 50%; background: #fff; transition: transform .1s; }
.jsc-shutter:active span { transform: scale(.88); }
.jsc-done { justify-self: end; background: var(--jsc-brand); }

/* ---------- dark mode ---------- */
:root[data-theme="dark"] .jsc-spin { background: rgba(15,23,42,.55); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .jsc-spin { background: rgba(15,23,42,.55); }
}
