/* Modern 2025 Design System - PDFToolHub */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
  --bg-color: #f8f9fa;
  --bg-gradient: radial-gradient(circle at top left, #ffffff, #f0f0f0);
  --primary-color: #4285F4;
  --primary-gradient: linear-gradient(135deg, #34A853, #4285F4);
  --secondary-color: #EA4335;
  --accent-color: #4285F4;
  --glass-bg: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(0, 0, 0, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
  --text-main: #202124;
  --text-muted: #5f6368;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

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

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.08);
}

.app-container {
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
  gap: 30px;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  box-shadow: var(--glass-shadow);
  z-index: 100;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
  padding: 0 10px;
}

.app-logo svg {
  width: 32px;
  height: 32px;
  fill: var(--accent-color);
  filter: drop-shadow(0 0 10px rgba(66, 133, 244, 0.5));
}

.logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(to right, #fff, #94a3b8);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-item {
  padding: 0;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 14px 18px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.nav-btn i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.nav-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-main);
  transform: translateX(5px);
}

.nav-btn.active {
  background: var(--primary-gradient);
  color: #202124;
  box-shadow: 0 4px 15px rgba(66, 133, 244, 0.4);
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 30px;
  overflow-y: auto;
}

/* Premium Upload Zone (2025) */
.upload-zone {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 80px 40px;
  text-align: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: var(--glass-shadow);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary-color);
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.upload-icon-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 30px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.upload-svg {
  width: 64px;
  height: 64px;
  color: var(--primary-color);
  z-index: 2;
  filter: drop-shadow(0 0 15px rgba(66, 133, 244, 0.5));
  transition: transform 0.4s ease;
}

.upload-zone:hover .upload-svg {
  transform: scale(1.1) rotate(-5deg);
}

.upload-ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(66, 133, 244, 0.2) 0%, transparent 70%);
  opacity: 0;
  border-radius: 50%;
  transition: opacity 0.4s ease;
}

.upload-zone:hover .upload-ripple {
  opacity: 1;
  animation: ripple 2s infinite;
}

@keyframes ripple {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.5;
  }

  100% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 0;
  }
}

.upload-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #fff, #94a3b8);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.upload-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.highlight {
  color: var(--primary-color);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Magic Status Card */
.file-status-card {
  margin-top: 30px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  max-width: 400px;
  animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.file-icon {
  width: 40px;
  height: 40px;
  background: rgba(234, 67, 53, 0.1);
  color: #EA4335;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
}

.file-info {
  flex: 1;
  text-align: left;
}

.file-name {
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.file-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-indicator.processing {
  background: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
  animation: pulse 1s infinite;
}

.status-indicator.success {
  background: var(--secondary-color);
  box-shadow: 0 0 10px rgba(52, 168, 83, 0.5);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

/* Tools Container */
.tools-container {
  background: rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-lg);
  padding: 30px;
  border: 1px solid var(--glass-border);
  min-height: 400px;
}

.tool-panel {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.tool-panel.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tool-header h3 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Inputs & Forms */
.form-control {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-md);
  color: #202124;
  padding: 12px 16px;
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  background: rgba(0, 0, 0, 0.06);
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.btn-success {
  background: var(--secondary-color);
  color: #202124;
}

.btn-warning {
  background: #f59e0b;
  color: #1e293b;
}

.btn-info {
  background: #0ea5e9;
  color: #202124;
}

.btn-secondary {
  background: #475569;
  color: #202124;
}

.btn-dark {
  background: #ffffff;
  color: #202124;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* PDF Preview Grid */
.pdf-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 25px;
  margin-top: 30px;
}

.page-container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-sm);
  padding: 10px;
  position: relative;
  transition: var(--transition);
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.page-container:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
  z-index: 10;
}

.page-container canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

.page-container.selected {
  box-shadow: 0 0 0 3px var(--primary-color);
  transform: scale(0.95);
}

.page-container.selected::after {
  content: 'ï¿?;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--primary-color);
  color: #202124;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.page-number {
  position: absolute;
  bottom: -20px;
  /* Moved outside */
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Spinner */
.spinner-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  /* Darker background to clearly signal blocking */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  /* Ensure it is on top of everything including sidebar */
  flex-direction: column;
  /* For text below spinner */
  backdrop-filter: blur(5px);
  /* Stronger blur */
  pointer-events: auto;
  /* Catch all clicks */
  cursor: wait;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(0, 0, 0, 0.06);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

/* Skeleton Loading for Virtual Scrolling */
.page-container.loading {
  background: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 280px;
  /* Approximate height of thumbnail */
}

.skeleton-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(66, 133, 244, 0.2);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 30px;
  color: rgba(0, 0, 0, 0.3);
  font-size: 0.9rem;
}

/* Helpers */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
    padding: 10px;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    top: 0;
    flex-direction: row;
    overflow-x: auto;
    padding: 15px;
    align-items: center;
  }

  .nav-btn span {
    display: none;
    /* Hide text on mobile for compact sidebar */
  }

  .nav-btn {
    width: auto;
    padding: 10px;
    justify-content: center;
  }

  .nav-menu {
    flex-direction: row;
  }
}

