/* PDF Arrange Tool - Pixel-perfect clone of PDF Merge Tool */
/* ===== CSS VARIABLES ===== */
:root {
  /* Color System */
  --arrpdfq9z3m2-primary-color: #dc2626;
  --arrpdfq9z3m2-primary-light: rgba(220, 38, 38, 0.1);
  --arrpdfq9z3m2-primary-dark: #b91c1c;
  --arrpdfq9z3m2-primary-glow: rgba(220, 38, 38, 0.3);
  
  /* Background Colors */
  --arrpdfq9z3m2-bg-primary: #ffffff;
  --arrpdfq9z3m2-bg-secondary: #f8f9fa;
  --arrpdfq9z3m2-bg-tertiary: #f1f3f4;
  --arrpdfq9z3m2-bg-card: #ffffff;
  
  /* Border Colors */
  --arrpdfq9z3m2-border-color: #e5e7eb;
  --arrpdfq9z3m2-border-light: #d1d5db;
  
  /* Text Colors */
  --arrpdfq9z3m2-text-primary: #111827;
  --arrpdfq9z3m2-text-secondary: #4b5563;
  --arrpdfq9z3m2-text-tertiary: #6b7280;
  --arrpdfq9z3m2-text-muted: #9ca3af;
  
  /* Status Colors */
  --arrpdfq9z3m2-success: #10b981;
  --arrpdfq9z3m2-error: #dc2626;
  --arrpdfq9z3m2-warning: #f59e0b;
  --arrpdfq9z3m2-info: #3b82f6;
  
  /* Shadows */
  --arrpdfq9z3m2-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --arrpdfq9z3m2-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --arrpdfq9z3m2-shadow-md: 0 6px 12px -2px rgba(0, 0, 0, 0.1);
  --arrpdfq9z3m2-shadow-lg: 0 10px 24px -3px rgba(0, 0, 0, 0.1);
  --arrpdfq9z3m2-shadow-xl: 0 20px 40px -5px rgba(0, 0, 0, 0.1);
  
  /* Border Radius */
  --arrpdfq9z3m2-radius-sm: 4px;
  --arrpdfq9z3m2-radius: 8px;
  --arrpdfq9z3m2-radius-md: 12px;
  --arrpdfq9z3m2-radius-lg: 16px;
  --arrpdfq9z3m2-radius-xl: 20px;
  
  /* Spacing */
  --arrpdfq9z3m2-spacing-xs: 4px;
  --arrpdfq9z3m2-spacing-sm: 8px;
  --arrpdfq9z3m2-spacing: 16px;
  --arrpdfq9z3m2-spacing-md: 24px;
  --arrpdfq9z3m2-spacing-lg: 32px;
  --arrpdfq9z3m2-spacing-xl: 48px;
}

/* ===== RESET & BASE STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== MAIN WIDGET CONTAINER ===== */
.arrpdfq9z3m2-pdf-arrange-tool {
  width: 100% !important;
  min-height: 100vh !important;
  max-height: none !important;
  height: auto !important;
  background: var(--arrpdfq9z3m2-bg-primary);
  border-radius: 0 !important;
  overflow: visible !important;
  position: relative !important;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 999 !important;
  margin: 0 !important;
  box-shadow: none !important;
}

/* ===== UPLOAD SECTION ===== */
.arrpdfq9z3m2-upload-section {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--arrpdfq9z3m2-bg-secondary);
  z-index: 10;
  padding: var(--arrpdfq9z3m2-spacing-xl) var(--arrpdfq9z3m2-spacing);
}

.arrpdfq9z3m2-upload-section.active {
  display: flex;
}

.arrpdfq9z3m2-upload-section.hidden {
  display: none;
}

/* UPLOAD TITLE */
.custom-upload-header {
  text-align: center;
  margin-bottom: var(--arrpdfq9z3m2-spacing-xl);
}

/* Upload button */
.arrpdfq9z3m2-upload-pdf-button {
  width: 320px;
  height: 64px;
  background: var(--arrpdfq9z3m2-primary-color);
  color: white;
  border: none;
  border-radius: var(--arrpdfq9z3m2-radius-lg);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: var(--arrpdfq9z3m2-shadow-lg);
  margin-bottom: var(--arrpdfq9z3m2-spacing);
}

.arrpdfq9z3m2-upload-pdf-button:hover {
  background: var(--arrpdfq9z3m2-primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--arrpdfq9z3m2-shadow-xl);
}

