/* PDF Merge Tool - 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 ===== */
.pdf-merge-tool {
  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: 999 !important;
  margin: 0 !important;
  box-shadow: none !important;
}


/* ===== TITLE SECTION ===== */
.plugin-title-section {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing) var(--spacing);
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: white;
  position: relative;
  z-index: 5;
}

.plugin-title-section.hidden {
  display: none;
}

.plugin-main-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: var(--spacing-sm);
  color: white;
}

.plugin-subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  font-weight: 400;
}

/* ===== 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: 10;
}

.upload-section.hidden {
  display: none;
}

/* UPLOAD TITLE - Same as desktop */
.upload-title {
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

.upload-title h2 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: var(--spacing-sm);
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--primary-color);
}

.upload-title p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  opacity: 0.9;
}

/* 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;
}

#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.secondary {
  border-color: var(--primary-color);
  color: var(--text-primary);
}

.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 ===== */
/* Add thin, visible outline to preview cards */
.pdf-preview-card {
  background: var(--bg-card);
  border: 1.5px solid #dc2626 !important; /* Red thin outline, force everywhere */
  box-shadow: 0 0 0 1px #fca5a5 !important; /* Subtle red glow, force everywhere */
  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;
}

/* FIXED: Desktop drag */
/* Keep outline red on hover */
.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);
}

/* EXISTING CODE - DON'T CHANGE */
.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);
}

/* NEW CODE TO ADD - Fix blue focus/click issue */
.order-btn:focus,
.order-btn:focus-visible {
  outline: 2px solid var(--primary-color) !important;  /* Red outline instead of blue */
  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;
}

.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 input[type="checkbox"] {
  opacity: 0;
  position: absolute;
  width: 0;
  height: 0;
}

.checkmark {
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
  display: block;
  border: 1px solid var(--border-color);
}

.checkmark::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--text-tertiary);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.option-control input[type="checkbox"]:checked + .checkmark {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.option-control input[type="checkbox"]:checked + .checkmark::after {
  background: #ffffff;
  transform: translateX(20px);
}

/* ===== 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);
}

/* ===== MERGE BUTTON ===== */
/* Merge button always red, even on hover */
.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%;
}

/* Keep background red on hover */
.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);
}

/* Prevent blue focus ring on click */
.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 - FIXED FOR DESKTOP ===== */
.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;
}

/* ===== MOBILE HEADER STYLES - FIXED POSITION ===== */
@media (max-width: 768px) {
  /* Container for mobile */
  .pdf-merge-tool {
    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;
  }
  
  /* Upload section mobile styling */
  .upload-section {
    padding: 20px;
    justify-content: flex-start;
    padding-top: 30px;
    min-height: 400px;
  }
  
  .upload-title {
    margin-bottom: var(--spacing-lg);
  }
  
  .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 - FIXED */
  .workspace {
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    min-height: calc(100vh - 120px) !important;
    background: var(--bg-primary);
    display: block !important;
  }
  
  /* Hide desktop panels on mobile */
  .left-panel,
  .right-panel {
    display: none !important;
  }
  
  /* Mobile Header Container - FIXED: Positioned at widget level */
  .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: 1000 !important;
    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;
    gap: 8px;
  }
  
  .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 - FIXED */
  .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;
  }
  
  .mobile-toggle-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
  }
  
  .mobile-toggle-btn svg {
    width: 20px;
    height: 20px;
  }
  
  /* Mobile Action Buttons */
  .mobile-header-left .action-btn {
    min-height: 36px;
    min-width: auto;
    padding: 8px 12px;
    font-size: 0.85rem;
    white-space: nowrap;
  }
  
  /* Mobile Panel Container - FIXED */
  .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;
    margin-top: 0 !important;
  }
  
  /* Mobile Panels - FIXED */
  .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;
  }
  
  /* Panel States - FIXED */
  .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);
  }
  
  /* FIXED: 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;
  }
  
  /* FIXED: SINGLE COLUMN 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 preview cards */
  .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;
  }
  
  /* Smaller file info */
  .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 */
  .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 Merge Button - Positioned at widget level */
  .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: 100 !important;
    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;
  }
  
  .download-notification.show {
    top: 80px;
  }
}

/* ===== VERY SMALL MOBILE DEVICES ===== */
@media (max-width: 480px) {
  /* Even smaller previews */
  .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) {
  .pdf-merge-tool {
    position: relative;
    margin: 0 auto;
    max-width: 100% !important; /* FIXED: Full width on desktop */
    width: 100% !important; /* FIXED: Full width on desktop */
    border-radius: 0 !important;
    box-shadow: none !important;
    left: 0 !important;
    right: 0 !important;
  }
  
  /* 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 merge 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 ===== */
/* Reset all SVG styling to original */
.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 header action buttons */
.mobile-header-actions .action-btn svg {
    width: 14px !important;
    height: 14px !important;
}

/* ===== MOBILE FILE SUMMARY FIX ===== */
/* Show file summary on mobile */
.mobile-panel.tools-panel .tool-section {
    display: block !important;
}

/* ===== DOWNLOAD LINK FIX ===== */
/* Remove any target attributes from download link */
#download-link {
    target: none !important;
}

/* ===== FORCE DOWNLOAD FIXES ===== */
/* Remove any target attributes from download link */
#download-link {
    text-decoration: none !important;
    cursor: pointer !important;
}

#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;
}

/* ===== Z-INDEX FIXES ===== */

/* 1. PLUGIN CONTAINER - MAKE LOW PRIORITY */
.pdf-merge-tool,
#pdf-merge-tool {
    z-index: 1 !important;
    position: relative !important;
}

/* 2. THEME OVERRIDES - FORCE ABOVE PLUGIN (MOBILE ONLY) */
@media (max-width: 768px) {
    /* UNIVERSAL THEME FIXES */
    #wpadminbar,
    .admin-bar #wpadminbar,
    header,
    .site-header,
    .main-header,
    .header-wrapper,
    .navigation,
    .main-navigation,
    .mobile-menu,
    .dropdown-menu,
    .sub-menu,
    .menu-toggle,
    .wp-block-navigation,
    .wp-block-navigation__container,
    .wp-block-navigation__responsive-container {
        z-index: 10010 !important;
        position: relative !important;
    }
    
    /* POPULAR THEME SPECIFICS */
    /* Astra */
    .ast-header-wrap,
    .ast-mobile-header-wrap,
    .ast-mobile-popup-content,
    .ast-mobile-menu-overlay,
    .ast-header-break-point .main-header-bar {
        z-index: 10010 !important;
    }
    
    /* GeneratePress */
    .main-navigation,
    .menu-toggle {
        z-index: 10010 !important;
    }
    
    /* OceanWP */
    #site-header,
    #mobile-menu {
        z-index: 10010 !important;
    }
    
    /* Divi */
    #main-header,
    .et_mobile_menu {
        z-index: 10010 !important;
    }
    
    /* Avada */
    .fusion-header-wrapper,
    .fusion-mobile-menu {
        z-index: 10010 !important;
    }
}

/* 3. PLUGIN OVERLAYS/MODALS */
.processing-overlay,
.result-overlay,
.error-overlay {
    z-index: 10000 !important; /* Below theme but above plugin */
}

.processing-overlay .content,
.result-overlay .content,
.error-overlay .content {
    z-index: auto !important;
}