/* Rotate PDF Converter - Fixed All Issues */
/* ===== CSS VARIABLES ===== */
:root {
  /* Color System */
  --primary-color: #dc2626;
  --primary-light: rgba(220, 38, 38, 0.1);
  --primary-dark: #b91c1c;
  --primary-glow: rgba(220, 38, 38, 0.3);
  
  /* Background Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f1f3f4;
  --bg-card: #ffffff;
  
  /* Border Colors */
  --border-color: #e5e7eb;
  --border-light: #d1d5db;
  
  /* Text Colors */
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #6b7280;
  --text-muted: #9ca3af;
  
  /* Status Colors */
  --success: #10b981;
  --error: #dc2626;
  --warning: #f59e0b;
  --info: #3b82f6;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 6px 12px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 24px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 40px -5px rgba(0, 0, 0, 0.1);
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing: 16px;
  --spacing-md: 24px;
  --spacing-lg: 32px;
  --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 ===== */
.rpdr-converter {
  width: 100% !important;
  min-height: 100vh !important;
  max-height: none !important;
  height: auto !important;
  background: var(--bg-primary);
  border-radius: 0 !important;
  overflow: visible !important;
  position: relative !important;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1 !important; /* VERY LOW Z-INDEX */
  margin: 0 !important;
  box-shadow: none !important;
}

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

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

/* Clean upload button */
.upload-pdf-button {
  width: 320px;
  height: 64px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--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(--shadow-lg);
  margin-bottom: var(--spacing);
}

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

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

/* "or drop files here" text */
.drop-text {
  font-size: 0.9rem;
  color: var(--text-tertiary);
  text-align: center;
}

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

/* ===== WORKSPACE ===== */
.workspace {
  display: flex;
  width: 100%;
  height: auto;
  min-height: 600px;
  position: relative;
  background: transparent;
}

.workspace.hidden {
  display: none;
}

/* ===== DESKTOP: LEFT PANEL (76%) ===== */
.left-panel {
  flex: 3.8;
  display: flex;
  flex-direction: column;
  background: transparent;
  border-right: 1px solid var(--border-color);
  min-height: 0;
}

/* ===== DESKTOP: RIGHT PANEL (24%) ===== */
.right-panel {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  background: transparent;
  min-height: 0;
}

/* ===== PANEL HEADER ===== */
.panel-header {
  background: var(--bg-card);
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  backdrop-filter: blur(20px);
}

.left-panel .panel-header {
  border-bottom: none;
  background: transparent;
  backdrop-filter: none;
}

.panel-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.header-content {
  display: flex;
  align-items: center;
  gap: var(--spacing);
}

.file-stats {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  color: var(--text-tertiary);
  font-size: 0.875rem;
}

.divider {
  color: var(--border-color);
}

.header-actions {
  display: flex;
  gap: var(--spacing-sm);
  margin-left: auto;
}

/* ===== ACTION BUTTONS ===== */
.action-btn {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
  font-weight: 500;
  backdrop-filter: blur(10px);
  -webkit-tap-highlight-color: transparent;
}

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

.action-btn.danger {
  color: var(--error);
  border-color: var(--error);
  background: rgba(220, 38, 38, 0.1);
}

.action-btn.danger:hover {
  background: rgba(220, 38, 38, 0.2);
}

/* ===== PREVIEW CONTENT ===== */
.preview-content {
  flex: 1;
  padding: var(--spacing-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ===== PDF PREVIEW CONTAINER ===== */
.pdf-preview-container {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--spacing);
  align-content: flex-start;
  overflow-y: auto;
  padding: 4px;
  min-height: 0;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--text-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.empty-icon {
  margin-bottom: var(--spacing);
  color: var(--border-color);
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--text-secondary);
}

.empty-state p {
  margin: 0 0 var(--spacing) 0;
  color: var(--text-tertiary);
}

/* ===== PDF PREVIEW CARDS ===== */
.pdf-preview-card {
  background: var(--bg-card);
  border: 1.5px solid #dc2626 !important;
  box-shadow: 0 0 0 1px #fca5a5 !important;
  border-radius: var(--radius-lg);
  padding: var(--spacing);
  transition: all 0.3s ease;
  position: relative;
  cursor: grab;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
  aspect-ratio: 1/1.414;
  max-width: 220px;
  margin: 0 auto;
  width: 100%;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.pdf-preview-card:hover {
  border-color: #dc2626 !important;
  box-shadow: 0 2px 12px 0 #fca5a5 !important;
  transform: translateY(-2px);
}

.pdf-preview-card.dragging {
  opacity: 0.6;
  transform: rotate(5deg);
  border-color: var(--primary-color);
  background: var(--primary-light);
  z-index: 100;
}

.pdf-preview-card:active {
  cursor: grabbing;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--spacing);
  flex-shrink: 0;
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px 0;
  word-break: break-word;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin: 0;
}

.preview-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.preview-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.preview-btn:hover {
  border-color: var(--primary-color);
  color: var(--text-primary);
}

.remove-btn:hover {
  border-color: var(--error);
  color: var(--error);
  background: rgba(220, 38, 38, 0.1);
}

/* ===== PDF CANVAS CONTAINER ===== */
.pdf-canvas-container {
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  margin-bottom: var(--spacing-sm);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  border: 1px solid var(--border-color);
  aspect-ratio: 1/1.414;
}

.pdf-canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  background: white;
  display: block !important;
  max-width: 100% !important;
  max-height: 100% !important;
}

.canvas-placeholder {
  width: 100%;
  height: 100%;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 0.75rem;
  text-align: center;
  padding: 10px;
}

.preview-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
  margin-top: var(--spacing-sm);
}

