/* DOCScanner - interfaccia PC */

:root {
  color-scheme: light dark;

  --bg: #f4f6fa;
  --bg-soft: #eaeef5;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #dfe4ec;
  --border-strong: #c8d0dd;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --accent-text: #ffffff;
  --ok: #10b981;
  --danger: #e11d48;

  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.06), 0 1px 1px rgb(15 23 42 / 0.04);
  --shadow-md: 0 10px 30px -12px rgb(15 23 42 / 0.25);
  --topbar-height: 64px;
  --actionbar-height: 76px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --bg-soft: #0f172a;
    --surface: #131c2e;
    --surface-2: #182236;
    --border: #263349;
    --border-strong: #35455f;
    --text: #e8eef8;
    --muted: #93a4bd;
    --accent: #60a5fa;
    --accent-soft: #1e3a5f;
    --accent-text: #08111f;
    --shadow-md: 0 10px 30px -12px rgb(0 0 0 / 0.6);
  }
}

* { box-sizing: border-box; }

body.desktop {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: var(--actionbar-height);
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-height);
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em; }

.brand__mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #a855f7));
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.25);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 auto 0 12px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

.status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background 200ms ease, box-shadow 200ms ease;
}

.status[data-online="true"] { color: var(--text); }
.status[data-online="true"] .status__dot {
  background: var(--ok);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent);
}

/* ------------------------------------------------------------------ layout */
.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 28px;
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 20px; padding: 20px 16px 32px; }
}

.panel {
  position: sticky;
  top: calc(var(--topbar-height) + 24px);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

@media (max-width: 900px) { .panel { position: static; } }

.panel__title { margin: 0 0 6px; font-size: 17px; letter-spacing: -0.01em; }
.panel__text { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; }

.qr {
  width: 100%;
  max-width: 240px;
  height: auto;
  image-rendering: pixelated;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px;
}

.linkbox { display: flex; gap: 8px; margin-top: 16px; }

.linkbox__input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-overflow: ellipsis;
}

.steps {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  text-align: left;
  display: grid;
  gap: 10px;
}

.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--muted);
  font-size: 13px;
}

.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
}

/* ---------------------------------------------------------------- contenuto */
.content__head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.content__title { margin: 0; font-size: 17px; letter-spacing: -0.01em; }

.counter {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 160ms ease, box-shadow 160ms ease;
  animation: pop 260ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.card__button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.card__image {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--surface-2);
}

.card__index {
  position: absolute;
  top: 10px;
  left: 10px;
  min-width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0 7px;
  border-radius: 8px;
  background: rgb(15 23 42 / 0.72);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  backdrop-filter: blur(4px);
}

.card__delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: rgb(15 23 42 / 0.72);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms ease, background 140ms ease;
  backdrop-filter: blur(4px);
}

.card:hover .card__delete,
.card__delete:focus-visible { opacity: 1; }
.card__delete:hover { background: var(--danger); }

@media (hover: none) { .card__delete { opacity: 1; } }

.empty {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 64px 24px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--muted);
}

.empty[hidden] { display: none; }

.empty__icon {
  width: 46px;
  height: 56px;
  border-radius: 8px;
  border: 2px solid var(--border-strong);
  background:
    linear-gradient(var(--border-strong), var(--border-strong)) 10px 16px / 26px 3px no-repeat,
    linear-gradient(var(--border-strong), var(--border-strong)) 10px 26px / 26px 3px no-repeat,
    linear-gradient(var(--border-strong), var(--border-strong)) 10px 36px / 16px 3px no-repeat;
  margin-bottom: 8px;
}

.empty__title { margin: 0; font-weight: 600; color: var(--text); }
.empty__text { margin: 0; font-size: 13.5px; }

/* ------------------------------------------------------------------ actionbar */
.actionbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  height: var(--actionbar-height);
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.field { display: flex; align-items: center; gap: 12px; }
.field__label { color: var(--muted); font-size: 13px; }

.field__control {
  display: flex;
  align-items: center;
  padding: 0 12px 0 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field__control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.field__control input {
  width: 260px;
  padding: 9px 8px 9px 12px;
  font: inherit;
  color: var(--text);
  background: none;
  border: 0;
  outline: none;
}

.field__suffix { color: var(--muted); font-size: 13px; }

@media (max-width: 720px) {
  .actionbar { justify-content: space-between; padding: 0 16px; gap: 10px; }
  .field__label { display: none; }
  .field__control input { width: 100%; min-width: 0; }
  .field { flex: 1; min-width: 0; }
}

/* --------------------------------------------------------------------- btn */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, transform 80ms ease, opacity 140ms ease;
}

.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
}
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }

.btn--ghost { background: transparent; }
.btn--small { padding: 7px 12px; font-size: 13px; }

:where(button, input, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --------------------------------------------------------------- lightbox */
.lightbox {
  width: min(94vw, 1000px);
  max-height: 92vh;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

.lightbox::backdrop { background: rgb(6 10 20 / 0.72); backdrop-filter: blur(3px); }

.lightbox img {
  display: block;
  width: 100%;
  max-height: calc(92vh - 62px);
  object-fit: contain;
  background: var(--bg-soft);
}

.lightbox__bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 62px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.lightbox__bar #closeLightbox { margin-left: auto; margin-right: 12px; }
.lightbox__bar #prevPage { margin-left: 12px; }

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--actionbar-height) + 18px);
  transform: translate(-50%, 12px);
  z-index: 40;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgb(15 23 42 / 0.92);
  color: #fff;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------- errorpage */
.errorpage {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
}

.errorpage__code { margin: 0; color: var(--muted); font-size: 13px; letter-spacing: 0.12em; }
.errorpage__title { margin: 0; font-size: 22px; }
.errorpage__text { margin: 0 0 18px; color: var(--muted); }

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
