/* Tool UI shared by the extension toolbox and the website (purrpdf.com). */

.tool-body, .work { display: flex; flex-direction: column; gap: 16px; }

/* Drop zone & files */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 44px 16px;
  border: 2px dashed color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface));
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.dropzone strong { font-size: 17px; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.over { border-style: solid; }
/* The icon sits in a solid accent circle, so the whole box reads as "click or drop here". */
.dropzone-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 6px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 26px; line-height: 1; box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent); transition: transform 0.15s; }
.dropzone:hover .dropzone-icon, .dropzone.over .dropzone-icon { transform: translateY(-3px); }
/* Once files are in (merge, images → PDF), the drop zone shrinks to an "add more" bar. */
.tool-body:has(.file-row, .page-card) .dropzone { flex-direction: row; justify-content: center; gap: 12px; padding: 12px 16px; }
.tool-body:has(.file-row, .page-card) .dropzone strong { font-size: 15px; }
.tool-body:has(.file-row, .page-card) .dropzone-icon { width: 34px; height: 34px; margin: 0; font-size: 17px; box-shadow: none; }

.file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.file-chip > span:first-child { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); }
.file-chip .btn { margin-inline-start: auto; }

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: grab;
}
.file-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drag-handle { color: var(--muted); letter-spacing: -3px; }
.row-actions { display: inline-flex; gap: 2px; }
.dragging { opacity: 0.4; }

