/* ===========================================================
   PDF Toolkit — feuille de style
   Palette et esprit visuel inspirés d'iLovePDF (rouge #E5322D,
   fond gris clair #F5F5FA, cartes blanches arrondies).
   =========================================================== */

:root {
  --red: #e5322d;
  --red-dark: #bd060a;
  --ink: #292931;
  --ink-soft: #47474f;
  --grey-bg: #f5f5fa;
  --grey-border: #d6d6df;
  --grey-border-soft: #ebebf4;
  --white: #ffffff;
  --green: #4acd86;
  --green-bg: #c0fddc;
  --amber: #d76c00;
  --amber-bg: #ffe4c9;
  --blue: #008ee9;
  --blue-bg: #def2ff;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 2px 10px rgba(22, 22, 22, 0.06);
  --shadow-hover: 0 10px 30px rgba(22, 22, 22, 0.10);
  --font: "Graphik", "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--grey-bg);
  color: var(--ink-soft);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; }

button { font-family: inherit; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--white);
  border-bottom: 1px solid var(--grey-border);
  height: 64px;
  display: flex;
  align-items: center;
}
.site-header__inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 20px;
  cursor: pointer;
  border: none;
  background: none;
}
.brand__mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.brand__tagline {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-soft);
  margin-left: 4px;
}
.header-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
  background: var(--green-bg);
  padding: 6px 12px;
  border-radius: 999px;
}
.header-badge svg { width: 14px; height: 14px; }

/* ---------- Layout ---------- */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 24px 96px;
}

/* ---------- Home hero ---------- */
.home-title {
  text-align: center;
  max-width: 900px;
  margin: 0 auto 40px;
}
.home-title h1 {
  font-size: 40px;
  line-height: 1.15;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 12px;
}
.home-title p {
  font-size: 17px;
  line-height: 1.6;
  margin: 0;
}
@media (max-width: 640px) {
  .home-title h1 { font-size: 28px; }
  .home-title p { font-size: 15px; }
}

/* ---------- Tool grid ---------- */
.tools-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 32px;
}
.tag {
  border: 1px solid var(--grey-border);
  background: var(--white);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink-soft);
  transition: all 0.15s ease;
}
.tag:hover { border-color: var(--ink); color: var(--ink); }
.tag.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media (max-width: 1024px) { .tools-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px) { .tools-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 440px) { .tools-grid { grid-template-columns: 1fr; } }

.tool-card {
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}
.tool-card:hover {
  border-color: var(--ink);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.tool-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: #fff;
}
.tool-card__icon svg { width: 22px; height: 22px; }
.tool-card h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 6px;
}
.tool-card p {
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  color: var(--ink-soft);
}
.tool-card__badge {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 999px;
}
.badge-beta { background: var(--amber-bg); color: var(--amber); }
.badge-limited { background: var(--blue-bg); color: var(--blue); }

/* ---------- Home / tool panel visibility ---------- */
#homeView { display: none; }
#homeView.active { display: block; }
.tool-panel { display: none; }
.tool-panel.active { display: block; }

.tool-panel__header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}
.back-btn {
  border: 1px solid var(--grey-border);
  background: var(--white);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
}
.back-btn:hover { border-color: var(--ink); }
.tool-panel__header h2 { margin: 0 0 4px; color: var(--ink); font-size: 24px; font-weight: 600; }
.tool-panel__header p { margin: 0; font-size: 14px; }

