/* ==========================================================
   PDF Toolkit — brandable, premium stylesheet
   Change the CSS variables below to match your site's colors.
   ========================================================== */
:root {
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-dark: #4338ca;
  --brand-light: #eef0ff;
  --accent: #f5b942;
  --ink: #14161f;
  --ink-soft: #5b6072;
  --ink-faint: #9096a8;
  --border: #e6e8f0;
  --border-soft: #eef0f6;
  --bg: #f6f7fb;
  --card: #ffffff;
  --success: #16a34a;
  --danger: #dc2626;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 22, 41, 0.06);
  --shadow: 0 4px 16px rgba(20, 22, 41, 0.07), 0 1px 3px rgba(20, 22, 41, 0.06);
  --shadow-lg: 0 20px 45px -12px rgba(79, 70, 229, 0.28), 0 6px 16px -6px rgba(20, 22, 41, 0.1);
  --font-body: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Noto Nastaliq Urdu";
  --font-display: "Lexend", "Inter", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

a { color: inherit; text-decoration: none; }

::selection { background: var(--brand); color: #fff; }

/* Soft ambient gradient glow behind everything */
.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(680px circle at 12% -10%, rgba(79, 70, 229, 0.16), transparent 60%),
    radial-gradient(600px circle at 100% 0%, rgba(124, 58, 237, 0.12), transparent 55%),
    var(--bg);
}

/* ---------- Header ---------- */
.topbar {
  position: relative;
  background:
    radial-gradient(900px 420px at 15% -20%, rgba(255, 255, 255, 0.14), transparent 60%),
    linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  padding: 46px 20px 34px;
  overflow: hidden;
}
.topbar::after {
  content: "";
  position: absolute;
  right: -120px;
  top: -120px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.16), transparent 70%);
  pointer-events: none;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-mark {
  background: #fff;
  color: var(--brand-dark);
  padding: 5px 12px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}
.tagline {
  margin: 12px 0 0;
  opacity: 0.92;
  font-size: 15px;
  max-width: 560px;
  line-height: 1.5;
}
.trust-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.trust-badges .badge {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(6px);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.1px;
}

/* ---------- Tabs (segmented control) ---------- */
.tabs {
  max-width: 1100px;
  margin: -22px auto 0;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  position: relative;
  z-index: 2;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  width: fit-content;
  max-width: calc(100% - 40px);
}
.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 11px 16px;
  border-radius: 11px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: all 0.18s ease;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--brand-dark); background: var(--brand-light); }
.tab-btn.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 6px 16px -4px rgba(79, 70, 229, 0.45);
}

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: 34px auto 70px;
  padding: 0 20px;
}
.panel { display: none; animation: panelIn 0.28s ease; }
.panel.active { display: block; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.panel h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.hint { color: var(--ink-soft); font-size: 14.5px; margin: 0 0 22px; line-height: 1.55; }
.hint-inline { color: var(--ink-soft); font-size: 13px; margin-left: 8px; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 42px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: var(--shadow-sm);
}
.dropzone:hover {
  border-color: var(--brand);
  background: var(--brand-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.dropzone.dragover {
  border-color: var(--brand);
  background: var(--brand-light);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12), var(--shadow);
}
.dz-icon {
  font-size: 38px;
  margin-bottom: 8px;
  filter: drop-shadow(0 6px 10px rgba(79, 70, 229, 0.18));
}
.dropzone-inner p { margin: 0; font-size: 15px; color: var(--ink); }
.dz-sub { display: block; margin-top: 5px; font-size: 12.5px; color: var(--ink-faint); }

/* ---------- File list (merge) ---------- */
.file-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.file-list li:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.file-list li.dragging { opacity: 0.4; }
.file-list .drag-handle { color: var(--ink-faint); font-size: 15px; }
.file-list .file-name { flex: 1; font-size: 14px; font-weight: 500; word-break: break-all; }
.file-list .file-size { font-size: 12px; color: var(--ink-faint); }
.file-list .remove-btn {
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 15px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  transition: background 0.15s ease;
}
.file-list .remove-btn:hover { background: #fee2e2; }

/* ---------- Buttons ---------- */
.actions { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  padding: 11px 20px;
  border-radius: 11px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--brand); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.55);
}
.btn-primary:hover { box-shadow: 0 10px 26px -6px rgba(79, 70, 229, 0.6); filter: brightness(1.04); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:hover { box-shadow: none; background: var(--brand-light); }
.btn-sm { padding: 8px 13px; font-size: 13px; border-radius: 9px; }

/* ---------- Status / toast ---------- */
.status { margin-top: 16px; font-size: 14px; min-height: 20px; font-weight: 500; }
.status.ok { color: var(--success); }
.status.err { color: var(--danger); }
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 50;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Split thumbnails ---------- */
.split-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 10px;
  margin: 18px 0;
}
.split-toolbar .divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.thumb-card {
  background: var(--card);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.thumb-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.thumb-card.selected { border-color: var(--brand); background: var(--brand-light); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }
.thumb-card canvas { width: 100%; height: auto; border-radius: 7px; box-shadow: var(--shadow-sm); transition: transform 0.15s ease; }
.thumb-card .thumb-label { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }

/* ---------- Editor canvas ---------- */
.editor-shell { margin-top: 18px; }
.edit-toolbar, .form-fields-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 12px;
  margin-bottom: 14px;
}
.tool-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tool-btn {
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.tool-btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.tool-btn.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px -3px rgba(79, 70, 229, 0.5);
}
.tiny-label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; display: flex; align-items: center; gap: 5px; }
.page-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); min-width: 90px; text-align: center; }