/* Options */
.options { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; gap: 12px; }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
/* A tool's main button stays in reach on long pages (many files, many options). */
.tool-body .actions:not(dialog .actions) {
  position: sticky;
  bottom: 0;
  z-index: 4;
  padding: 12px 0;
  background: var(--bg);
}
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar.sticky { position: sticky; top: 0; z-index: 5; padding: 10px 0; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.toolbar.sticky .btn.primary { min-height: 42px; padding: 0 22px; font-size: 15px; }
.spacer { flex: 1; }
.toolbar.tools { margin: 2px 0 12px; }
.toolbar .divider { align-self: stretch; width: 1px; margin: 4px 4px; background: var(--border); }
.toolbar.sticky + .toolbar.tools { margin-top: 0; }

.option-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.option-card {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  align-content: start;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.option-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.option-card .small { grid-column: 2; }
.option-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.option-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border: 1px solid var(--success);
  border-radius: var(--radius);
  background: var(--success-soft);
}
.size-compare { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.result-card .btn.primary { min-height: 44px; padding: 0 24px; font-size: 15px; background: var(--success); border-color: var(--success); box-shadow: none; }
.result-card .btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--success) 85%, #000); }
.arrow { color: var(--muted); }
.badge { padding: 2px 8px; border-radius: 99px; background: var(--surface-2); font-size: 12px; font-weight: 700; }
.badge.success { background: var(--success); color: #fff; }

.panel { padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panel summary { font-weight: 600; cursor: pointer; margin-bottom: 10px; }
.panel .small { margin-top: 8px; }

/* Page thumbnails */
.page-grid, .image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.page-card {
  margin: 0;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: grab;
  transition: border-color 0.15s;
}
.page-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.page-card { position: relative; }
.page-card.selected { border-color: var(--accent); background: var(--accent-soft); }
/* A check badge, so selected pages are obvious at a glance, not just by colour. */
.page-card.selected::after { content: '✓'; position: absolute; top: -8px; inset-inline-end: -8px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; font-weight: 800; box-shadow: 0 2px 6px rgb(0 0 0 / 0.2); }
.thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  overflow: hidden;
  cursor: pointer;
}
.thumb canvas, .thumb img { max-width: 100%; max-height: 100%; box-shadow: 0 1px 4px rgb(0 0 0 / 0.2); transition: transform 0.2s; }
.thumb canvas { max-height: 190px; }
.thumb-placeholder { width: 120px; height: 160px; background: var(--surface-2); border-radius: 4px; }
.page-card figcaption { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; font-weight: 600; }

/* Sign */
.hint-line { margin-top: -8px; }
.sign-pages { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sign-page { position: relative; box-shadow: var(--shadow), 0 0 0 1px var(--border); background: #fff; }
.sign-page canvas { display: block; }
.sign-pages.placing .sign-page canvas { cursor: crosshair; }
.page-label { margin-bottom: 16px; }

.overlay { position: absolute; border: 1px dashed transparent; touch-action: none; }
.overlay:hover, .overlay:focus-within { border-color: var(--accent); }
.overlay.image { cursor: move; }
.overlay img { display: block; width: 100%; pointer-events: none; user-select: none; }
.overlay-text { padding: 2px 4px; min-width: 20px; white-space: pre; outline: none; }
.overlay-tools {
  position: absolute;
  bottom: 100%;
  left: -1px;
  display: none;
  gap: 2px;
  padding: 2px;
  border-radius: 6px 6px 0 0;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
}
.overlay:hover .overlay-tools, .overlay:focus-within .overlay-tools { display: flex; }
.overlay-tools button, .move-handle {
  padding: 2px 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.move-handle { cursor: move; }
.overlay-tools button:hover { background: rgb(255 255 255 / 0.2); }
.resize-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: nwse-resize;
  display: none;
}
.overlay:hover .resize-handle { display: block; }

.sig-dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
}
.sig-dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.sig-dialog > * + * { margin-top: 12px; }
.sig-pad { display: block; width: 100%; aspect-ratio: 1000 / 360; border: 1px dashed var(--border); border-radius: 8px; background: #fff; touch-action: none; cursor: crosshair; }
.sig-typed { width: 100%; font: 40px "Segoe Script", "Brush Script MT", "Snell Roundhand", "Apple Chancery", cursive; min-height: 80px; background: #fff; color: #111; }
.saved-sig { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.saved-sig img { max-height: 48px; max-width: 220px; margin-inline-end: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab { padding: 6px 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Page numbers & watermark */
.stamp-layout { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: start; }
.stamp-options { display: flex; flex-direction: column; gap: 16px; }
.stamp-figure { margin: 0; text-align: center; }
.stamp-preview { width: 300px; min-height: 200px; background: var(--surface-2); border-radius: 4px; }
.stamp-preview canvas { display: block; box-shadow: var(--shadow), 0 0 0 1px var(--border); }
@media (max-width: 720px) {
  .stamp-layout { grid-template-columns: 1fr; }
  .stamp-figure { justify-self: center; }
}

/* Unlock & protect */
.notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  transform: translate(-50%, 120px);
  transition: transform 0.25s;
  z-index: 100;
}
#toast.show { transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }
#toast.success { background: var(--success); color: #fff; }

/* Redact */
.redact-pages .sign-page canvas { cursor: crosshair; touch-action: none; }
.redact-page { touch-action: none; user-select: none; }
.redact-box { position: absolute; background: #000; box-shadow: 0 0 0 1px var(--accent); }
.redact-box.draft { background: rgb(0 0 0 / 0.55); pointer-events: none; }
.redact-box button {
  position: absolute;
  top: -10px;
  inset-inline-end: -10px;
  display: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}
.redact-box:hover button, .redact-box button:focus-visible { display: grid; place-items: center; }
@media (hover: none) { .redact-box button { display: grid; place-items: center; } }

/* Share dialog (after a finished job) */
.share-dialog { position: fixed; width: min(360px, calc(100vw - 32px)); padding: 18px 18px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); text-align: center; }
.share-dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.share-logo { display: block; margin: 0 auto 8px; border-radius: 10px; }
.share-dialog h2 { margin: 0 24px 12px; font-size: 17px; }
.share-x { position: absolute; top: 6px; inset-inline-end: 8px; border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.share-buttons { display: flex; justify-content: center; gap: 10px; }
.share-btn { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; color: #fff; cursor: pointer; }
.share-btn.copy { background: var(--text); color: var(--bg); }
.share-btn:hover { filter: brightness(1.12); }
.share-donate { display: flex; margin-top: 12px; padding: 9px 14px; font-size: 14px; }