/* ===== TOOLS CONTENT ===== */
.tools-content {
  flex: 1;
  padding: var(--spacing-md);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  min-height: 0;
}

/* ===== TOOL SECTIONS ===== */
.tool-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing);
  border: 2px solid var(--primary-color);
  backdrop-filter: blur(20px);
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.tool-section:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 var(--spacing) 0;
  color: var(--text-primary);
  display: flex;
  align-items: center;
}

.order-controls {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

/* ORDER BUTTONS */
.order-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}

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

.order-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.order-btn:focus,
.order-btn:focus-visible {
  outline: 2px solid var(--primary-color) !important;
  outline-offset: 2px !important;
  border-color: var(--primary-color) !important;
  background: var(--primary-light) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1) !important;
}

.order-btn:active {
  transform: translateY(1px);
  border-color: var(--primary-color) !important;
  background: var(--primary-light) !important;
  color: var(--text-primary) !important;
}

/* Remove blue focus ring in Firefox */
.order-btn::-moz-focus-inner {
  border: 0;
}

/* Custom Pages Input - FIXED FOR MOBILE */
.custom-pages-input {
  margin-top: var(--spacing-sm);
  display: block;
}

.custom-pages-input.hidden {
  display: none !important;
}

.custom-pages-input input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 4px;
}

.custom-pages-input small {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  display: block;
}

/* SELECT DROPDOWNS */
.format-select,
.quality-select,
.dpi-select,
.color-select {
  width: 120px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
}

.format-select:hover,
.quality-select:hover,
.dpi-select:hover,
.color-select:hover {
  border-color: var(--primary-color);
}

.section-help {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin: 0;
  font-style: italic;
}

/* ===== OPTIONS LIST ===== */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.option-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.option-item:last-child {
  border-bottom: none;
}

.option-item:hover {
  background: var(--primary-light);
  margin: 0 -16px;
  padding: 12px 16px;
  border-radius: var(--radius);
}

.option-info {
  flex: 1;
  min-width: 0;
  padding-right: var(--spacing);
}

.option-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.option-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  line-height: 1.3;
}

.option-control {
  position: relative;
  flex-shrink: 0;
}