.arrpdfq9z3m2-upload-pdf-button:active {
  transform: translateY(0);
}

/* Drop text */
.arrpdfq9z3m2-drop-text {
  font-size: 0.9rem;
  color: var(--arrpdfq9z3m2-text-tertiary);
  text-align: center;
}

#arrpdfq9z3m2-pdf-file-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 11;
}

/* ===== GIF OVERLAY ===== */
.arrpdfq9z3m2-gif-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  z-index: 100001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.arrpdfq9z3m2-gif-overlay.hidden {
  display: none;
}

.arrpdfq9z3m2-gif-container {
  width: 100%;
  max-width: 800px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.arrpdfq9z3m2-gif-content {
  background: var(--arrpdfq9z3m2-bg-card);
  border-radius: var(--arrpdfq9z3m2-radius-xl);
  padding: 40px;
  text-align: center;
  box-shadow: var(--arrpdfq9z3m2-shadow-xl);
  width: 100%;
  max-width: 600px;
}

#arrpdfq9z3m2-gif-player {
  width: 100%;
  max-width: 500px;
  height: 300px;
  margin: 0 auto 30px;
  border-radius: var(--arrpdfq9z3m2-radius-lg);
  overflow: hidden;
  background: var(--arrpdfq9z3m2-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

#arrpdfq9z3m2-gif-player img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.arrpdfq9z3m2-gif-countdown {
  margin: 30px 0;
}

.arrpdfq9z3m2-countdown-circle {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 60px;
}

.arrpdfq9z3m2-countdown-circle svg {
  transform: rotate(-90deg);
}

#arrpdfq9z3m2-countdown-circle {
  stroke-dashoffset: 175;
  transition: stroke-dashoffset 1s linear;
}

#arrpdfq9z3m2-countdown-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--arrpdfq9z3m2-primary-color);
}

.arrpdfq9z3m2-gif-instructions h3 {
  font-size: 1.8rem;
  color: var(--arrpdfq9z3m2-text-primary);
  margin-bottom: 15px;
}

.arrpdfq9z3m2-gif-instructions p {
  color: var(--arrpdfq9z3m2-text-secondary);
  font-size: 1.1rem;
  line-height: 1.6;
}

/* ===== EDITOR CONTAINER ===== */
.arrpdfq9z3m2-editor-container {
  width: 100%;
  height: calc(100vh - 60px);
  min-height: 600px;
  position: relative;
  background: transparent;
  display: flex;
  flex-direction: column;
}

.arrpdfq9z3m2-editor-container.hidden {
  display: none;
}

.arrpdfq9z3m2-editor-container.active {
  display: flex;
}

/* Editor Header */
.arrpdfq9z3m2-editor-header {
  background: var(--arrpdfq9z3m2-primary-color);
  color: white;
  padding: var(--arrpdfq9z3m2-spacing);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--arrpdfq9z3m2-shadow-md);
}

.arrpdfq9z3m2-editor-header.hidden {
  display: none;
}

.arrpdfq9z3m2-editor-header-left,
.arrpdfq9z3m2-editor-header-center,
.arrpdfq9z3m2-editor-header-right {
  flex: 1;
  display: flex;
  align-items: center;
}

.arrpdfq9z3m2-editor-header-center {
  justify-content: center;
}

.arrpdfq9z3m2-editor-header-right {
  justify-content: flex-end;
}

.arrpdfq9z3m2-editor-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: white;
}

/* Back Button */
.arrpdfq9z3m2-editor-back-btn {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  border-radius: var(--arrpdfq9z3m2-radius);
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.arrpdfq9z3m2-editor-back-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateX(-2px);
}

.arrpdfq9z3m2-editor-back-btn svg {
  width: 18px;
  height: 18px;
}

/* Editor Status */
.arrpdfq9z3m2-editor-status {
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 12px;
  border-radius: var(--arrpdfq9z3m2-radius);
  font-size: 0.85rem;
  font-weight: 500;
}

.arrpdfq9z3m2-editor-placeholder {
  flex: 1;
  width: 100%;
  position: relative;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.arrpdfq9z3m2-editor-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  z-index: 5;
}

.arrpdfq9z3m2-editor-loading .loading-content {
  text-align: center;
  padding: var(--arrpdfq9z3m2-spacing-xl);
  background: white;
  border-radius: var(--arrpdfq9z3m2-radius-lg);
  box-shadow: var(--arrpdfq9z3m2-shadow-md);
  max-width: 400px;
  width: 90%;
}

