/* ============================================================
   PDF Merger — Stylesheet
   Design tokens, base reset, layout, components.
   ============================================================ */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;

  --accent: #ec4899;
  --success: #10b981;
  --success-50: #ecfdf5;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-50: #fef2f2;

  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --border: #e5e7eb;
  --border-strong: #cbd5e1;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, .06), 0 10px 25px -5px rgba(15, 23, 42, .08);
  --shadow-lg: 0 25px 50px -12px rgba(79, 70, 229, .18);

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; }
input { font: inherit; color: inherit; }
a { color: var(--primary-dark); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary); }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
  padding: .1em .4em;
  background: var(--primary-50);
  color: var(--primary-dark);
  border-radius: 4px;
}

/* ---------- Decorative background ---------- */
.background-decoration {
  position: fixed; inset: 0; z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .45;
  animation: float 14s ease-in-out infinite;
}
.blob-1 { width: 500px; height: 500px; top: -150px; left: -120px;
  background: radial-gradient(circle, #818cf8, transparent 70%); }
.blob-2 { width: 460px; height: 460px; top: 30%; right: -120px;
  background: radial-gradient(circle, #f0abfc, transparent 70%);
  animation-delay: -4s; }
.blob-3 { width: 380px; height: 380px; bottom: -120px; left: 30%;
  background: radial-gradient(circle, #5eead4, transparent 70%);
  animation-delay: -8s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.05); }
  66% { transform: translate(-30px, 20px) scale(.95); }
}

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.main-content { padding: 32px 24px 64px; flex: 1; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .72);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid rgba(229, 231, 235, .6);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px; padding-bottom: 14px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 18px;
  color: var(--text);
}
.brand:hover { color: var(--primary-dark); }
.brand-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, .35);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name { letter-spacing: -.02em; }
.brand-accent { color: var(--primary); }
.header-nav { display: flex; gap: 24px; }
.header-nav a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  transition: color var(--transition);
}
.header-nav a:hover { color: var(--text); }

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 48px 0 32px;
  max-width: 760px;
  margin: 0 auto;
}
.hero h1 {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  letter-spacing: -.03em;
  margin-bottom: 16px;
}
.gradient-text {
  background: linear-gradient(120deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.hero-sub {
  font-size: 17px;
  color: var(--text-muted);
  margin: 0 auto;
  max-width: 600px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  margin-bottom: 28px;
  overflow: hidden;
}

/* ---------- Dropzone ---------- */
.dropzone-card { padding: 16px; }
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.dropzone:hover, .dropzone:focus-visible {
  outline: none;
  border-color: var(--primary);
  background: var(--primary-50);
  transform: translateY(-1px);
}
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-50);
  transform: scale(1.01);
  box-shadow: 0 0 0 6px rgba(99, 102, 241, .12);
}
.dropzone-illustration {
  width: 84px; height: 84px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary-100), white);
  border-radius: 24px;
  color: var(--primary-dark);
  box-shadow: 0 10px 24px rgba(99, 102, 241, .18);
}
.dropzone-illustration svg { width: 44px; height: 44px; }
.dropzone-text {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 15px; color: var(--text-muted);
}
.dropzone-text strong {
  display: block;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}
.link-button {
  color: var(--primary-dark);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-button:hover { color: var(--primary); }
.dropzone-hint {
  font-size: 13px;
  color: var(--text-soft);
}
.dropzone-hint strong { color: var(--text-muted); font-weight: 600; }

/* ---------- Files section ---------- */
.files-card { padding: 24px 24px 20px; }
.files-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.files-header h2 {
  font-size: 20px; font-weight: 700;
  margin-bottom: 4px;
}
.files-meta {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}
.files-meta span { font-weight: 600; color: var(--text); }
.files-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.files-tip {
  display: flex; align-items: center; gap: 10px;
  background: var(--primary-50);
  color: var(--primary-dark);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 4px 0 16px;
  font-size: 13.5px;
}
.files-tip svg { width: 18px; height: 18px; flex-shrink: 0; }

/* File items */
.files-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex; flex-direction: column;
  gap: 10px;
}
.file-item {
  display: grid;
  grid-template-columns: auto auto auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  position: relative;
}
.file-item:hover {
  border-color: var(--primary-light);
  box-shadow: 0 4px 12px rgba(99, 102, 241, .08);
}
.file-item.is-uploading {
  border-style: dashed;
  background: var(--surface-2);
}
.file-item.is-uploading .file-actions { opacity: .35; pointer-events: none; }
.file-item.sortable-ghost {
  opacity: .35;
  background: var(--primary-50);
  border-color: var(--primary);
  border-style: dashed;
}
.file-item.sortable-chosen { cursor: grabbing; }
.file-item.sortable-drag {
  box-shadow: 0 20px 40px rgba(99, 102, 241, .25);
  border-color: var(--primary);
}

.drag-handle {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  color: var(--text-soft);
  cursor: grab;
  border-radius: 6px;
  transition: all var(--transition);
}
.drag-handle:hover { background: var(--primary-50); color: var(--primary-dark); }
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { width: 18px; height: 18px; }