.option-control select {
  background: var(--bg-primary);
}

/* ===== FILE SUMMARY ===== */
.file-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.summary-item:last-child {
  border-bottom: none;
}

.summary-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.summary-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ===== PANEL FOOTER ===== */
.panel-footer {
  background: var(--bg-card);
  padding: var(--spacing-md);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  backdrop-filter: blur(20px);
}

/* ===== ROTATE BUTTON ===== */
.merge-btn {
  width: 100%;
  background: #dc2626 !important;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px var(--primary-glow);
  -webkit-tap-highlight-color: transparent;
}

.merge-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s ease;
}

.merge-btn:hover::before {
  left: 100%;
}

.merge-btn:hover:not(:disabled) {
  background: #dc2626 !important;
  border-color: #dc2626 !important;
  color: #fff !important;
  transform: translateY(-2px);
  box-shadow: 0 8px 32px var(--primary-glow);
}

.merge-btn:focus {
  outline: 2px solid #dc2626 !important;
  outline-offset: 2px;
  background: #dc2626 !important;
  border-color: #dc2626 !important;
  color: #fff !important;
}

.merge-btn:disabled {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.file-badge {
  background: rgba(255, 255, 255, 0.3);
  color: #ffffff;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  margin-left: 8px;
}

/* ===== OVERLAY STYLES ===== */
.processing-overlay,
.result-overlay,
.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;
}

.processing-overlay.hidden,
.result-overlay.hidden,
.error-overlay.hidden {
  display: none;
}

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

/* ===== SORTABLE.JS CLASSES ===== */
.sortable-ghost {
  opacity: 0.4;
  background: var(--primary-light);
}

.sortable-chosen {
  opacity: 0.8;
}

.sortable-drag {
  opacity: 0.8;
  background: var(--primary-light);
  border-color: var(--primary-color);
  box-shadow: var(--shadow-lg);
  z-index: 1000 !important;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
}

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

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

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

/* ===== DOWNLOAD NOTIFICATION STYLES ===== */
.download-notification {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-weight: 500;
  box-shadow: var(--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;
}

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

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

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

/* ===== STRICT Z-INDEX FIXES FOR MOBILE ===== */
/* CRITICAL: Force WordPress admin bar and theme headers above plugin */
#wpadminbar,
.admin-bar #wpadminbar {
  z-index: 99999 !important;
}

/* Mobile-specific fixes */
@media (max-width: 768px) {
  /* Force theme elements to be above plugin */
  .site-header,
  .ast-header-wrap,
  .ast-mobile-header-wrap,
  .ast-header-break-point .ast-mobile-header-wrap,
  .ast-desktop .main-header-bar,
  .ast-header-break-point .main-header-bar,
  .ast-above-header,
  .ast-below-header,
  .ast-main-header-wrap,
  .main-header-bar,
  .main-header-bar-navigation,
  .ast-builder-menu,
  .ast-desktop .main-header-menu,
  .ast-header-sections-navigation,
  .ast-mobile-header-content,
  .ast-mobile-menu-wrapper,
  .ast-mobile-popup-content,
  .ast-mobile-menu-overlay,
  .ast-mobile-popup-drawer,
  .ast-header-break-point .main-navigation,
  .ast-header-break-point .main-navigation ul,
  .ast-header-break-point .main-navigation ul ul,
  .menu-toggle,
  .main-navigation,
  .dropdown-menu,
  .sub-menu,
  .wp-block-navigation,
  .wp-block-navigation__container,
  .wp-block-navigation__responsive-container {
    z-index: 10010 !important;
    position: relative !important;
  }
  
  /* STRICT: Plugin must stay below everything */
  .rpdr-converter,
  #rpdr-converter {
    z-index: 1 !important;
    position: relative !important;
  }
  
  /* Plugin mobile elements also stay low */
  .mobile-header,
  .mobile-panel-container,
  .fixed-merge-container,
  .upload-section,
  .workspace,
  .left-panel,
  .right-panel {
    z-index: 1 !important;
    position: relative !important;
  }
  
  /* Only overlays can be above but below theme */
  .processing-overlay,
  .result-overlay,
  .error-overlay {
    z-index: 10000 !important;
  }
  
  /* Download notification should be below theme */
  .download-notification {
    z-index: 9999 !important;
  }
}