/* SortableJS Feedback */
.sortable-ghost {
  opacity: 0.4;
  background: var(--secondary-color);
}

.sortable-chosen {
  background: rgba(0, 0, 0, 0.08);
}

/* Quick Page Extract Button */
.page-container {
  position: relative;
  overflow: hidden;
  /* Keeps button inside rounded corners */
}

.quick-split-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #EA4335;
  color: #202124;
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.quick-split-btn i {
  font-size: 14px;
}

.page-container:hover .quick-split-btn {
  opacity: 1;
  transform: translateY(0);
}

.merge-actions .btn-sm:hover {
  transform: scale(1.1);
}

/* Quick Extract Button in Grid (Restored) */
.quick-split-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: var(--primary-color);
  color: #202124;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.page-container:hover .quick-split-btn {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.quick-split-btn:hover {
  background: #059669;
  transform: translate(-50%, -50%) scale(1.1);
}

/* Merge Selection Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: var(--bg-color);
  width: 90%;
  max-width: 900px;
  height: 85vh;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.modal-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 15px;
  padding: 10px;
}

.modal-page-item {
  position: relative;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  transition: transform 0.2s;
  border: 2px solid transparent;

  /* Layout Fixes */
  min-height: 150px;
  background: rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.modal-page-item:hover {
  transform: translateY(-2px);
}

.modal-page-item.selected {
  border-color: var(--primary-color);
  box-shadow: 0 0 15px rgba(66, 133, 244, 0.3);
}

.modal-page-item:after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(66, 133, 244, 0.2);
  opacity: 0;
  transition: opacity 0.2s;
}

.modal-page-item.selected:after {
  opacity: 1;
}

/* =========================================
   Merge Tool Styles (Premium Redesign)
   ========================================= */
.merge-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 20px;
}

.merge-card {
  background: linear-gradient(145deg, #ffffff, #f8f9fa);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.sortable-ghost {
  opacity: 0.4;
  background: rgba(66, 133, 244, 0.1);
  border: 2px dashed rgba(66, 133, 244, 0.5);
}

.drag-handle:hover {
  color: white !important;
}

.merge-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
  border-color: rgba(66, 133, 244, 0.3);
}

.merge-thumb {
  width: 80px;
  height: 110px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.merge-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Show full page usually better for docs */
  opacity: 0.9;
  transition: opacity 0.3s;
}

.merge-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  /* Text truncation fix */
}

.merge-filename {
  font-weight: 600;
  color: var(--text-main);
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.5px;
}

.merge-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.merge-input-group {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  padding: 4px 10px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  flex: 1;
  max-width: 300px;
}

.merge-input-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-right: 8px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.merge-input-group input {
  background: transparent;
  border: none;
  color: var(--primary-color);
  font-weight: 500;
  width: 100%;
  font-size: 0.9rem;
  outline: none;
}

.merge-input-group input::placeholder {
  color: rgba(0, 0, 0, 0.08);
}

.rotate-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.rotate-btn:hover {
  background: var(--primary-color);
  color: #202124;
  border-color: var(--primary-color);
  transform: scale(1.05);
}

/* =========================================
   Comment Tool Styles
   ========================================= */
.comment-page-container {
  margin-bottom: 40px;
  display: flex;
  justify-content: center;
}

/* This wrapper acts as the coordinate system origin */
.comment-canvas-wrapper {
  position: relative;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  display: block;
  /* Removes inline-block spacing issues */
  line-height: 0;
  /* Ensures container is exact height of canvas */
}

.comment-page-canvas {
  display: block;
  max-width: 100%;
  /* No margin/padding here! */
}

/* The text overlay */
.comment-overlay {
  position: absolute;
  cursor: grab;
  user-select: none;
  white-space: nowrap;
  /* Prevent unauthorized wrapping */
  padding: 2px 4px;
  border: 1px dashed transparent;
  transition: background 0.1s, border-color 0.1s;
  line-height: normal;
  /* Restore line height for text */
  z-index: 10;
  /* Ensure above canvas */
  font-family: Helvetica, Arial, sans-serif;
  /* Match PDF standard font */
}

