/* merge-pdf.css */

/* ===== TOOL HEADER ===== */
.tool-header {
  text-align: center;
  padding: 56px 24px 32px;
  position: relative;
  z-index: 1;
}
.tool-header .badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(239,68,68,.13);
  border: 1px solid rgba(239,68,68,.25);
  color: #ef4444;
  font-size: .78rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 18px;
}
.tool-header h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 900;
  margin-bottom: 12px;
  line-height: 1.15;
}
.tool-header h1 .highlight {
  background: linear-gradient(135deg, #ef4444, #f87171);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tool-header p { color: var(--t2); font-size: 1.05rem; max-width: 520px; margin: 0 auto; }

.pdf-workspace {
  margin-top: 20px;
}

.drop-zone {
  border: 2px dashed rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.03);
  border-radius: 12px;
  padding: 60px 20px;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  margin-bottom: 20px;
}

.drop-zone:hover, .drop-zone.dragover {
  background: rgba(239, 68, 68, 0.08);
  border-color: #ef4444;
  transform: scale(1.01);
}

.drop-icon {
  font-size: 3rem;
  color: #ef4444;
  margin-bottom: 15px;
  opacity: 0.9;
}

.drop-zone h3 {
  font-size: 1.25rem;
  color: var(--t);
  margin-bottom: 8px;
}

.drop-zone p {
  color: var(--t2);
  margin-bottom: 20px;
}

.drop-note {
  font-size: 0.8rem !important;
  color: #10b981 !important;
  margin-top: 25px;
  margin-bottom: 0 !important;
}

.error-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid #ef4444;
  color: #f87171;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.error-box i {
  font-size: 1.1rem;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.list-info {
  font-weight: 600;
  color: var(--t);
}

.list-info span {
  color: #ef4444;
}

.sortable-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 25px;
}

.file-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: grab;
  transition: border-color 0.2s, background 0.2s;
}

.file-card:hover {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(255, 255, 255, 0.03);
}

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

.sortable-ghost {
  opacity: 0.4;
  background: rgba(239, 68, 68, 0.1);
  border: 1px dashed #ef4444;
}

.file-drag-handle {
  color: var(--t3);
  font-size: 1.2rem;
  padding: 0 5px;
}

.file-preview {
  width: 60px;
  height: 80px;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  position: relative;
}

.file-preview canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-preview-placeholder {
  color: #ef4444;
  font-size: 2rem;
}

.file-details {
  flex-grow: 1;
  overflow: hidden;
}

.file-name {
  font-weight: 600;
  color: var(--t);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

.file-meta {
  font-size: 0.8rem;
  color: var(--t2);
  display: flex;
  gap: 12px;
}

.file-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.file-remove {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.file-remove:hover {
  background: #ef4444;
  color: #fff;
}

.action-bar {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 10px;
}

.merge-btn {
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.merge-btn:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.progress-container {
  width: 100%;
}

.progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ef4444, #f87171);
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.85rem;
  color: var(--t2);
  text-align: right;
  font-weight: 600;
}

/* ==========================================
   PREVIEW & EDIT WORKSPACE
   ========================================== */
#previewWorkspace {
  background: var(--card);
  min-height: 500px;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

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

.tool-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 5px;
}

.tool-btn {
  background: transparent;
  color: var(--t2);
  border: 1px solid transparent;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.tool-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--p);
  border-color: var(--border);
}

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

.toolbar-center {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--t3);
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 20px;
  padding: 10px;
}

.page-card {
  position: relative;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  padding: 8px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  user-select: none;
}

.page-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 15px rgba(0,0,0,0.5);
}

.page-card.selected {
  outline: 3px solid #10b981;
}

.page-canvas-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1.414; /* A4 Ratio approx */
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #ddd;
  transition: transform 0.3s ease;
}

.page-canvas-wrapper canvas {
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 0 5px rgba(0,0,0,0.1);
}

.page-checkbox {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 22px;
  height: 22px;
  background: rgba(0,0,0,0.5);
  border: 2px solid #fff;
  border-radius: 4px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.2s;
}

.page-checkbox.checked {
  background: #10b981;
  border-color: #10b981;
  color: #fff;
}

.page-num-badge {
  position: absolute;
  bottom: -10px;
  right: -10px;
  background: var(--p);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 10;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(5px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-box {
  background: var(--card);
  padding: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  text-align: center;
  width: 90%;
  max-width: 400px;
}

.progress-box .spinner {
  font-size: 3rem;
  color: var(--p);
  margin-bottom: 20px;
}

.sortable-ghost {
  opacity: 0.3;
}

.page-zoom-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  background: rgba(16, 185, 129, 0.9);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  opacity: 0;
  z-index: 20;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.page-card:hover .page-zoom-btn {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.page-zoom-btn:hover {
  background: #059669;
  transform: translate(-50%, -50%) scale(1.1) !important;
}

/* ==========================================
   ZOOM MODAL CSS
   ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(10px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  width: 100%;
  max-width: 800px;
  background: #0f0f29;
  border-radius: 12px;
  box-shadow: 0 15px 50px rgba(0,0,0,0.8);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(255,255,255,0.05);
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
}

.modal-close {
  background: transparent;
  border: none;
  color: #ef4444;
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #f87171;
}

.modal-body {
  padding: 20px;
  background: #2a2a35;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
}

/* Responsive Media Queries for Mobile/Tablets */
@media (max-width: 1024px) {
    .preview-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        height: auto !important;
        padding: 15px;
    }
    
    .toolbar-left, .toolbar-center, .toolbar-right {
        display: flex;
        justify-content: center;
        width: 100% !important;
        flex-wrap: wrap;
        gap: 8px;
    }

    .toolbar-center {
        text-align: center;
        font-size: 0.85rem;
        order: -1; /* Place status text at the top of the stacked toolbar */
    }

    .toolbar-right button {
        width: 100%;
        padding: 12px;
        text-align: center;
    }

    .page-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 12px;
        padding: 5px;
    }

    /* Force zoom button to be visible on touch devices (no hover) */
    .page-zoom-btn {
        opacity: 0.95 !important;
        transform: translate(-50%, -50%) scale(1) !important;
        background: rgba(16, 185, 129, 0.95) !important;
    }
}

@media (max-width: 600px) {
    .modal-content {
        width: 95%;
        height: 85vh;
    }
    
    .tool-header {
        padding: 30px 15px 15px;
    }
    
    .drop-zone {
        padding: 40px 15px;
    }
}