/* ===== MOBILE HEADER STYLES - FIXED POSITION ===== */
@media (max-width: 768px) {
  /* Container for mobile */
  .rpdr-converter {
    width: 100% !important;
    min-height: 100vh !important;
    max-height: none !important;
    height: auto !important;
    background: var(--bg-primary);
    border-radius: 0 !important;
    overflow: visible !important;
    position: relative !important;
    margin: 0 !important;
    box-shadow: none !important;
    z-index: 1 !important; /* VERY LOW */
  }
  
  /* Upload section mobile styling */
  .upload-section {
    padding: 20px;
    justify-content: flex-start;
    padding-top: 30px;
    min-height: 400px;
    z-index: 1 !important;
  }
  
  .upload-title h2 {
    font-size: 2rem;
  }
  
  .upload-title p {
    font-size: 1rem;
  }
  
  .upload-pdf-button {
    width: 280px;
    height: 56px;
    font-size: 1rem;
  }
  
  .drop-text {
    font-size: 0.85rem;
    margin-top: var(--spacing-sm);
  }
  
  /* Mobile workspace */
  .workspace {
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    min-height: calc(100vh - 120px) !important;
    background: var(--bg-primary);
    display: block !important;
    z-index: 1 !important;
  }
  
  /* Hide desktop panels on mobile */
  .left-panel,
  .right-panel {
    display: none !important;
  }
  
  /* Mobile Header Container - VERY LOW Z-INDEX */
  .mobile-header {
    position: sticky !important;
    top: 0 !important;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1 !important; /* VERY LOW */
    backdrop-filter: blur(20px);
    margin: 0 !important;
  }
  
  /* Mobile Header Sections */
  .mobile-header-left,
  .mobile-header-center,
  .mobile-header-right {
    display: flex;
    align-items: center;
    height: 100%;
  }
  
  .mobile-header-left {
    flex: 1;
    justify-content: flex-start;
  }
  
  .mobile-header-center {
    flex: 2;
    justify-content: center;
  }
  
  .mobile-header-right {
    flex: 1;
    justify-content: flex-end;
  }
  
  /* Mobile Panel Title */
  #mobile-panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  
  /* Mobile Toggle Button */
  .mobile-toggle-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    padding: 0;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    flex-shrink: 0;
    z-index: 1 !important; /* LOW */
  }
  
  .mobile-toggle-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
  }
  
  .mobile-toggle-btn svg {
    width: 20px;
    height: 20px;
  }
  
  /* Mobile Action Buttons - REMOVED CHANGE FILE BUTTON */
  .mobile-header-left .action-btn {
    min-height: 36px;
    min-width: auto;
    padding: 8px 12px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 1 !important; /* LOW */
  }
  
  /* Mobile Panel Container - VERY LOW Z-INDEX */
  .mobile-panel-container {
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100vh - 140px) !important;
    min-height: 400px !important;
    display: flex !important;
    overflow: hidden;
    z-index: 1 !important; /* VERY LOW */
    margin-top: 0 !important;
  }
  
  /* Mobile Panels */
  .mobile-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    background: var(--bg-primary);
    display: flex !important;
    flex-direction: column;
    z-index: 1 !important; /* LOW */
  }
  
  /* Panel States */
  .mobile-panel.preview-panel {
    transform: translateX(0);
  }
  
  .mobile-panel.tools-panel {
    transform: translateX(100%);
  }
  
  .mobile-panel-container.preview-active .preview-panel {
    transform: translateX(0);
  }
  
  .mobile-panel-container.preview-active .tools-panel {
    transform: translateX(100%);
  }
  
  .mobile-panel-container.tools-active .preview-panel {
    transform: translateX(-100%);
  }
  
  .mobile-panel-container.tools-active .tools-panel {
    transform: translateX(0);
  }
  
  /* Mobile Preview Content */
  .mobile-panel.preview-panel .preview-content {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100%;
    margin-top: 0 !important;
  }
  
  /* Mobile preview cards */
  .mobile-panel .pdf-preview-container {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px;
    align-items: flex-start !important;
    justify-content: flex-start;
    margin-top: 0 !important;
  }
  
  .mobile-panel .pdf-preview-card {
    width: 100% !important;
    max-width: none !important;
    padding: 12px;
    margin: 0 0 12px 0 !important;
    box-sizing: border-box;
    border: 1.5px solid #dc2626 !important;
    box-shadow: 0 0 0 1px #fca5a5 !important;
    background: var(--bg-card) !important;
  }
  
  .mobile-panel .file-name {
    font-size: 0.8rem;
    line-height: 1.2;
    height: 2.4em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
  }
  
  .mobile-panel .file-size {
    font-size: 0.7rem;
  }
  
  /* Canvas container */
  .mobile-panel .pdf-canvas-container {
    height: 140px !important;
    min-height: 140px !important;
    aspect-ratio: 1/1.414;
    position: relative;
  }
  
  /* Canvas rendering */
  .mobile-panel .pdf-canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    background: white !important;
  }
  
  /* Smaller preview buttons */
  .mobile-panel .preview-btn {
    padding: 4px;
    min-width: 28px;
    min-height: 28px;
  }
  
  .mobile-panel .preview-btn svg {
    width: 14px;
    height: 14px;
  }
  
  /* Mobile Tools Content - FIXED: Custom pages input */
  .mobile-panel.tools-panel .tools-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    gap: 16px;
    height: 100%;
    margin-top: 0 !important;
  }
  
  /* Mobile Tool Sections */
  .mobile-panel .tool-section {
    padding: 16px;
  }
  
  .mobile-panel .section-title {
    font-size: 1rem;
    margin-bottom: 12px;
  }
  
  /* FIXED: Mobile custom pages input */
  .mobile-panel .custom-pages-input {
    margin-top: 8px !important;
    display: block !important;
  }
  
  .mobile-panel .custom-pages-input.hidden {
    display: none !important;
  }
  
  .mobile-panel .custom-pages-input input {
    width: 100% !important;
    padding: 8px 10px !important;
    font-size: 0.8rem !important;
  }
  
  /* Mobile select dropdowns */
  .mobile-panel .format-select,
  .mobile-panel .quality-select,
  .mobile-panel .dpi-select,
  .mobile-panel .color-select {
    width: 100px;
    padding: 6px 8px;
    font-size: 0.8rem;
  }
  
  /* Fixed Merge Button - VERY LOW Z-INDEX */
  .fixed-merge-container {
    display: block !important;
    position: sticky !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 16px;
    z-index: 1 !important; /* VERY LOW */
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(20px);
    margin-top: 0 !important;
  }
  
  /* Hide desktop merge button on mobile */
  .panel-footer {
    display: none !important;
  }
  
  /* Touch optimizations */
  .mobile-panel .action-btn,
  .mobile-panel .order-btn,
  .mobile-panel .merge-btn {
    min-height: 44px;
    min-width: 44px;
    background: #dc2626 !important;
    border: none !important;
    color: #fff !important;
  }
  
  .mobile-panel .merge-btn:hover:not(:disabled),
  .mobile-panel .merge-btn:focus {
    background: #dc2626 !important;
    border: none !important;
    color: #fff !important;
    outline: 2px solid #dc2626 !important;
    outline-offset: 2px;
  }
  
  /* Prevent text selection */
  .mobile-panel * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* Better drag experience */
  .mobile-panel .pdf-preview-card {
    touch-action: pan-y;
  }
  
  .mobile-panel .pdf-preview-card:active {
    transform: scale(0.97);
    border-color: #dc2626 !important;
  }
  
  /* Mobile download notification */
  .download-notification {
    top: -100px;
    width: 90%;
    max-width: 300px;
    padding: 10px 20px;
    z-index: 9999 !important; /* Below theme */
  }
  
  .download-notification.show {
    top: 80px;
  }
}