.comment-overlay:hover {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.04);
  z-index: 11;
}

.comment-overlay.selected {
  border-color: var(--primary-color);
  background: rgba(0, 0, 0, 0.06);
  z-index: 12;
}

.comment-delete-btn {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  color: #202124;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.comment-overlay:hover .comment-delete-btn {
  display: flex;
}

.merge-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-left: 1px solid rgba(0, 0, 0, 0.06);
  padding-left: 15px;
}

.merge-actions .btn-sm {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.modal-page-item .check-icon {
  position: absolute;
  top: 5px;
  right: 5px;
  background: var(--primary-color);
  color: #202124;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  opacity: 0;
  transform: scale(0);
  transition: all 0.2s;
  z-index: 10;
}

.modal-page-item.selected .check-icon {
  opacity: 1;
  transform: scale(1);
}

.modal-page-num {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: #202124;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  z-index: 10;
}

.modal-footer {
  padding-top: 15px;
  margin-top: 15px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 15px;

  /* =========================================
   File Status Card (Used in Convert/Extract/Split)
   ========================================= */
  .file-status-card {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-out;
  }

  .file-icon {
    width: 45px;
    height: 45px;
    background: rgba(239, 68, 68, 0.2);
    /* Red tint */
    color: #EA4335;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
  }

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

  .file-details .filename {
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .file-details .meta {
    font-size: 0.8rem;
    color: var(--text-muted);
  }


  .action-btn-remove {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none !important;
    background: transparent !important;
    color: var(--text-muted) !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
  }

  .action-btn-remove:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
    transform: scale(1.1);
    opacity: 1;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
  }
}

/* Comment Tool Mobile Enhancements */
@media (max-width: 768px) {

  /* Toolbar horizontal scroll */
  #comment-toolbar {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    justify-content: flex-start !important;
    /* Padding to allow scrolling past last item */
    padding-right: 20px !important;
  }

  #comment-input-text {
    min-width: 150px !important;
  }
}

/* --- Comment Tool UX Enhancements --- */

/* Ghost Cursor (Visual Guide) */
#comment-ghost {
  position: absolute;
  pointer-events: none;
  /* Let clicks pass through */
  border: 1px dashed rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 5px;
  white-space: nowrap;
  z-index: 9999;
  display: none;
  /* Hidden by default */
  transform: translate(-50%, -50%);
  /* Centered on mouse */
  font-family: inherit;
  /* Neon glow for visibility */
  text-shadow: 0 0 2px black;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  transition: opacity 0.2s;
}

/* Comment Item Interactions */
.comment-item {
  cursor: grab;
  transition: transform 0.1s, box-shadow 0.1s;
}

.comment-item:hover {
  border: 1px dashed rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.1);
  /* Slight highlight */
}

.comment-item:active {
  cursor: grabbing;
}

/* Lift Up Effect when dragging */
.comment-item.is-dragging {
  transform: translate(-50%, -50%) scale(1.1) !important;
  /* Zoom up */
  z-index: 10000 !important;
  /* Always on top */
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
  /* Drop shadow */
}

/* Page Cursor override */
.pdf-page-canvas {
  cursor: text;
  /* I-Beam over pages */
}


/* FORCE DRAG VISIBILITY */
.comment-item.is-dragging {
  transform: translate(-50%, -50%) scale(1.2) !important;
  z-index: 99999 !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6) !important;
  border: 2px solid #ef4444 !important;
  /* Bright Red Border */
  background: rgba(255, 255, 255, 0.9) !important;
  cursor: grabbing !important;
}


/* Drag Handle Icon */
.comment-drag-handle {
  position: absolute;
  top: -15px;
  left: -15px;
  width: 24px;
  height: 24px;
  background: #ef4444;
  color: #202124;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  font-size: 12px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  opacity: 0;
  /* Hidden by default */
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10001;
}

/* Show Handle on Comment Hover */
.comment-overlay:hover .comment-drag-handle {
  opacity: 1;
  transform: scale(1.1);
}

/* Hover Border for Comment */
.comment-overlay:hover {
  outline: 2px dashed rgba(0, 0, 0, 0.3);
  /* Explicit outline on hover */
  background: rgba(0, 0, 0, 0.08);
}

/* Drag State for Comment */
.comment-overlay.is-dragging {
  /* Existing rules forced visible */
  outline: 3px solid #ef4444 !important;
  transform: translate(-50%, -50%) scale(1.15) !important;
}