.file-index {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: var(--primary-50);
  color: var(--primary-dark);
  border-radius: 50%;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

.file-icon {
  position: relative;
  width: 44px; height: 52px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #fee2e2, #fef2f2);
  border-radius: 8px;
  color: #dc2626;
  flex-shrink: 0;
}
.file-icon svg { width: 26px; height: 26px; }
.file-icon-label {
  position: absolute;
  bottom: 4px; left: 50%;
  transform: translateX(-50%);
  font-size: 8px; font-weight: 800;
  letter-spacing: .05em;
  color: white;
  background: #dc2626;
  padding: 1px 5px;
  border-radius: 3px;
}

.file-info {
  min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.file-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.file-meta .dot { color: var(--text-soft); }
.file-rotation-text {
  color: var(--primary-dark);
  font-weight: 600;
}

.file-progress { margin-top: 6px; }
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 999px;
  transition: width 200ms ease;
}
.progress-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

.file-actions {
  display: flex; gap: 4px;
  flex-shrink: 0;
}
.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--text-muted);
  transition: all var(--transition);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--primary-50); color: var(--primary-dark); }
.rotate-btn.is-active {
  background: var(--primary-50);
  color: var(--primary-dark);
}
.delete-btn:hover { background: var(--danger-50); color: var(--danger); }

/* ---------- Merge panel ---------- */
.merge-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.field-input {
  position: relative;
  display: flex; align-items: center;
}
.field-input input {
  width: 100%;
  padding: 12px 48px 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 15px;
  transition: all var(--transition);
}
.field-input input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}
.field-suffix {
  position: absolute;
  right: 14px;
  color: var(--text-soft);
  font-size: 14px;
  pointer-events: none;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  transition: all var(--transition);
  user-select: none;
}
.btn svg { width: 17px; height: 17px; }
.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
}
.btn-primary:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(99, 102, 241, .45);
}
.btn-primary:not(:disabled):active { transform: translateY(0); }
.btn-merge { padding: 13px 24px; font-size: 15px; }
.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-loading .btn-label { opacity: .65; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-ghost.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-50); }

/* ---------- Features ---------- */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 48px 0 32px;
}
.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: all var(--transition);
}
.feature:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary-light);
}
.feature h3 { font-size: 16px; margin-bottom: 4px; }
.feature p { font-size: 14px; color: var(--text-muted); margin: 0; }
.feature-icon {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  margin-bottom: 14px;
  color: white;
}
.feature-icon svg { width: 20px; height: 20px; }
.feature-icon.teal { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.feature-icon.violet { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.feature-icon.amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
.feature-icon.rose { background: linear-gradient(135deg, #f43f5e, #be123c); }

/* ---------- How it works ---------- */
.how-it-works {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  margin-bottom: 32px;
}
.how-it-works h2 {
  font-size: 22px;
  margin-bottom: 24px;
  text-align: center;
}
.steps {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 24px;
}
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.step-num {
  width: 32px; height: 32px;
  flex-shrink: 0;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
}
.steps h4 { font-size: 15px; margin-bottom: 4px; }
.steps p { font-size: 14px; color: var(--text-muted); margin: 0; }

/* ---------- Footer ---------- */
.site-footer {
  padding: 20px 0 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
}
.site-footer p { margin: 0; }

/* ---------- Toast notifications ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex; flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 14px 12px 12px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, .15);
  min-width: 260px; max-width: 380px;
  border-left: 4px solid var(--primary);
  pointer-events: auto;
  animation: toastIn 250ms cubic-bezier(.4, 0, .2, 1);
}
.toast.is-removing { animation: toastOut 200ms ease forwards; }
.toast-icon {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--primary);
}
.toast-icon svg { width: 20px; height: 20px; }
.toast-body { font-size: 14px; flex: 1; min-width: 0; }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-message { color: var(--text-muted); font-size: 13px; line-height: 1.45; word-break: break-word; }
.toast.success { border-left-color: var(--success); }
.toast.success .toast-icon { color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.warning .toast-icon { color: var(--warning); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .header-nav { display: none; }
  .main-content { padding: 24px 16px 48px; }
  .container { padding: 0 16px; }
  .hero { padding: 32px 0 24px; }
  .hero-sub { font-size: 15px; }
  .dropzone { padding: 40px 16px; }
  .dropzone-illustration { width: 68px; height: 68px; }
  .dropzone-illustration svg { width: 36px; height: 36px; }
  .dropzone-text strong { font-size: 17px; }
  .files-card { padding: 18px 16px; }
  .file-item {
    grid-template-columns: auto auto 1fr auto;
    padding: 10px 12px;
  }
  .file-index { display: none; }
  .merge-panel { grid-template-columns: 1fr; }
  .btn-merge { width: 100%; }
  .how-it-works { padding: 24px 18px; }
  .toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { min-width: 0; max-width: none; }
  .files-header { flex-direction: column; align-items: stretch; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .blob { animation: none; }
}