/* ===== VERY SMALL MOBILE DEVICES ===== */
@media (max-width: 480px) {
  .mobile-panel .pdf-preview-card {
    width: 100% !important;
    max-width: none !important;
    padding: 10px;
    margin: 0 0 10px 0 !important;
    box-sizing: border-box;
  }
  
  .mobile-panel .pdf-canvas-container {
    height: 120px !important;
    min-height: 120px !important;
  }
  
  .mobile-panel .preview-content {
    padding: 8px;
  }
  
  .mobile-panel .tools-content {
    padding: 12px;
  }
  
  .mobile-panel .tool-section {
    padding: 12px;
  }
  
  .upload-pdf-button {
    width: 260px;
    height: 52px;
    font-size: 0.95rem;
  }
  
  .upload-title h2 {
    font-size: 1.8rem;
  }
  
  .mobile-header {
    padding: 0 12px;
    height: 55px;
  }
  
  .mobile-header-left .action-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  
  #mobile-panel-title {
    font-size: 1rem;
  }
  
  .mobile-toggle-btn {
    width: 40px;
    height: 40px;
  }
  
  .mobile-toggle-btn svg {
    width: 18px;
    height: 18px;
  }
  
  .mobile-panel-container {
    height: calc(100vh - 135px) !important;
  }
  
  .download-notification {
    width: 95%;
    padding: 8px 16px;
    font-size: 0.9rem;
  }
}