/* --- Rotate Tool Styles --- */

/* Rotate Page Controls */
.rotate-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.rotate-controls button {
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #202124;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.rotate-controls button:hover {
  background: var(--accent-color);
  transform: scale(1.1);
}

.rotation-display {
  font-size: 12px;
  font-weight: bold;
  color: var(--accent-color);
  min-width: 35px;
  text-align: center;
}

/* Canvas Wrapper Animation */
.page-card .canvas-wrapper {
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}


/* Page Grid Layout (Multi-Column) */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
  padding: 10px;
}

.page-card {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.2s ease;
}

.page-card:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: var(--accent-color);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.page-card .page-num {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Responsive Grid */
@media (max-width: 768px) {
  .page-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
  }
}

@media (max-width: 480px) {
  .page-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}


/* --- Reorder Tool Styles --- */

/* Drag Handle Icon */
.drag-handle-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  color: rgba(0, 0, 0, 0.4);
  font-size: 16px;
  cursor: grab;
  transition: color 0.2s, transform 0.2s;
}

.page-card:hover .drag-handle-icon {
  color: var(--accent-color);
  transform: scale(1.2);
}

/* Sortable Classes */
.sortable-ghost {
  opacity: 0.4;
  background: var(--accent-color) !important;
}

.sortable-chosen {
  transform: scale(1.05);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.sortable-drag {
  opacity: 0.9;
}

/* Reorder Card Cursor */
.reorder-card {
  cursor: grab;
}

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


/* Reorder Move Indicator */
.page-moved {
  border: 2px solid var(--accent-color) !important;
  background: rgba(66, 133, 244, 0.1) !important;
}

.page-num .original-page {
  color: rgba(0, 0, 0, 0.6);
  text-decoration: line-through;
}

.page-num .new-position {
  color: var(--accent-color);
  font-weight: bold;
}


/* Shifted Page (Side Effect) */
.page-num .shifted-pos {
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  font-style: italic;
}


/* Swap Badge */
.swap-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 8px;
  border-radius: 12px;
  color: #202124;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.swap-badge i {
  font-size: 10px;
}


/* --- Background Tool Styles --- */

/* Page Selection Checkbox */
.page-checkbox {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 12px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.page-card.selected .page-checkbox {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #202124;
}

.page-card.selected {
  border: 2px solid var(--accent-color);
  box-shadow: 0 0 20px rgba(66, 133, 244, 0.3);
}

/* Background Card Cursor */
.background-card {
  cursor: pointer;
  position: relative;
}


/* --- Images to PDF Styles --- */

.img2pdf-card {
  cursor: grab;
  position: relative;
}

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

.img-delete-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  background: rgba(239, 68, 68, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #202124;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 10;
}

.img2pdf-card:hover .img-delete-btn {
  opacity: 1;
}

.img-delete-btn:hover {
  transform: scale(1.1);
  background: #dc2626;
}


/* Fix Dropdown Styling for Dark Theme */
select option {
  background: #1a1a2e;
  color: #202124;
}

select {
  background: rgba(26, 26, 46, 0.95) !important;
  color: white !important;
}


/* --- Mobile Responsive Sidebar --- */

/* Mobile Menu Button */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  width: 45px;
  height: 45px;
  background: var(--accent-color);
  border: none;
  border-radius: 10px;
  color: #202124;
  font-size: 20px;
  cursor: pointer;
  z-index: 1001;
  box-shadow: 0 4px 15px rgba(66, 133, 244, 0.4);
  transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
  transform: scale(1.05);
}

.mobile-menu-btn.active {
  background: #dc2626;
}

/* Mobile Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
  backdrop-filter: blur(3px);
}

.sidebar-overlay.active {
  display: block;
}

/* Mobile Responsive */
@media (max-width: 900px) {
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    height: 100vh;
    width: 260px;
    z-index: 1000;
    transition: left 0.3s ease;
    overflow-y: auto;
  }

  .sidebar.open {
    left: 0;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 70px 15px 20px 15px !important;
  }

  .app-logo {
    padding-top: 10px;
  }
}

@media (max-width: 600px) {
  .sidebar {
    width: 100%;
    left: -100%;
  }

  .sidebar.open {
    left: 0;
  }

  .page-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .toolbar-container {
    flex-direction: column;
    align-items: stretch !important;
  }

  .tool-header h3 {
    font-size: 1.2em;
  }
}


/* --- Desktop Sidebar Collapse --- */

