/* ── Reset & Base ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface-hover: #1a1a24;
  --border: #2a2a3a;
  --border-hover: #3a3a50;
  --text: #e8e8f0;
  --text-muted: #8888a0;
  --text-dim: #555570;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --success: #00cec9;
  --success-glow: rgba(0, 206, 201, 0.3);
  --danger: #ff6b6b;
  --danger-hover: #ee5a5a;
  --warning: #feca57;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* ── Animated Background ── */
.bg-blobs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  animation: float 20s ease-in-out infinite;
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: var(--accent);
  top: -150px;
  right: -100px;
  animation-delay: 0s;
}

.blob-2 {
  width: 400px;
  height: 400px;
  background: #e84393;
  bottom: -100px;
  left: -100px;
  animation-delay: -7s;
}

.blob-3 {
  width: 350px;
  height: 350px;
  background: var(--success);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -40px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(40px, 30px) scale(1.02); }
}

/* ── Header ── */
header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 3rem 1.5rem 1.5rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo svg {
  color: var(--accent-light);
}

.tagline {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ── Main ── */
main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 680px;
  padding: 0 1.5rem 3rem;
}

/* ── Drop Zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 3.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface);
  backdrop-filter: blur(12px);
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(108, 92, 231, 0.05);
  box-shadow: 0 0 40px var(--accent-glow);
  transform: translateY(-2px);
}

.drop-zone.drag-over {
  border-style: solid;
  transform: scale(1.02);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.drop-icon {
  color: var(--accent-light);
  margin-bottom: 0.5rem;
  transition: transform var(--transition);
}

.drop-zone:hover .drop-icon {
  transform: translateY(-4px);
}

.drop-zone h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.drop-zone p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.drop-hint {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.35rem 0.9rem;
  border-radius: 100px;
  background: rgba(108, 92, 231, 0.12);
  color: var(--accent-light);
  font-size: 0.78rem;
  font-weight: 500;
}

/* ── File List Section ── */
.file-list-section {
  margin-top: 1.5rem;
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.section-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.section-header h3 svg {
  color: var(--accent-light);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 100px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

.section-actions {
  display: flex;
  gap: 0.5rem;
}

.reorder-hint {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}

/* ── File List ── */
.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  cursor: grab;
  user-select: none;
}

.file-item:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.file-item.dragging {
  opacity: 0.5;
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.file-item.drag-target {
  border-color: var(--accent-light);
  background: rgba(108, 92, 231, 0.08);
}

.file-item:active {
  cursor: grabbing;
}

.drag-handle {
  color: var(--text-dim);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.file-order {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.file-pages {
  font-size: 0.72rem;
  color: var(--accent-light);
  background: rgba(108, 92, 231, 0.12);
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
  margin-left: 0.4rem;
}

.file-remove {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.file-remove:hover {
  background: rgba(255, 107, 107, 0.12);
  color: var(--danger);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 0.85rem 1.8rem;
  font-size: 1rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  background: #7c6ef0;
  box-shadow: 0 6px 24px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--danger);
  background: rgba(255, 107, 107, 0.08);
}

/* ── Merge Bar ── */
.merge-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.merge-status {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.merge-status .warn {
  color: var(--warning);
}

/* ── Progress ── */
.progress-section {
  margin-top: 2rem;
  text-align: center;
  animation: slideUp 0.4s ease;
}

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--surface);
  border-radius: 100px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 100px;
  transition: width 0.3s ease;
}

.progress-text {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ── Success ── */
.success-section {
  margin-top: 2rem;
  text-align: center;
  animation: slideUp 0.4s ease;
}

.success-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(0, 206, 201, 0.1);
  color: var(--success);
  margin-bottom: 1rem;
  animation: popIn 0.5s ease;
}

@keyframes popIn {
  0% { transform: scale(0); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.success-section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.success-section p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.success-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Footer ── */
footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1.5rem;
  margin-top: auto;
}

footer p {
  color: var(--text-dim);
  font-size: 0.78rem;
}

/* ── Utilities ── */
.hidden {
  display: none !important;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 1000;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  header {
    padding: 2rem 1rem 1rem;
  }

  .logo {
    font-size: 1.4rem;
  }

  .tagline {
    font-size: 0.85rem;
  }

  main {
    padding: 0 1rem 2rem;
  }

  .drop-zone {
    padding: 2.5rem 1.5rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .merge-bar {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }

  .success-actions {
    flex-direction: column;
  }

  .success-actions .btn {
    width: 100%;
  }
}
