/* ══ PAGE THUMBNAIL ══ */
/* Componente <page-thumbnail> — miniatura di una pagina PDF con immagine, checkbox e grip */
/* Componente generico riusabile da: Delete, Split, Rotate, Reorder */
/* Attributi: page (numero), selectable (checkbox), sortable (grip handle) */

/* ── Griglia contenitore ── */
/* L'app crea un <div class="page-grid"> e lo riempie di <page-thumbnail> */

.page-grid {
  text-align: center;
  width: 100%;
  max-width: 900px;
  font-size: 0;
}

/* ── Card thumbnail (il custom element stesso) ── */

page-thumbnail {
  background: white;
  border: 2px solid var(--grey-200);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  display: inline-block;
  vertical-align: top;
  width: 160px;
  margin: 8px;
  font-size: 13px;
}

page-thumbnail:hover {
  border-color: var(--grey-300);
  box-shadow: var(--shadow-1);
}

page-thumbnail.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(234, 67, 53, 0.2);
}

/* ── Thumbnail sortable: cursore grab ── */
page-thumbnail[sortable] {
  cursor: grab;
}

/* ── Area anteprima (contiene l'immagine e la checkbox) ── */

.page-thumb-preview {
  background: var(--grey-50);
  position: relative;
  overflow: hidden;
}

/* Immagine dell'anteprima — ha aspect ratio naturale dal contenuto */
.page-thumb-img {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Checkbox di selezione (visibile solo con attributo selectable) ── */

.page-thumb-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--grey-300);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  pointer-events: none;
}

page-thumbnail:hover .page-thumb-check {
  border-color: var(--grey-500);
}

page-thumbnail.selected .page-thumb-check {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Footer (numero pagina + grip opzionale) ── */

.page-thumb-footer {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--grey-200);
}

.page-thumb-number {
  font-size: 12px;
  font-weight: 500;
  color: var(--grey-700);
}

page-thumbnail.selected .page-thumb-number {
  color: var(--accent);
}

/* ── Grip handle per riordino (visibile solo con attributo sortable) ── */

.page-thumb-grip {
  color: var(--grey-300);
  flex-shrink: 0;
  cursor: grab;
  display: flex;
  align-items: center;
}

.page-thumb-grip:hover {
  color: var(--grey-500);
}

/* ── Stati durante drag & drop ── */

page-thumbnail.sortable-ghost {
  opacity: 0.4;
  border-color: var(--blue);
}

page-thumbnail.sortable-chosen {
  box-shadow: var(--shadow-2);
  cursor: grabbing;
}

page-thumbnail.sortable-fallback {
  opacity: 0.9 !important;
  box-shadow: var(--shadow-2) !important;
  width: 160px !important;
  height: auto !important;
}
