/* "Scansiona fogli" (public/js/scanner.js): foto dei fogli → PDF. Pensato prima per il telefono. */

.scanner-window .window-body {
  overflow: hidden;
}

.sc {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.sc.sc-drop {
  outline: 3px dashed var(--accent);
  outline-offset: -6px;
}

.sc-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--border);
  background: var(--toolbar-bg);
}

.sc-head h2 {
  margin: 0;
  font-size: 15px;
}

.sc-head small {
  color: var(--text-2);
  font-size: 11.5px;
}

.sc-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.sc-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
}

/* --- schermata iniziale ------------------------------------------------------------------ */

.sc-empty {
  margin: auto;
  max-width: 420px;
  padding: 10px;
  text-align: center;
}

.sc-empty h3 {
  margin: 18px 0 14px;
  font-size: 18px;
}

.sc-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.sc-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 14px;
}

.sc-add .btn-icon {
  width: 18px;
  height: 18px;
}

.sc-add.compact {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
}

.sc-hint {
  margin: 10px 0 0;
  color: var(--text-2);
  font-size: 12px;
}

.sc-tips {
  display: inline-flex;
  flex-direction: column;
  gap: 7px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  color: var(--text-2);
  font-size: 12.5px;
  text-align: left;
}

.sc-tips li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sc-tips .svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #30d158;
}

/* Illustrazione: foglio storto con gli angoli evidenziati e una linea che lo "scansiona" */
.sc-illustration {
  position: relative;
  width: 150px;
  height: 170px;
  margin: 0 auto;
}

.sc-sheet {
  position: absolute;
  inset: 12px 22px;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
  transform: rotate(-7deg);
  animation: sc-straighten 3.2s ease-in-out infinite;
}

.sc-sheet b {
  display: block;
  height: 4px;
  margin: 18px 14px 0;
  border-radius: 2px;
  background: #9ab0d6;
}

.sc-sheet b + b {
  margin-top: 10px;
  width: 60%;
}

.sc-sheet i {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 3px solid #0a84ff;
}

.sc-sheet i:nth-child(1) { top: -6px; left: -6px; border-right: 0; border-bottom: 0; }
.sc-sheet i:nth-child(2) { top: -6px; right: -6px; border-left: 0; border-bottom: 0; }
.sc-sheet i:nth-child(3) { bottom: -6px; right: -6px; border-left: 0; border-top: 0; }
.sc-sheet i:nth-child(4) { bottom: -6px; left: -6px; border-right: 0; border-top: 0; }

.sc-scanline {
  position: absolute;
  left: 10px;
  right: 10px;
  height: 3px;
  border-radius: 2px;
  background: #ffd60a;
  box-shadow: 0 0 14px 4px rgba(255, 214, 10, 0.6);
  animation: sc-scan 3.2s ease-in-out infinite;
}

@keyframes sc-straighten {
  45%,
  80% {
    transform: rotate(0deg);
  }
}

@keyframes sc-scan {
  0%,
  10% {
    top: 8px;
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  70% {
    top: 158px;
    opacity: 1;
  }
  80%,
  100% {
    top: 158px;
    opacity: 0;
  }
}

/* --- editor ---------------------------------------------------------------------------- */

.sc-pageinfo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 600;
}

.sc-ok,
.sc-warn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  font-size: 11.5px;
}

.sc-ok {
  color: #28a745;
}

.sc-ok .svg {
  width: 13px;
  height: 13px;
}

.sc-warn {
  color: #e67e00;
}

.sc-stage {
  position: relative;
  flex: 1;
  min-height: 140px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background:
    repeating-conic-gradient(#2c2c2e 0% 25%, #242426 0% 50%) 0 0 / 20px 20px;
  overflow: hidden;
}

.sc-frame {
  position: relative;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.sc-photo {
  display: block;
  width: 100%;
  height: 100%;
}

.sc-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  touch-action: none;
  cursor: crosshair;
}

.sc-shade {
  fill: rgba(0, 0, 0, 0.5);
}

.sc-quad {
  fill: rgba(10, 132, 255, 0.08);
  stroke: #0a84ff;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}

.sc-handle {
  cursor: grab;
}

.sc-hit {
  fill: transparent;
}

.sc-dot {
  fill: #fff;
  stroke: #0a84ff;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
  transition: fill 0.15s;
}

.sc-handle.active .sc-dot {
  fill: #0a84ff;
}

.sc-loupe {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: 110px;
  height: 110px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.sc-stage.preview {
  padding: 12px;
}

.sc-result {
  display: block;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: fade 0.3s ease;
}

.sc-tools {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
}

.sc-seg.segmented {
  display: inline-flex;
}

.sc-iconbar {
  display: flex;
  gap: 2px;
}

.sc-tool {
  width: 34px;
  height: 34px;
}

.sc-tool.danger {
  color: var(--danger);
}

.sc-tool:disabled {
  opacity: 0.3;
}

/* --- pagine ------------------------------------------------------------------------------- */

.sc-strip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  overflow-x: auto;
  border-top: 0.5px solid var(--border);
  background: var(--row-alt);
}

.sc-strip[hidden] {
  display: none;
}

.sc-thumb {
  position: relative;
  flex-shrink: 0;
  width: 58px;
  height: 78px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
  animation: hx-pop 0.35s ease-out both;
}

.sc-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sc-thumb span {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
}

.sc-thumb.on {
  box-shadow: 0 0 0 3px var(--accent), 0 4px 10px rgba(0, 0, 0, 0.25);
  transform: translateY(-2px);
}

.sc-thumb-warn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #ff9500;
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  line-height: 17px;
}

.sc-strip-add {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  gap: 6px;
  margin-left: 4px;
}

/* --- piede ----------------------------------------------------------------------------------- */

.sc-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 0.5px solid var(--border);
}

.sc-progress {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.sc-progress[hidden] {
  display: none;
}

.sc-progress i {
  display: block;
  width: 0;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, #5ee7df, #2b6fd6);
  transition: width 0.3s;
}

.sc-progress span {
  color: var(--text-2);
  font-size: 11.5px;
}

/* --- telefono ------------------------------------------------------------------------------ */

@container (max-width: 560px) {
  .sc-head small {
    display: none;
  }

  .sc-main {
    padding: 8px 10px;
  }

  .sc-tools {
    justify-content: center;
  }

  .sc-seg .seg-btn {
    padding: 0 9px;
    font-size: 12px;
  }

  .sc-tool {
    width: 40px;
    height: 40px;
  }

  .sc-thumb {
    width: 50px;
    height: 68px;
  }

  .sc-foot .btn {
    height: 38px;
  }

  .sc-create {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sc-sheet,
  .sc-scanline {
    animation: none;
  }
}

/* Pulsante "Fotografa i fogli" nella finestra Carica */
.scan-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: auto;
  margin: -4px 0 14px;
  padding: 10px 12px;
  border-color: rgba(43, 111, 214, 0.3);
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(94, 231, 223, 0.16), rgba(43, 111, 214, 0.12));
  text-align: left;
  white-space: normal;
  line-height: 1.35;
  font-weight: 400;
}

.scan-entry .btn-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: #2b6fd6;
}

.scan-entry strong {
  font-weight: 600;
}