.sidebar-collapse-btn {
  position: absolute;
  top: 25px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  color: rgba(0, 0, 0, 0.6);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  z-index: 10;
}

.sidebar-collapse-btn:hover {
  background: var(--accent-color);
  color: #202124;
  border-color: var(--accent-color);
}

/* Collapsed State */
.sidebar.collapsed {
  width: 70px !important;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-btn span {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .nav-btn {
  justify-content: center;
  padding: 12px;
}

.sidebar.collapsed .nav-btn i {
  margin-right: 0;
  font-size: 20px;
}

.sidebar.collapsed .app-logo svg {
  width: 40px;
  height: 40px;
}

.sidebar.collapsed .sidebar-collapse-btn i {
  transform: rotate(180deg);
}

/* Adjust main content when sidebar collapsed */
.app-container.sidebar-collapsed .main-content {
  margin-left: 70px;
}

/* Hide collapse button on mobile */
@media (max-width: 900px) {
  .sidebar-collapse-btn {
    display: none !important;
  }
}
/* Ensure sidebar has relative positioning for collapse button */
.sidebar {
    position: relative;
}


/* Better Collapsed State Styles */
.sidebar.collapsed {
    padding: 15px 10px !important;
}

.sidebar.collapsed .app-logo {
    flex-direction: column;
    gap: 5px;
    margin-bottom: 15px;
}

.sidebar.collapsed .logo-text {
    display: none !important;
}

.sidebar.collapsed .nav-btn span {
    display: none !important;
}

.sidebar.collapsed .nav-btn {
    width: 48px;
    height: 48px;
    padding: 0 !important;
    border-radius: 12px !important;
    margin: 0 auto;
}

.sidebar.collapsed .nav-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.sidebar.collapsed .nav-item {
    width: 100%;
    display: flex;
    justify-content: center;
}

.sidebar.collapsed .sidebar-collapse-btn {
    position: static;
    margin: 0 auto 15px auto;
}


/* Smooth Sidebar Transitions */
.sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar .logo-text {
    transition: opacity 0.2s ease, width 0.3s ease;
}

.sidebar .nav-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar .nav-btn span {
    transition: opacity 0.2s ease, width 0.2s ease;
    white-space: nowrap;
}

.sidebar .nav-btn i {
    transition: margin 0.3s ease, font-size 0.2s ease;
}

.sidebar .app-logo {
    transition: all 0.3s ease;
}

.sidebar .app-logo svg {
    transition: width 0.3s ease, height 0.3s ease;
}

.main-content {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-collapse-btn i {
    transition: transform 0.3s ease;
}

/* Hover animation for collapsed buttons */
.sidebar.collapsed .nav-btn:hover {
    transform: scale(1.08);
}


/* --- Custom Tooltips --- */

/* Tooltip Container */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::before,
[data-tooltip]::after {
    position: absolute;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
}

/* Tooltip Text */
[data-tooltip]::after {
    content: attr(data-tooltip);
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #202124;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Tooltip Arrow */
[data-tooltip]::before {
    content: '';
    border: 6px solid transparent;
}

/* Default: Top Position */
[data-tooltip]::after {
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(5px);
}

[data-tooltip]::before {
    bottom: calc(100% + -2px);
    left: 50%;
    transform: translateX(-50%);
    border-top-color: #1a1a2e;
}

/* Show on Hover */
[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

[data-tooltip]:hover::after {
    transform: translateX(-50%) translateY(0);
}

/* Right Position */
[data-tooltip-pos='right']::after {
    bottom: auto;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(-5px);
}

[data-tooltip-pos='right']::before {
    bottom: auto;
    left: calc(100% + -2px);
    top: 50%;
    transform: translateY(-50%);
    border-top-color: transparent;
    border-right-color: #1a1a2e;
}

[data-tooltip-pos='right']:hover::after {
    transform: translateY(-50%) translateX(0);
}

/* Left Position */
[data-tooltip-pos='left']::after {
    bottom: auto;
    left: auto;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(5px);
}

[data-tooltip-pos='left']::before {
    bottom: auto;
    left: auto;
    right: calc(100% + -2px);
    top: 50%;
    transform: translateY(-50%);
    border-top-color: transparent;
    border-left-color: #1a1a2e;
}

[data-tooltip-pos='left']:hover::after {
    transform: translateY(-50%) translateX(0);
}

/* Accent Tooltip */
[data-tooltip-type='accent']::after {
    background: linear-gradient(135deg, var(--accent-color) 0%, #34A853 100%);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-tooltip-type='accent']::before {
    border-top-color: var(--accent-color);
}