.canvas-wrap {
  position: relative;
  display: inline-block;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow);
  max-width: 100%;
  overflow: auto;
}
.canvas-wrap canvas { display: block; max-width: 100%; height: auto; }
.overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}
.overlay-item {
  position: absolute;
  cursor: move;
  border: 1px dashed transparent;
  border-radius: 2px;
}
.overlay-item.selected { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.18); }
.overlay-item .resize-handle {
  position: absolute;
  width: 13px; height: 13px;
  right: -6px; bottom: -6px;
  background: var(--brand);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: nwse-resize;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.overlay-text {
  min-width: 20px;
  min-height: 20px;
  outline: none;
  white-space: pre;
  font-family: Helvetica, Arial, sans-serif;
}

/* ---------- Forms (watermark / compress) ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-top: 18px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
}
.form-grid input[type="text"],
.form-grid select {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-grid input[type="text"]:focus,
.form-grid select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}
.form-grid input[type="range"] { accent-color: var(--brand); }
input[type="range"] { accent-color: var(--brand); }
input[type="color"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 40px;
  height: 32px;
  padding: 2px;
  cursor: pointer;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.radio-row { flex-direction: row !important; align-items: center; gap: 9px !important; font-weight: 500 !important; }
.radio-row input[type="radio"] { accent-color: var(--brand); width: 16px; height: 16px; }
.wm-preview {
  margin-top: 18px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow);
  display: inline-block;
  max-width: 100%;
  overflow: auto;
}
.wm-preview canvas { display: block; max-width: 100%; height: auto; }

/* ---------- Sign & forms ---------- */
.form-fields-box { margin-top: 18px; background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; }
.form-fields-box h3, .sign-shell h3 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.form-fields-list { flex-direction: column; align-items: stretch; }
.field-row { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.field-row label { font-weight: 600; color: var(--ink-soft); }
.field-row input[type="text"], .field-row textarea, .field-row select {
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; font-size: 14px; font-family: var(--font-body);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field-row input[type="text"]:focus, .field-row select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14); }
.field-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); }

.sign-shell { margin-top: 18px; }
.sign-pad-canvas {
  width: 100%;
  max-width: 480px;
  height: 180px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: repeating-linear-gradient(135deg, #fbfbfe, #fbfbfe 10px, #f6f7fb 10px, #f6f7fb 20px);
  touch-action: none;
  box-shadow: var(--shadow-sm);
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 30px 20px 46px;
  color: var(--ink-faint);
  font-size: 12.5px;
}

/* ---------- Scrollbar polish (webkit) ---------- */
.canvas-wrap::-webkit-scrollbar { height: 10px; width: 10px; }
.canvas-wrap::-webkit-scrollbar-track { background: var(--border-soft); border-radius: 10px; }
.canvas-wrap::-webkit-scrollbar-thumb { background: var(--brand); border-radius: 10px; opacity: 0.6; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .topbar { padding: 34px 16px 26px; }
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
    max-width: calc(100% - 32px);
    -webkit-overflow-scrolling: touch;
  }
  .tab-btn { flex: 0 0 auto; }
  .panel h2 { font-size: 21px; }
}
