/**
 * Advanced PDF Page Sorter Styles
 * Responsive, modern, smooth animations
 */

/* ===== MODAL/CONTAINER ===== */

.advanced-merge-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.advanced-merge-modal.active {
  display: flex;
}

.advanced-merge-container {
  background: white;
  border-radius: 20px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== HEADER ===== */

.advanced-merge-header {
  padding: 25px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.advanced-merge-header h2 {
  color: #333;
  font-size: 22px;
  margin: 0;
  flex: 1;
}

.advanced-merge-header-info {
  font-size: 13px;
  color: #999;
}

.advanced-merge-close-btn {
  background: none;
  border: none;
  color: #999;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.advanced-merge-close-btn:hover {
  color: #333;
  background: #f3f4f6;
  border-radius: 8px;
}

/* ===== CONTENT AREA ===== */

.advanced-merge-content {
  flex: 1;
  overflow-y: auto;
  padding: 25px;
  background: #fafafa;
}

/* ===== STATUS ===== */

.page-sorter-status {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 13px;
  background: #dbeafe;
  color: #1e40af;
  display: none;
}

.page-sorter-status:not(:empty) {
  display: block;
  animation: slideDown 0.2s ease-out;
}

.page-sorter-status.error {
  background: #fee2e2;
  color: #991b1b;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== LEGEND ===== */

.page-sorter-legend {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e5e7eb;
}

.legend-title {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #555;
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== GRID ===== */

.page-sorter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 15px;
}

/* Desktop */
@media (min-width: 1024px) {
  .page-sorter-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
  }
}

/* Tablet */
@media (max-width: 768px) {
  .page-sorter-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .page-sorter-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }
}

/* ===== PAGE CARD ===== */

.page-card {
  cursor: grab;
  user-select: none;
  transition: all 0.2s ease;
  border: 4px solid transparent;
  border-radius: 12px;
  overflow: hidden;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  aspect-ratio: 0.71 / 1; /* PDF aspect ratio */
}

.page-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
  border-color: currentColor;
}

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

.page-card.drag-over {
  transform: scale(0.95);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.5);
}

.page-card-content {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #f3f4f6;
}

/* ===== PAGE NUMBER OVERLAY ===== */

.page-number {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 100%);
  color: white;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ===== FILE NAME LABEL ===== */

.file-name {
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  padding: 6px 8px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.7) 100%);
  color: white;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== FOOTER ===== */

.advanced-merge-footer {
  padding: 20px 25px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  background: white;
  flex-wrap: wrap;
}

.advanced-merge-actions {
  display: flex;
  gap: 10px;
}

.advanced-merge-btn {
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.advanced-merge-btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.advanced-merge-btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.advanced-merge-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.advanced-merge-btn-secondary {
  background: #f3f4f6;
  color: #333;
  border: 1px solid #e5e7eb;
}

.advanced-merge-btn-secondary:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
}

.advanced-merge-btn-reset {
  background: transparent;
  color: #667eea;
  border: 1px solid #667eea;
}

.advanced-merge-btn-reset:hover {
  background: #f0f4ff;
}

.advanced-merge-page-count {
  font-size: 13px;
  color: #666;
}

.advanced-merge-filename-input {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #666;
}

.advanced-merge-filename-input label {
  font-weight: 600;
  color: #333;
}

.advanced-merge-filename-input input {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-family: monospace;
  min-width: 180px;
  transition: all 0.2s;
}

.advanced-merge-filename-input input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.advanced-merge-page-count strong {
  color: #333;
  font-weight: 600;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
  .advanced-merge-container {
    max-height: 95vh;
    border-radius: 16px;
  }

  .advanced-merge-header {
    padding: 18px;
    flex-direction: column;
    align-items: flex-start;
  }

  .advanced-merge-content {
    padding: 18px;
  }

  .advanced-merge-footer {
    padding: 16px 18px;
    flex-direction: column-reverse;
  }

  .advanced-merge-actions {
    width: 100%;
  }

  .advanced-merge-btn {
    flex: 1;
    justify-content: center;
  }

  .legend-items {
    gap: 10px;
  }

  .legend-item {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .advanced-merge-container {
    max-height: 98vh;
    border-radius: 12px;
  }

  .advanced-merge-header {
    padding: 14px;
  }

  .advanced-merge-header h2 {
    font-size: 18px;
  }

  .advanced-merge-content {
    padding: 14px;
  }

  .advanced-merge-footer {
    padding: 12px 14px;
  }

  .advanced-merge-btn {
    padding: 10px 16px;
    font-size: 13px;
  }

  .page-sorter-grid {
    gap: 8px;
  }
}

/* ===== SCROLLBAR STYLING ===== */

.advanced-merge-content::-webkit-scrollbar {
  width: 8px;
}

.advanced-merge-content::-webkit-scrollbar-track {
  background: #f3f4f6;
}

.advanced-merge-content::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.advanced-merge-content::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}