/* ===== PROCESSING OVERLAY ===== */
.arrpdfq9z3m2-processing-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.arrpdfq9z3m2-processing-overlay.hidden {
  display: none;
}

.arrpdfq9z3m2-processing-content {
  background: var(--arrpdfq9z3m2-bg-card);
  border-radius: var(--arrpdfq9z3m2-radius-xl);
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  border: 1px solid var(--arrpdfq9z3m2-border-color);
  backdrop-filter: blur(20px);
  box-shadow: var(--arrpdfq9z3m2-shadow-xl);
}

/* Animation for dotted spinner */
@keyframes arrpdfq9z3m2-dotted-spin { 
  100% { 
    transform: rotate(360deg); 
  } 
}
.dotted-spinner { 
  animation: arrpdfq9z3m2-dotted-spin 1.2s linear infinite; 
}

/* ===== DOWNLOAD NOTIFICATION ===== */
.arrpdfq9z3m2-download-notification {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--arrpdfq9z3m2-success);
  color: white;
  padding: 12px 24px;
  border-radius: var(--arrpdfq9z3m2-radius);
  font-weight: 500;
  box-shadow: var(--arrpdfq9z3m2-shadow-lg);
  z-index: 2147483647;
  transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 200px;
  text-align: center;
}

.arrpdfq9z3m2-download-notification.show {
  top: 20px;
}

.arrpdfq9z3m2-download-notification-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}

.arrpdfq9z3m2-download-notification-content svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

/* ===== ERROR OVERLAY ===== */
.arrpdfq9z3m2-error-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.arrpdfq9z3m2-error-overlay.hidden {
  display: none;
}

.arrpdfq9z3m2-error-content {
  background: var(--arrpdfq9z3m2-bg-card);
  border-radius: var(--arrpdfq9z3m2-radius-xl);
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  border: 1px solid var(--arrpdfq9z3m2-border-color);
  backdrop-filter: blur(20px);
  box-shadow: var(--arrpdfq9z3m2-shadow-xl);
}

.arrpdfq9z3m2-error-icon {
  margin-bottom: var(--arrpdfq9z3m2-spacing-md);
  color: var(--arrpdfq9z3m2-error);
}

.arrpdfq9z3m2-error-icon svg {
  width: 64px;
  height: 64px;
}

.arrpdfq9z3m2-error-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--arrpdfq9z3m2-spacing);
  color: var(--arrpdfq9z3m2-text-primary);
}

.arrpdfq9z3m2-error-description {
  color: var(--arrpdfq9z3m2-text-secondary);
  margin-bottom: var(--arrpdfq9z3m2-spacing-xl);
}

.arrpdfq9z3m2-error-actions {
  display: flex;
  gap: var(--arrpdfq9z3m2-spacing);
  justify-content: center;
}