.notice {
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
}
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.notice--info { background: var(--blue-bg); color: #0a5b91; }
.notice--warn { background: var(--amber-bg); color: #8a4c00; }
.notice--ok { background: var(--green-bg); color: #14713d; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--grey-border);
  border-radius: var(--radius-lg);
  background: var(--white);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.dropzone.dragover { border-color: var(--red); background: #fff6f5; }
.dropzone__icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--grey-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--red);
}
.dropzone h4 { margin: 0 0 6px; color: var(--ink); font-size: 16px; font-weight: 600; }
.dropzone p { margin: 0; font-size: 13px; }
.dropzone input[type="file"] { display: none; }

/* ---------- File chip list (merge order) ---------- */
.file-list { display: flex; flex-direction: column; gap: 8px; margin: 20px 0; }
.file-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.file-chip__handle { cursor: grab; color: var(--grey-border); }
.file-chip__handle:active { cursor: grabbing; }
.file-chip__icon {
  width: 34px; height: 34px; border-radius: 8px;
  background: #fde4df; color: var(--red);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.file-chip__icon svg { width: 18px; height: 18px; }
.file-chip__meta { flex: 1; min-width: 0; }
.file-chip__name { font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip__size { font-size: 11px; color: var(--ink-soft); }
.file-chip__remove {
  border: none; background: none; cursor: pointer; color: var(--ink-soft);
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.file-chip__remove:hover { background: var(--grey-bg); color: var(--red); }

/* ---------- Page thumbnails grid ---------- */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.page-thumb {
  background: var(--white);
  border: 2px solid var(--grey-border);
  border-radius: var(--radius-md);
  padding: 10px;
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s ease, opacity 0.15s ease;
  user-select: none;
}
.page-thumb.selected { border-color: var(--red); }
.page-thumb.selected .page-thumb__check { background: var(--red); border-color: var(--red); }
.page-thumb.selected .page-thumb__check svg { opacity: 1; }
.page-thumb.marked-delete { opacity: 0.35; }
.page-thumb.sortable-ghost { opacity: 0.3; }
.page-thumb__canvas-wrap {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--grey-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.page-thumb__canvas-wrap canvas,
.page-thumb__canvas-wrap img { max-width: 100%; max-height: 100%; transition: transform 0.15s ease; }
.page-thumb__num {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 8px;
}
.page-thumb__check {
  position: absolute;
  top: 16px; left: 16px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--white);
  background: rgba(255,255,255,0.85);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  z-index: 2;
}
.page-thumb__check svg { width: 13px; height: 13px; opacity: 0; }
.page-thumb__toolbar {
  position: absolute;
  bottom: 16px; right: 16px;
  display: flex;
  gap: 4px;
  z-index: 2;
}
.page-thumb__mini-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--ink);
}
.page-thumb__mini-btn:hover { background: var(--ink); color: #fff; }
.page-thumb__mini-btn svg { width: 13px; height: 13px; }
.page-thumb__drag {
  position: absolute; top: 16px; right: 16px;
  color: var(--grey-border); cursor: grab; z-index: 2;
}
.page-thumb__drag svg { width: 16px; height: 16px; }

.page-thumb__order {
  position: absolute;
  top: 16px; left: 16px;
  min-width: 22px; height: 22px;
  border-radius: 11px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  z-index: 3;
}

.page-range-field {
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.page-range-field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.page-range-field__row { display: flex; gap: 8px; }
.page-range-field__row input {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid var(--grey-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
}
.page-range-field__row input:focus { outline: none; border-color: var(--red); }
.field-hint--error { color: var(--red); margin-top: 8px; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.toolbar__spacer { flex: 1; }
.toolbar__count { font-size: 13px; color: var(--ink-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--red);
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--red-dark); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--secondary {
  background: var(--white);
  color: var(--ink);
  border: 1.5px solid var(--grey-border);
}
.btn--secondary:hover { background: var(--grey-bg); border-color: var(--ink); }
.btn--ghost {
  background: none;
  color: var(--ink-soft);
  border: 1px solid transparent;
}
.btn--ghost:hover { background: var(--grey-bg); color: var(--ink); }
.btn--sm { padding: 7px 14px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--lg { padding: 14px 28px; font-size: 15px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* ---------- Form controls ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--grey-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: var(--white);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--red); }
.field-hint { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-opt {
  display: flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--grey-border);
  padding: 10px 16px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink-soft);
}
.radio-opt input { accent-color: var(--red); }
.radio-opt.active { border-color: var(--red); color: var(--ink); background: #fff6f5; }

/* ---------- Card / panel container ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-lg);
  padding: 28px;
}
.card + .card { margin-top: 20px; }

/* ---------- Signature tool ---------- */
.sign-layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .sign-layout { grid-template-columns: 1fr; } }
.sign-doc-stage {
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  overflow: auto;
  max-height: 78vh;
}
.sign-page-wrap { position: relative; margin: 0 auto 20px; width: fit-content; }
.sign-page-wrap canvas { display: block; border: 1px solid var(--grey-border-soft); border-radius: 4px; }
.sign-stamp {
  position: absolute;
  cursor: move;
  border: 1.5px dashed var(--red);
  touch-action: none;
}
.sign-stamp img, .sign-stamp canvas { width: 100%; height: 100%; display: block; }
.sign-stamp__resize {
  position: absolute; width: 14px; height: 14px; right: -7px; bottom: -7px;
  background: var(--red); border-radius: 50%; cursor: nwse-resize; border: 2px solid #fff;
}
.sign-stamp__del {
  position: absolute; top: -12px; right: -12px; width: 22px; height: 22px;
  background: var(--ink); border-radius: 50%; color: #fff; border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.sign-stamp__del svg { width: 11px; height: 11px; }

.sig-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.sig-tab {
  flex: 1; text-align: center; padding: 9px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--grey-border); font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink-soft);
}
.sig-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.sig-pane { display: none; }
.sig-pane.active { display: block; }
#signCanvas { width: 100%; touch-action: none; background: var(--grey-bg); border-radius: var(--radius-sm); border: 1.5px solid var(--grey-border); }
.font-choice { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.font-choice__opt {
  border: 1.5px solid var(--grey-border); border-radius: var(--radius-sm);
  padding: 12px; cursor: pointer; text-align: center; font-size: 22px; color: var(--ink);
}
.font-choice__opt.active { border-color: var(--red); background: #fff6f5; }
.sig-text-input {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--grey-border); border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 10px;
}
.color-row { display: flex; gap: 8px; margin-bottom: 12px; }
.color-dot {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent;
}
.color-dot.active { border-color: var(--ink); }

/* ---------- Progress / status ---------- */
.status-line {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--ink-soft); margin-top: 14px;
}
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--grey-border); border-top-color: var(--red);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Result panel ---------- */
.result-box {
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
}
.result-box__icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--green-bg); color: #14713d;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
}
.result-box__icon svg { width: 30px; height: 30px; }
.result-box h3 { margin: 0 0 6px; color: var(--ink); }
.result-files { display: flex; flex-direction: column; gap: 8px; max-width: 420px; margin: 20px auto 0; text-align: left; }

.footer-note {
  text-align: center;
  font-size: 12px;
  color: #9999a2;
  margin-top: 60px;
  line-height: 1.7;
}
.footer-note a { color: var(--ink-soft); }
