* {
  box-sizing: border-box;
}
body {
  background: #0a0f0e;
  font-family: "DM Sans", sans-serif;
}

/* ─── Core animation keyframes & utility classes ─────
   NOTE: these back the animate-fade-in / animate-slide-up / animate-pulse-soft
   classes used throughout the markup (originally only declared in the Tailwind
   theme config, which needs a build step to become real CSS). Defining them
   here guarantees they always work, independent of the Tailwind build. */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes pulseSoft {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}
.animate-fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}
.animate-slide-up {
  animation: slideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.animate-pulse-soft {
  animation: pulseSoft 2s ease-in-out infinite;
}

/* Staggered pop-in for grid thumbnails / list rows as they render */
@keyframes thumbPopIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.thumb-pop-in {
  animation: thumbPopIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.glass {
  background: rgba(22, 33, 32, 0.7);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(45, 212, 191, 0.12);
}

.glow-border {
  border: 1px solid rgba(45, 212, 191, 0.25);
  box-shadow:
    0 0 24px rgba(20, 184, 166, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.tab-active {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  color: #fff;
  box-shadow: 0 4px 20px rgba(20, 184, 166, 0.35);
}

.drop-zone {
  border: 2px dashed rgba(45, 212, 191, 0.25);
  transition: all 0.3s ease;
  background: rgba(20, 184, 166, 0.03);
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: rgba(45, 212, 191, 0.7);
  background: rgba(20, 184, 166, 0.08);
  transform: scale(1.005);
}

.file-card {
  background: rgba(22, 33, 32, 0.9);
  border: 1px solid rgba(45, 212, 191, 0.12);
  transition: all 0.25s ease;
  cursor: grab;
}
.file-card:hover {
  border-color: rgba(45, 212, 191, 0.35);
  transform: translateY(-1px);
}
.file-card.sortable-ghost {
  opacity: 0.4;
}
.file-card.sortable-chosen {
  cursor: grabbing;
}

.btn-primary {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  color: white;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(20, 184, 166, 0.3);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(20, 184, 166, 0.45);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-ghost {
  background: rgba(45, 212, 191, 0.08);
  border: 1px solid rgba(45, 212, 191, 0.2);
  color: #5eead4;
  transition: all 0.2s ease;
}
.btn-ghost:hover {
  background: rgba(45, 212, 191, 0.15);
  transform: translateY(-1px);
}
.btn-ghost:active {
  transform: translateY(0) scale(0.97);
}

.tab-active {
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  color: #fff;
  box-shadow: 0 4px 20px rgba(20, 184, 166, 0.35);
  transform: scale(1.015);
}

.progress-bar {
  background: linear-gradient(90deg, #14b8a6, #2dd4bf);
  transition: width 0.4s ease;
  box-shadow: 0 0 10px rgba(20, 184, 166, 0.6);
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
}

/* Static (non-animated) ambience — kept subtle and cheap so it doesn't
   weigh down lower-end phones. */
.bg-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(
      circle at 20% 20%,
      rgba(20, 184, 166, 0.14),
      transparent 48%
    ),
    radial-gradient(
      circle at 82% 28%,
      rgba(45, 212, 191, 0.11),
      transparent 52%
    ),
    radial-gradient(circle at 50% 85%, rgba(6, 182, 212, 0.1), transparent 48%);
}

/* Static gradient orbs for a bit of visual depth — no animation, so there's
   no ongoing repaint cost on mobile GPUs. */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}
.orb-teal {
  width: 400px;
  height: 400px;
  top: -10%;
  left: -5%;
  background: #14b8a6;
  opacity: 0.14;
}
.orb-emerald {
  width: 340px;
  height: 340px;
  bottom: 10%;
  right: -5%;
  background: #059669;
  opacity: 0.12;
}
.orb-cyan {
  width: 270px;
  height: 270px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #22d3ee;
  opacity: 0.1;
}

.split-input {
  background: rgba(22, 33, 32, 0.9);
  border: 1px solid rgba(45, 212, 191, 0.2);
  color: #e2e8f0;
}
.split-input:focus {
  outline: none;
  border-color: rgba(45, 212, 191, 0.6);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.badge {
  background: rgba(20, 184, 166, 0.15);
  border: 1px solid rgba(45, 212, 191, 0.3);
  color: #2dd4bf;
}

.result-card {
  background: rgba(20, 184, 166, 0.06);
  border: 1px solid rgba(45, 212, 191, 0.2);
  animation: slideUp 0.4s ease-out;
}

/* Smaller/lighter orbs on small screens to keep things smooth */
@media (max-width: 640px) {
  .orb {
    filter: blur(50px);
  }
  .orb-teal {
    width: 220px;
    height: 220px;
  }
  .orb-emerald {
    width: 190px;
    height: 190px;
  }
  .orb-cyan {
    width: 160px;
    height: 160px;
  }
}

.drag-handle {
  cursor: grab;
}
.drag-handle:active {
  cursor: grabbing;
}

/* Page thumbnail grid */
.page-thumb {
  position: relative;
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid rgba(45, 212, 191, 0.12);
  background: rgba(22, 33, 32, 0.9);
  transition: all 0.2s ease;
  aspect-ratio: 3/4;
}
.page-thumb:hover {
  border-color: rgba(45, 212, 191, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.page-thumb.selected {
  border-color: #14b8a6;
  box-shadow:
    0 0 0 2px rgba(20, 184, 166, 0.3),
    0 8px 24px rgba(0, 0, 0, 0.4);
}
.page-thumb canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  display: block;
}
.page-thumb .page-num {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 6px 4px 4px;
  font-size: 10px;
  font-family: "DM Sans", sans-serif;
  color: #94a3b8;
  background: linear-gradient(transparent, rgba(10, 15, 14, 0.9));
}
.page-thumb.selected .page-num {
  color: #2dd4bf;
}
.page-thumb .check-icon {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #14b8a6;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.2s ease;
}
.page-thumb.selected .check-icon {
  opacity: 1;
  transform: scale(1);
}
.page-thumb .thumb-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(45, 212, 191, 0.4);
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
}
@media (min-width: 480px) {
  .thumb-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

.select-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Rotate tab: thumbnail canvas wrapper + centered rotate button */
.thumb-canvas-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.thumb-canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  display: block;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

/* Hover-revealed action toolbar centered on a page thumbnail
   (used by both the Rotate tab — rotate + zoom — and the Split tab — zoom only) */
.thumb-hover-actions {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.page-thumb:hover .thumb-hover-actions {
  opacity: 1;
}

.rotate-page-btn,
.zoom-page-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(10, 15, 14, 0.6);
  border: 1.5px solid rgba(45, 212, 191, 0.5);
  color: #5eead4;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  padding: 0;
}
.rotate-page-btn:hover,
.zoom-page-btn:hover {
  background: #14b8a6;
  border-color: #14b8a6;
  color: #fff;
  transform: scale(1.1);
}
.rotate-page-btn:active,
.zoom-page-btn:active {
  transform: scale(0.94);
}

/* Small always-visible affordance on touch devices where hover doesn't apply */
@media (hover: none) {
  .thumb-hover-actions {
    opacity: 0.9;
  }
}

/* Corner checkbox used on the Rotate tab (separate from the center rotate button) */
.page-select-box {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid rgba(148, 163, 184, 0.5);
  background: rgba(10, 15, 14, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
  transition: all 0.15s ease;
  padding: 0;
}
.page-select-box svg {
  opacity: 0;
  transition: opacity 0.15s ease;
}
.page-select-box:hover {
  border-color: rgba(45, 212, 191, 0.7);
}
.page-thumb.selected .page-select-box {
  background: #14b8a6;
  border-color: #14b8a6;
}
.page-thumb.selected .page-select-box svg {
  opacity: 1;
}

.page-thumb.rotated .page-num {
  color: #2dd4bf;
}
.page-thumb.rotated {
  border-color: rgba(45, 212, 191, 0.35);
}

/* Drag handle used to reorder pages on the Rotate tab */
.page-drag-handle {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid rgba(148, 163, 184, 0.5);
  background: rgba(10, 15, 14, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 3;
  transition: all 0.15s ease;
  color: #94a3b8;
  padding: 0;
}
.page-drag-handle:hover {
  border-color: rgba(45, 212, 191, 0.7);
  color: #5eead4;
}
.page-drag-handle:active {
  cursor: grabbing;
}

/* Small color strip identifying which uploaded file a page belongs to */
.page-file-strip {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 2;
  border-radius: 8px 8px 0 0;
}

.page-thumb.sortable-ghost {
  opacity: 0.35;
}
.page-thumb.sortable-chosen {
  cursor: grabbing;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.page-thumb.sortable-dragging {
  opacity: 0.4;
}
.sortable-fallback {
  opacity: 0.97 !important;
  transform: scale(1.06) rotate(2deg);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.55);
  border-color: #14b8a6 !important;
  cursor: grabbing;
}

/* Language switcher dropdown */
/* #lang-menu {
  animation: slideUp 0.18s ease-out;
}
.lang-option {
  color: #94a3b8;
}
.lang-option:hover {
  background: rgba(45, 212, 191, 0.1);
  color: #e2e8f0;
} */

#lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);

  width: 190px;

  padding: 8px;

  border-radius: 16px;

  background: rgba(18, 25, 24, 0.96);
  backdrop-filter: blur(20px);

  border: 1px solid rgba(45, 212, 191, 0.18);

  box-shadow:
    0 10px 35px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset;

  animation: dropdown 0.22s ease;
}
.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;

  width: 100%;

  padding: 12px 14px;

  border-radius: 12px;

  color: #cbd5e1;

  font-size: 14px;

  transition: 0.25s;
}
.lang-option:hover {
  background: rgba(20, 184, 166, 0.12);

  color: white;

  transform: translateX(3px);
}
.lang-option.active {
  background: linear-gradient(
    90deg,
    rgba(20, 184, 166, 0.2),
    rgba(20, 184, 166, 0.05)
  );

  color: #2dd4bf;

  font-weight: 600;
}
.lang-check {
  transition: 0.2s;
}

.lang-option.active .lang-check {
  display: block;
}
@keyframes dropdown {
  from {
    opacity: 0;

    transform: translateY(-8px) scale(0.96);
  }

  to {
    opacity: 1;

    transform: translateY(0) scale(1);
  }
}

/* ─── Merge file thumbnail preview + zoom trigger ────── */
.merge-thumb-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(20, 184, 166, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}
.merge-thumb-wrap canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  animation: fadeIn 0.3s ease-out;
}
.merge-thumb-zoom-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 14, 0.55);
  color: #fff;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s ease;
  padding: 0;
}
.merge-thumb-wrap:hover .merge-thumb-zoom-btn {
  opacity: 1;
}
@media (hover: none) {
  .merge-thumb-zoom-btn {
    opacity: 0.85;
  }
}

/* ─── Zoom / Page Preview Modal ───────────────────────
   Shared by the Merge, Split, and Rotate tabs so the user can inspect
   exactly which page/file they are looking at before committing. */
.zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 9, 8, 0.82);
  backdrop-filter: blur(10px);
  animation: overlayFadeIn 0.2s ease;
}
.zoom-overlay.hidden {
  display: none;
}
@keyframes overlayFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.zoom-box {
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: rgba(17, 25, 24, 0.97);
  border: 1px solid rgba(45, 212, 191, 0.18);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  animation: zoomBoxIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes zoomBoxIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.zoom-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(45, 212, 191, 0.1);
  flex-shrink: 0;
}
.zoom-title {
  color: #fff;
  font-family: "Syne", sans-serif;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.zoom-subtitle {
  color: #64748b;
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
  margin-top: 2px;
}
.zoom-close-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}
.zoom-close-btn:hover {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
  transform: rotate(90deg);
}

.zoom-box-body {
  position: relative;
  flex: 1;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
  background: radial-gradient(
    circle at 50% 0%,
    rgba(20, 184, 166, 0.06),
    transparent 60%
  );
}
.zoom-canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  width: 100%;
}
.zoom-canvas-wrap canvas {
  max-width: 100%;
  max-height: 68vh;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: zoomPageIn 0.22s ease;
}
@keyframes zoomPageIn {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.zoom-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.zoom-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(10, 15, 14, 0.7);
  border: 1.5px solid rgba(45, 212, 191, 0.3);
  color: #5eead4;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
  transition: all 0.18s ease;
  padding: 0;
}
.zoom-nav-btn:hover {
  background: #14b8a6;
  border-color: #14b8a6;
  color: #fff;
  transform: translateY(-50%) scale(1.08);
}
.zoom-nav-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  pointer-events: none;
}
.zoom-nav-prev {
  left: 12px;
}
.zoom-nav-next {
  right: 12px;
}

.zoom-box-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid rgba(45, 212, 191, 0.1);
  flex-shrink: 0;
}
.zoom-page-indicator {
  color: #64748b;
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
}
.zoom-rotate-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.zoom-rotate-controls button {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

@media (max-width: 640px) {
  .zoom-nav-btn {
    width: 32px;
    height: 32px;
  }
  .zoom-box-body {
    padding: 12px;
  }
  .zoom-box {
    border-radius: 18px;
  }
}
