/**
 * pdf-tools.css — shared styling for the vanilla client-side PDF tools
 * (merge / combine / split / compress). Uses the site design tokens from
 * design-system.css with safe fallbacks so each tool looks native to the
 * product without depending on the old React/webpack CSS.
 */

.ptk {
  --ptk-accent: var(--brand-primary, #2563EB);
  --ptk-border: var(--border-primary, #e2e2e6);
  --ptk-bg: var(--bg-secondary, #f7f7fa);
  --ptk-text: var(--text-primary, #1c1c1e);
  --ptk-text-2: var(--text-secondary, #5b5b66);
  --ptk-radius: var(--radius-lg, 12px);
  font-family: var(--font-sans, system-ui, -apple-system, "Segoe UI", sans-serif);
  color: var(--ptk-text);
}

/* --- Drop zone -------------------------------------------------------- */
.ptk-drop {
  border: 2px dashed var(--ptk-border);
  border-radius: var(--ptk-radius);
  background: var(--ptk-bg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.ptk-drop:hover,
.ptk-drop:focus-visible {
  border-color: var(--ptk-accent);
  outline: none;
}
.ptk-drop--over {
  border-color: var(--ptk-accent);
  background: var(--brand-primary-light, #fdeaea);
}
.ptk-drop-icon { font-size: 40px; line-height: 1; margin-bottom: 12px; }
.ptk-drop-title { font-size: 18px; font-weight: 600; margin: 0 0 4px; }
.ptk-drop-hint { color: var(--ptk-text-2); font-size: 14px; margin: 0; }
.ptk-hidden-input { display: none; }

/* --- File list (combine / merge) ------------------------------------- */
.ptk-filelist { list-style: none; margin: 24px 0 0; padding: 0; }
.ptk-fileitem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--ptk-border);
  border-radius: var(--radius-md, 8px);
  background: #fff;
  margin-bottom: 8px;
  cursor: grab;
}
.ptk-fileitem.ptk-dragging { opacity: .5; }
.ptk-fileitem.ptk-drop-target { border-color: var(--ptk-accent); }
.ptk-fileitem-handle { color: var(--ptk-text-2); font-size: 18px; cursor: grab; }
.ptk-fileitem-name { flex: 1; font-weight: 500; word-break: break-all; }
.ptk-fileitem-meta { color: var(--ptk-text-2); font-size: 13px; white-space: nowrap; }
.ptk-fileitem-remove {
  background: none; border: none; cursor: pointer;
  color: var(--ptk-text-2); font-size: 20px; line-height: 1; padding: 0 4px;
}
.ptk-fileitem-remove:hover { color: var(--ptk-accent); }

/* --- Thumbnail grid --------------------------------------------------- */
.ptk-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
  margin: 24px 0 0;
}
.ptk-thumb {
  position: relative;
  border: 2px solid var(--ptk-border);
  border-radius: var(--radius-md, 8px);
  background: #fff;
  padding: 8px;
  cursor: grab;
  transition: border-color .15s ease, box-shadow .15s ease;
  user-select: none;
}
.ptk-thumb.ptk-thumb--selected { border-color: var(--ptk-accent); }
.ptk-thumb.ptk-thumb--deselected { opacity: .5; }
.ptk-thumb.ptk-dragging { opacity: .4; }
.ptk-thumb.ptk-drop-target { box-shadow: 0 0 0 2px var(--ptk-accent); }
.ptk-thumb canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  background: #fff;
}
.ptk-thumb-placeholder {
  display: flex; align-items: center; justify-content: center;
  height: 140px; color: var(--ptk-text-2); font-size: 12px;
}
.ptk-thumb-label {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px; font-size: 12px; color: var(--ptk-text-2);
}
.ptk-thumb-check { width: 16px; height: 16px; accent-color: var(--ptk-accent); cursor: pointer; }
.ptk-thumb-num { font-variant-numeric: tabular-nums; }
.ptk-thumb-src { display: block; font-size: 10px; color: var(--ptk-text-2); margin-top: 2px; word-break: break-all; }
.ptk-thumb-canvas-holder { transition: transform .15s ease; }

/* Per-page controls (organize): rotate + delete buttons over the thumb. */
.ptk-thumb-controls {
  position: absolute; top: 6px; right: 6px;
  display: flex; gap: 4px;
}
.ptk-thumb-ctrl {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--ptk-border);
  border-radius: var(--radius-sm, 6px);
  background: rgba(255, 255, 255, .92);
  color: var(--ptk-text);
  font-size: 15px; line-height: 1; cursor: pointer; padding: 0;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.ptk-thumb-ctrl:hover { background: #fff; border-color: var(--ptk-accent); color: var(--ptk-accent); }
.ptk-thumb-ctrl--del:hover { border-color: var(--color-error, #b3261e); color: var(--color-error, #b3261e); }

/* --- Controls / options ---------------------------------------------- */
.ptk-panel {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--ptk-border);
  border-radius: var(--ptk-radius);
  background: var(--ptk-bg);
}
.ptk-panel h3 { margin: 0 0 12px; font-size: 16px; }
.ptk-radio-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.ptk-radio-row input { margin-top: 3px; accent-color: var(--ptk-accent); }
.ptk-radio-row label { cursor: pointer; }
.ptk-radio-row .ptk-radio-desc { display: block; font-size: 13px; color: var(--ptk-text-2); }
.ptk-inline-control { margin: 6px 0 0 26px; }
.ptk-inline-control input[type="number"],
.ptk-inline-control input[type="text"] {
  padding: 8px 10px;
  border: 1px solid var(--ptk-border);
  border-radius: var(--radius-sm, 6px);
  font-size: 14px;
  font-family: inherit;
}
.ptk-inline-control input[type="text"] { width: 100%; max-width: 360px; }

/* --- Action bar + buttons -------------------------------------------- */
.ptk-actions {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-top: 24px;
}
.ptk-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md, 8px);
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, opacity .15s ease;
}
.ptk-btn--primary { background: var(--ptk-accent); color: #fff; }
.ptk-btn--primary:hover { background: var(--brand-primary-hover, #1D4ED8); }
.ptk-btn--secondary {
  background: transparent; color: var(--ptk-text);
  border: 1px solid var(--ptk-border);
}
.ptk-btn--secondary:hover { background: #fff; }
.ptk-btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Progress bar ----------------------------------------------------- */
.ptk-progress { display: none; margin-top: 20px; }
.ptk-progress-track {
  height: 10px;
  border-radius: var(--radius-full, 999px);
  background: var(--ptk-border);
  overflow: hidden;
}
.ptk-progress-fill {
  height: 100%; width: 0%;
  background: var(--ptk-accent);
  border-radius: inherit;
  transition: width .2s ease;
}
.ptk-progress-label { margin-top: 8px; font-size: 13px; color: var(--ptk-text-2); }

/* --- Status / inline messages ---------------------------------------- */
.ptk-status {
  display: none;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md, 8px);
  font-size: 14px;
}
.ptk-status--error {
  background: var(--color-error-light, #fdeaea);
  color: var(--color-error, #b3261e);
}
.ptk-status--info {
  background: var(--color-info-light, #e8f0fe);
  color: var(--color-info, #1a56c4);
}
.ptk-status--warning {
  background: var(--color-warning-light, #fff4e5);
  color: var(--color-warning, #8a5300);
}
.ptk-status--success {
  background: var(--color-success-light, #e6f4ea);
  color: var(--color-success, #1e7e34);
}

/* --- Size comparison (compress) -------------------------------------- */
.ptk-sizebox {
  display: flex; flex-wrap: wrap; gap: 24px;
  margin-top: 20px; padding: 16px 20px;
  border: 1px solid var(--ptk-border);
  border-radius: var(--ptk-radius);
  background: #fff;
}
.ptk-sizebox div { text-align: center; }
.ptk-sizebox .ptk-size-num { font-size: 22px; font-weight: 700; }
.ptk-sizebox .ptk-size-cap { font-size: 12px; color: var(--ptk-text-2); text-transform: uppercase; letter-spacing: .04em; }
.ptk-size-saved { color: var(--color-success, #1e7e34); }