.arrpdfq9z3m2-primary-btn {
  background: var(--arrpdfq9z3m2-primary-color);
  color: white;
  border: none;
  border-radius: var(--arrpdfq9z3m2-radius);
  padding: 12px 24px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.arrpdfq9z3m2-primary-btn:hover {
  background: var(--arrpdfq9z3m2-primary-dark);
}

.arrpdfq9z3m2-primary-btn.large {
  padding: 14px 28px;
  font-size: 1rem;
}

.arrpdfq9z3m2-secondary-btn {
  background: var(--arrpdfq9z3m2-bg-tertiary);
  color: var(--arrpdfq9z3m2-text-secondary);
  border: 1px solid var(--arrpdfq9z3m2-border-color);
  border-radius: var(--arrpdfq9z3m2-radius);
  padding: 12px 24px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.arrpdfq9z3m2-secondary-btn:hover {
  background: var(--arrpdfq9z3m2-border-color);
}

.arrpdfq9z3m2-secondary-btn.large {
  padding: 14px 28px;
  font-size: 1rem;
}

/* ===== MOBILE STYLES ===== */
@media (max-width: 768px) {
  .arrpdfq9z3m2-pdf-arrange-tool {
    min-height: 100vh !important;
  }
  
  .arrpdfq9z3m2-upload-section {
    min-height: 400px;
    padding: 20px;
    padding-top: 30px;
  }
  
  .arrpdfq9z3m2-upload-pdf-button {
    width: 280px;
    height: 56px;
    font-size: 1rem;
  }
  
  .arrpdfq9z3m2-drop-text {
    font-size: 0.85rem;
    margin-top: var(--arrpdfq9z3m2-spacing-sm);
  }
  
  .arrpdfq9z3m2-editor-container {
    height: calc(100vh - 50px);
    min-height: 500px;
  }
  
  .arrpdfq9z3m2-editor-header {
    padding: 12px 16px;
  }
  
  .arrpdfq9z3m2-editor-header h2 {
    font-size: 1rem;
  }
  
  .arrpdfq9z3m2-editor-back-btn {
    padding: 8px 12px;
    font-size: 0.85rem;
  }
  
  .arrpdfq9z3m2-editor-back-btn svg {
    width: 16px;
    height: 16px;
  }
  
  .arrpdfq9z3m2-editor-status {
    font-size: 0.75rem;
    padding: 4px 8px;
  }
  
  .arrpdfq9z3m2-download-notification {
    width: 90%;
    max-width: 300px;
    padding: 10px 20px;
  }
  
  .arrpdfq9z3m2-download-notification.show {
    top: 80px;
  }
  
  /* Mobile GIF Overlay */
  .arrpdfq9z3m2-gif-container {
    padding: 10px;
  }
  
  .arrpdfq9z3m2-gif-content {
    padding: 20px;
    max-width: 95%;
  }
  
  #arrpdfq9z3m2-gif-player {
    height: 200px;
    max-width: 100%;
  }
  
  .arrpdfq9z3m2-gif-instructions h3 {
    font-size: 1.4rem;
  }
  
  .arrpdfq9z3m2-gif-instructions p {
    font-size: 1rem;
  }
}

/* ===== VERY SMALL MOBILE DEVICES ===== */
@media (max-width: 480px) {
  .arrpdfq9z3m2-upload-pdf-button {
    width: 260px;
    height: 52px;
    font-size: 0.95rem;
  }
  
  .custom-upload-header h1 {
    font-size: 2rem;
  }
  
  .arrpdfq9z3m2-download-notification {
    width: 95%;
    padding: 8px 16px;
    font-size: 0.9rem;
  }
  
  .arrpdfq9z3m2-editor-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .arrpdfq9z3m2-editor-header-left,
  .arrpdfq9z3m2-editor-header-center,
  .arrpdfq9z3m2-editor-header-right {
    flex: 100%;
    justify-content: center;
  }
  
  .arrpdfq9z3m2-editor-header-center {
    order: 1;
  }
  
  .arrpdfq9z3m2-editor-header-left {
    order: 2;
  }
  
  .arrpdfq9z3m2-editor-header-right {
    order: 3;
  }
  
  #arrpdfq9z3m2-gif-player {
    height: 180px;
  }
}

/* ===== DESKTOP STYLES ===== */
@media (min-width: 769px) {
  .arrpdfq9z3m2-pdf-arrange-tool {
    position: relative;
    margin: 0 auto;
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    left: 0 !important;
    right: 0 !important;
  }
}

/* ===== Z-INDEX FIXES ===== */
.arrpdfq9z3m2-pdf-arrange-tool,
#arrpdfq9z3m2-pdf-arrange-tool {
  z-index: 1 !important;
  position: relative !important;
}

.arrpdfq9z3m2-processing-overlay,
.arrpdfq9z3m2-error-overlay {
  z-index: 10000 !important;
}

.arrpdfq9z3m2-gif-overlay {
  z-index: 100001 !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--arrpdfq9z3m2-bg-tertiary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: var(--arrpdfq9z3m2-border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--arrpdfq9z3m2-primary-color);
}

/* Animation for notification */
@keyframes arrpdfq9z3m2-notification-slide {
  0% { transform: translateX(-50%) translateY(-100px); }
  100% { transform: translateX(-50%) translateY(0); }
}

.arrpdfq9z3m2-download-notification.show {
  animation: arrpdfq9z3m2-notification-slide 0.3s ease-out;
}

/* Countdown animation */
@keyframes arrpdfq9z3m2-countdown-fill {
  0% { stroke-dashoffset: 175; }
  100% { stroke-dashoffset: 0; }
}

/* Ensure our overlays are above SimplePDF */
.arrpdfq9z3m2-processing-overlay,
.arrpdfq9z3m2-error-overlay {
  z-index: 100001 !important;
}

.arrpdfq9z3m2-download-notification {
  z-index: 100002 !important;
}