/* ===== DESKTOP STYLES - FULL WIDTH ===== */
@media (min-width: 769px) {
  .rpdr-converter {
    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: 1 !important; /* LOW on desktop too */
  }
  
  /* Full width workspace */
  .workspace {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 0 !important;
  }
  
  /* Full width panels */
  .left-panel,
  .right-panel {
    width: 100%;
  }
  
  /* Hide mobile elements on desktop */
  .mobile-header,
  .mobile-toggle-btn,
  .mobile-panel-container,
  .fixed-merge-container {
    display: none !important;
  }
  
  /* Show desktop panels */
  .left-panel,
  .right-panel {
    display: flex !important;
  }
  
  /* Show desktop rotate button */
  .panel-footer {
    display: block !important;
  }
  
  /* Desktop drag improvements */
  .pdf-preview-card {
    cursor: grab !important;
  }
  
  .pdf-preview-card:active {
    cursor: grabbing !important;
  }
}

/* ===== CRITICAL ICON FIXES ===== */
.remove-btn svg,
.download-btn svg,
.mobile-toggle-btn svg,
.empty-icon svg,
.panel-header svg,
.section-title svg,
.order-btn svg,
.preview-btn svg,
.error-icon svg {
    width: auto !important;
    height: auto !important;
    stroke: currentColor !important;
    fill: none !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

.remove-btn svg {
    width: 16px !important;
    height: 16px !important;
}

.mobile-toggle-btn svg {
    width: 20px !important;
    height: 20px !important;
}

/* ===== MOBILE FILE SUMMARY FIX ===== */
.mobile-panel.tools-panel .tool-section {
    display: block !important;
}

/* ===== FORCE DOWNLOAD FIXES ===== */
/* Force download for all file types */
#rpdr-download-link,
.rpdr-download-link {
    text-decoration: none !important;
    cursor: pointer !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

#rpdr-download-link:hover,
.rpdr-download-link:hover {
    opacity: 0.9 !important;
}

/* Hide iframes used for downloads */
iframe[style*="display: none"],
iframe[style*="width: 0"],
iframe[style*="height: 0"] {
    display: none !important;
    visibility: hidden !important;
}