/**
 * merge.css — Premium Client-Side iLovePDF Merge Tool Styling
 * Builds on the UI/UX Pro Max design system in style.css
 */

/* Main Container Layout */
.merge-main-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 80px;
  min-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
}

/* Header & Intro */
.merge-hero-header {
  text-align: center;
  margin-bottom: 24px;
}

.merge-hero-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.merge-hero-header h1 span {
  background: linear-gradient(135deg, #ef4444 0%, #f43f5e 50%, #4f46e5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.merge-hero-header p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 600px;
  margin: 0 auto;
}

/* Initial Upload Dropzone */
.merge-dropzone-section {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 20px;
}

.merge-dropzone {
  width: 100%;
  max-width: 680px;
  border: 2px dashed rgba(239, 68, 68, 0.4);
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  padding: 60px 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.merge-dropzone:hover,
.merge-dropzone.drag-over {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.04);
  transform: translateY(-2px);
  box-shadow: 0 12px 36px -6px rgba(239, 68, 68, 0.15);
}

.merge-drop-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(79, 70, 229, 0.12));
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ef4444;
  transition: transform 0.25s ease;
}

.merge-dropzone:hover .merge-drop-icon {
  transform: scale(1.08) rotate(-4deg);
}

.btn-select-pdf {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #ef4444 0%, #e11d48 100%);
  color: #ffffff;
  font-family: var(--font-main);
  font-size: 1.15rem;
  font-weight: 700;
  padding: 16px 36px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px -4px rgba(239, 68, 68, 0.45);
  transition: all 0.2s ease;
  margin-bottom: 14px;
}

.btn-select-pdf:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -4px rgba(239, 68, 68, 0.55);
}

.merge-drop-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Secondary Top Toolbar when files are loaded */
.merge-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.merge-toolbar-left,
.merge-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-toolbar:hover {
  color: var(--text-primary);
  background: var(--bg-card-subtle);
  border-color: var(--border-focus);
}

.btn-toolbar-danger:hover {
  color: var(--color-danger);
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
}

.btn-toolbar-primary {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

.btn-toolbar-primary:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

/* View Mode Segmented Control (Files vs Pages) */
.view-mode-toggle {
  display: inline-flex;
  background: var(--bg-card-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.view-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-mode-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Workspace Split Layout (Grid + Sidebar) */
.merge-workspace {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 960px) {
  .merge-workspace {
    grid-template-columns: 1fr;
  }
}

/* Card Grid */
.merge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
  min-height: 250px;
}

/* Card Item */
.merge-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  user-select: none;
}

.merge-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(239, 68, 68, 0.4);
}

.merge-card.is-dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.merge-card.drag-target-left {
  border-left: 3px solid #ef4444;
}

.merge-card.drag-target-right {
  border-right: 3px solid #ef4444;
}

/* Card Header with Sequence Badge */
.merge-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-seq-badge {
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* Card Actions Hover Dock */
.card-actions-dock {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-card-action {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-card-action:hover {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-card-delete:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Card Thumbnail Preview */
.merge-card-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.35;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  margin-bottom: 10px;
}

.merge-card-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s ease;
}

/* Card Footer / Metadata */
.merge-card-footer {
  margin-top: auto;
}

.card-filename {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.card-meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.card-page-count {
  font-weight: 600;
  color: var(--color-primary);
}

/* Sidebar Action Panel */
.merge-sidebar-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 90px;
}

.sidebar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border-subtle);
  font-size: 0.9rem;
}

.summary-metric-label {
  color: var(--text-secondary);
}

.summary-metric-val {
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.summary-filename-group {
  margin: 18px 0;
}

.summary-filename-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.summary-filename-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 10px;
}

.summary-filename-input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-family: var(--font-main);
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
}

.summary-filename-ext {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Big Glow Merge Button */
.btn-merge-action {
  width: 100%;
  background: linear-gradient(135deg, #ef4444 0%, #e11d48 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 15px;
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 8px 24px -4px rgba(239, 68, 68, 0.45);
  transition: all 0.2s ease;
  margin-top: 10px;
}

.btn-merge-action:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -4px rgba(239, 68, 68, 0.55);
}

.btn-merge-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* Completed Success View */
.merge-success-view {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 48px 32px;
  text-align: center;
  max-width: 650px;
  margin: 30px auto;
  box-shadow: var(--shadow-md);
  animation: fadeIn 0.3s ease;
}

.success-badge-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--color-success-bg);
  color: var(--color-success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.25);
}

.merge-success-view h2 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.merge-success-view p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.success-action-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  margin: 0 auto;
}

.btn-download-merged {
  background: linear-gradient(135deg, #ef4444 0%, #e11d48 100%);
  color: #ffffff;
  padding: 15px 24px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  box-shadow: 0 8px 24px -4px rgba(239, 68, 68, 0.45);
  transition: all 0.2s ease;
}

.btn-download-merged:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -4px rgba(239, 68, 68, 0.55);
}

.btn-crossover {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-crossover:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: var(--border-focus);
}

.btn-merge-reset {
  margin-top: 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.btn-merge-reset:hover {
  color: var(--text-primary);
}

/* Subtle Loading Overlay */
.merge-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ef4444;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

.loading-text {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 600;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

/* Add More Files Card in Grid */
.merge-card-add {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-subtle);
  background: var(--bg-card-subtle);
  min-height: 220px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.merge-card-add:hover {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
  transform: translateY(-3px);
}

.card-add-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.merge-card-add:hover .card-add-inner {
  color: #ef4444;
}

/* Drag over active workspace indicator */
.workspace-drag-over {
  outline: 3px dashed #ef4444;
  outline-offset: -6px;
  background: rgba(239, 68, 68, 0.03);
  border-radius: var(--radius-md);
}

.hide {
  display: none !important;
}