/* Mobile fixes for SimplePDF modal */
@media (max-width: 768px) {
  .simplepdf-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
  }
  
  .simplepdf-modal iframe {
    height: 100% !important;
  }
  
  /* Prevent iOS zoom */
  #arrpdfq9z3m2-simplepdf-iframe {
    font-size: 16px !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
}

/* Safari-specific fixes */
@supports (-webkit-touch-callout: none) {
  #arrpdfq9z3m2-simplepdf-iframe {
    height: -webkit-fill-available !important;
    min-height: 500px;
  }
  
  .arrpdfq9z3m2-editor-container {
    height: -webkit-fill-available !important;
    min-height: 500px;
  }
  
  #arrpdfq9z3m2-simplepdf-iframe-wrapper {
    height: -webkit-fill-available !important;
    min-height: 500px;
  }
}

/* Android-specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: .001dpcm) {
  #arrpdfq9z3m2-simplepdf-iframe {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }
}

/* Prevent unwanted scrolling on mobile */
.arrpdfq9z3m2-pdf-arrange-tool {
  -webkit-overflow-scrolling: touch;
  overflow-x: hidden;
}

/* Fix for mobile viewport height issues */
@media (max-width: 768px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }
  
  .arrpdfq9z3m2-pdf-arrange-tool {
    height: 100vh !important;
    min-height: 100vh !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Loading animation improvements for mobile */
@media (max-width: 768px) {
  .arrpdfq9z3m2-editor-loading .loading-content {
    padding: 30px 20px;
    margin: 20px;
    max-width: 320px;
  }
  
  .dotted-loading-ring {
    width: 48px !important;
    height: 48px !important;
  }
  
  .dotted-spinner {
    width: 48px !important;
    height: 48px !important;
  }
  
  .dotted-spinner-inner svg {
    width: 20px !important;
    height: 20px !important;
  }
}

/* Mobile header adjustments */
@media (max-width: 768px) {
  .arrpdfq9z3m2-editor-header {
    padding: 12px 16px;
    height: 60px;
    min-height: 60px;
    flex-shrink: 0;
  }
  
  .arrpdfq9z3m2-editor-back-btn {
    padding: 8px 12px;
    font-size: 14px;
  }
  
  .arrpdfq9z3m2-editor-header h2 {
    font-size: 16px;
  }
}

/* Download helper button styles */
.arrpdfq9z3m2-download-helper {
  transition: all 0.3s ease !important;
  background: rgba(255, 255, 255, 0.15) !important;
  color: white !important;
  border: none !important;
  border-radius: var(--arrpdfq9z3m2-radius) !important;
  padding: 6px 12px !important;
  font-size: 0.85rem !important;
  cursor: pointer !important;
  margin-right: 8px !important;
}

.arrpdfq9z3m2-download-helper:hover {
  background: rgba(255, 255, 255, 0.25) !important;
}

.arrpdfq9z3m2-download-helper:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

/* Fullscreen toggle button */
.arrpdfq9z3m2-fullscreen-toggle {
  transition: all 0.3s ease !important;
  background: rgba(255, 255, 255, 0.15) !important;
  color: white !important;
  border: none !important;
  border-radius: var(--arrpdfq9z3m2-radius) !important;
  padding: 6px 12px !important;
  font-size: 0.85rem !important;
  cursor: pointer !important;
}

.arrpdfq9z3m2-fullscreen-toggle:hover {
  background: rgba(255, 255, 255, 0.25) !important;
}

/* Ensure proper touch targets on mobile */
@media (max-width: 768px) {
  .arrpdfq9z3m2-editor-back-btn,
  .arrpdfq9z3m2-download-helper,
  .arrpdfq9z3m2-fullscreen-toggle {
    min-height: 36px !important;
    min-width: 44px !important; /* Minimum touch target size */
  }
}

/* Fix for iframe loading on slow connections */
#arrpdfq9z3m2-simplepdf-iframe {
  background: white !important;
}

/* Fix viewport issues on mobile */
@media (max-width: 768px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }
  
  .arrpdfq9z3m2-pdf-arrange-tool {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
  }
}

/* Prevent iframe from causing page scroll */
.arrpdfq9z3m2-editor-container {
  overflow: hidden !important;
}

#arrpdfq9z3m2-simplepdf-iframe-wrapper {
  overflow: auto !important;
}

/* Loading state improvements for mobile */
@media (max-width: 768px) {
  .arrpdfq9z3m2-editor-loading .loading-content {
    padding: 40px 20px !important;
    margin: 20px !important;
  }
}

/* ===== BACKGROUND RETURN BUTTON ===== */
.arrpdfq9z3m2-background-return-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.arrpdfq9z3m2-background-return-btn.show {
    opacity: 1;
    visibility: visible;
}

.arrpdfq9z3m2-return-to-upload {
    background: var(--arrpdfq9z3m2-primary-color);
    color: white;
    border: none;
    border-radius: var(--arrpdfq9z3m2-radius-lg);
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: var(--arrpdfq9z3m2-shadow-lg);
    min-width: 200px;
    justify-content: center;
}

.arrpdfq9z3m2-return-to-upload:hover {
    background: var(--arrpdfq9z3m2-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--arrpdfq9z3m2-shadow-xl);
}

.arrpdfq9z3m2-return-to-upload:active {
    transform: translateY(0);
}

.arrpdfq9z3m2-return-to-upload svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* Mobile styles for background button */
@media (max-width: 768px) {
    .arrpdfq9z3m2-background-return-btn {
        bottom: 20px;
        right: 20px;
        left: 20px;
        text-align: center;
    }
    
    .arrpdfq9z3m2-return-to-upload {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
        padding: 14px 20px;
        font-size: 0.95rem;
    }
    
    .arrpdfq9z3m2-return-to-upload svg {
        width: 18px;
        height: 18px;
    }
}

/* Ensure button is above SimplePDF modal */
.arrpdfq9z3m2-background-return-btn {
    z-index: 100050 !important;
}

/* Animation for button appearance */
@keyframes arrpdfq9z3m2-return-button-slide {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.arrpdfq9z3m2-background-return-btn.show {
    animation: arrpdfq9z3m2-return-button-slide 0.5s ease-out;
}

/* Make button semi-transparent when SimplePDF modal is active */
.simplepdf-modal-open .arrpdfq9z3m2-return-to-upload {
    background: rgba(220, 38, 38, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Add subtle pulse animation to attract attention */
@keyframes arrpdfq9z3m2-return-button-pulse {
    0% {
        box-shadow: var(--arrpdfq9z3m2-shadow-lg);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(220, 38, 38, 0.2), var(--arrpdfq9z3m2-shadow-lg);
    }
    100% {
        box-shadow: var(--arrpdfq9z3m2-shadow-lg);
    }
}

.arrpdfq9z3m2-background-return-btn:not(:hover) {
    animation: arrpdfq9z3m2-return-button-pulse 2s infinite;
}

/* ===== RETURN TO UPLOAD BUTTON ===== */
.arrpdfq9z3m2-return-to-upload-button {
    margin-top: 30px;
    text-align: center;
    animation: arrpdfq9z3m2-button-fade-in 0.5s ease-out;
}

.arrpdfq9z3m2-return-to-upload-button.hidden {
    display: none;
}

.arrpdfq9z3m2-upload-return-btn {
    background: var(--arrpdfq9z3m2-primary-color);
    color: white;
    border: none;
    border-radius: var(--arrpdfq9z3m2-radius-lg);
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: var(--arrpdfq9z3m2-shadow-lg);
    margin: 0 auto;
}

.arrpdfq9z3m2-upload-return-btn:hover {
    background: var(--arrpdfq9z3m2-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--arrpdfq9z3m2-shadow-xl);
}

.arrpdfq9z3m2-upload-return-btn:active {
    transform: translateY(0);
}

.arrpdfq9z3m2-upload-return-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

@keyframes arrpdfq9z3m2-button-fade-in {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile styles for return button */
@media (max-width: 768px) {
    .arrpdfq9z3m2-return-to-upload-button {
        margin-top: 20px;
    }
    
    .arrpdfq9z3m2-upload-return-btn {
        padding: 12px 20px;
        font-size: 0.95rem;
        width: 100%;
        max-width: 280px;
    }
    
    .arrpdfq9z3m2-upload-return-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* Ensure hidden class works properly */
.arrpdfq9z3m2-editor-loading .loading-content h3.hidden,
.arrpdfq9z3m2-editor-loading .loading-content p.hidden {
    display: none;
}

.arrpdfq9z3m2-editor-loading .loading-content h3,
.arrpdfq9z3m2-editor-loading .loading-content p {
    display: block;
}

/* GIF overlay animations */
@keyframes arrpdfq9z3m2-gif-fade-in {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.arrpdfq9z3m2-gif-overlay:not(.hidden) {
    animation: arrpdfq9z3m2-gif-fade-in 0.3s ease-out;
}