/* PDF Helper Custom Styles */

/* CSS Variables for Theming */
:root {
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  --card-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  --card-shadow-hover: 0 20px 60px rgba(0, 0, 0, 0.15);
  --border-radius-lg: 16px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* General */
body {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Navbar */
.navbar {
  background: var(--primary-gradient) !important;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  backdrop-filter: blur(10px);
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-brand::before {
  content: '📄';
  font-size: 1.2rem;
}

.nav-link {
  font-weight: 500;
  padding: 0.5rem 1rem !important;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-smooth);
  margin: 0 2px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.15);
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.2);
}

/* Login Page */
.card {
  border: none;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(20px);
  background: rgba(255, 255, 255, 0.95);
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary-gradient);
}

.card-header {
  font-weight: 600;
  background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
}

.card-header.bg-secondary {
  background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%) !important;
  color: white;
  padding: 0.5rem 0.875rem;
}

.card-body {
  padding: 1rem;
}

/* Compact sidebar cards */
.col-md-3 .card,
.col-lg-2 .card {
  margin-bottom: 0.5rem !important;
}

.col-md-3 .card-body,
.col-lg-2 .card-body {
  padding: 0.625rem;
}

.col-md-3 .card-header,
.col-lg-2 .card-header {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.col-md-3 .d-grid.gap-2,
.col-lg-2 .d-grid.gap-2 {
  gap: 0.35rem !important;
}

.col-md-3 .btn-sm,
.col-lg-2 .btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

/* Form Controls */
.form-control {
  border-radius: var(--border-radius-sm);
  border: 2px solid #e2e8f0;
  padding: 0.75rem 1rem;
  transition: var(--transition-smooth);
  font-size: 0.95rem;
}

.form-control:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

.form-label {
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  transition: var(--transition-smooth);
  border: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(255,255,255,0.2), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn:hover::after {
  opacity: 1;
}

.btn-primary {
  background: var(--primary-gradient);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-success {
  background: var(--success-gradient);
  box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(17, 153, 142, 0.5);
}

.btn-outline-primary {
  border: 2px solid #667eea;
  color: #667eea;
  background: transparent;
}

.btn-outline-primary:hover {
  background: var(--primary-gradient);
  border-color: transparent;
  color: white;
  transform: translateY(-2px);
}

.btn-outline-secondary {
  border: 2px solid #718096;
  color: #718096;
}

.btn-outline-secondary:hover {
  background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
  border-color: transparent;
  color: white;
}

.btn-outline-danger {
  border: 2px solid #e53e3e;
  color: #e53e3e;
}

.btn-outline-danger:hover {
  background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
  border-color: transparent;
  color: white;
}

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.875rem;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed #cbd5e0;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-smooth);
  cursor: pointer;
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  position: relative;
  overflow: hidden;
  padding: 0.75rem !important;
}

.drop-zone i.fs-1 {
  font-size: 1.5rem !important;
}

.drop-zone p {
  margin-bottom: 0.25rem !important;
  font-size: 0.85rem;
}

.drop-zone small {
  font-size: 0.75rem;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--primary-gradient);
  opacity: 0;
  transition: opacity 0.3s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: #667eea;
  transform: scale(1.02);
}

.drop-zone:hover::before,
.drop-zone.drag-over::before {
  opacity: 0.05;
}

.drop-zone i {
  transition: var(--transition-smooth);
  position: relative;
  z-index: 1;
}

.drop-zone:hover i,
.drop-zone.drag-over i {
  transform: scale(1.2) translateY(-5px);
  color: #667eea !important;
}

.drop-zone p, .drop-zone small {
  position: relative;
  z-index: 1;
}

/* Pages Grid */
.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
  padding: 20px;
}

/* Page Thumbnail */
.page-thumbnail {
  position: relative;
  aspect-ratio: 8.5 / 11;
  border: 3px solid #e2e8f0;
  border-radius: var(--border-radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition-smooth);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.page-thumbnail::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--primary-gradient);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 1;
  pointer-events: none;
}

.page-thumbnail:hover {
  border-color: #667eea;
  box-shadow: 0 12px 30px rgba(102, 126, 234, 0.25);
  transform: translateY(-5px) scale(1.02);
}

.page-thumbnail:hover::before {
  opacity: 0.05;
}

.page-thumbnail.selected {
  border-color: #667eea;
  border-width: 3px;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.3), 0 12px 30px rgba(102, 126, 234, 0.25);
}

.page-thumbnail.selected::before {
  opacity: 0.08;
}

.page-thumbnail img, .page-thumbnail canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 0;
}

.page-thumbnail .page-number {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.6) 100%);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  z-index: 2;
  backdrop-filter: blur(4px);
}

.page-thumbnail .page-check {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--primary-gradient);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  z-index: 2;
  box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

.page-thumbnail.selected .page-check {
  display: flex;
}

.page-thumbnail .page-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  z-index: 3;
}

/* Sortable Ghost */
.sortable-ghost {
  opacity: 0.4;
  transform: scale(0.95);
}

.sortable-chosen {
  box-shadow: 0 20px 40px rgba(102, 126, 234, 0.3);
}

/* Stamps List */
.stamps-list {
  max-height: 120px;
  overflow-y: auto;
}

.stamp-item {
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  transition: var(--transition-smooth);
  border-radius: var(--border-radius-sm);
  margin-bottom: 5px;
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  font-size: 0.85rem;
}

.stamp-item:hover {
  background: linear-gradient(135deg, #edf2f7 0%, #e2e8f0 100%);
  transform: translateX(3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stamp-item:last-child {
  margin-bottom: 0;
}

/* Stamp Placement Modal */
.stamp-placement-area {
  max-height: 70vh;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 30px;
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  border-radius: var(--border-radius-md);
  border: 2px solid #e2e8f0;
}

/* Page Preview Modal */
.page-preview-area {
  max-height: 70vh;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  border-radius: var(--border-radius-md);
  border: 2px solid #e2e8f0;
}

#previewCanvas {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  max-width: 100%;
}

/* View button on thumbnails */
.page-thumbnail .page-view-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--primary-gradient);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  z-index: 2;
  box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
  opacity: 0;
  transition: var(--transition-smooth);
  cursor: pointer;
  border: none;
}

.page-thumbnail:hover .page-view-btn {
  opacity: 1;
}

.page-thumbnail .page-view-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 6px 15px rgba(102, 126, 234, 0.5);
}

#stampCanvas, #textCanvas {
  cursor: crosshair;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

#redactionCanvas {
  cursor: crosshair;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  user-select: none;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay .spinner-border {
  width: 3rem;
  height: 3rem;
  border-width: 4px;
}

/* Toast Styling */
.toast {
  min-width: 280px;
  border-radius: var(--border-radius-md);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  border: none;
  overflow: hidden;
}

.toast-header {
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  border-bottom: 1px solid #e2e8f0;
}

/* Table */
.table {
  border-radius: var(--border-radius-md);
  overflow: hidden;
}

.table th {
  font-weight: 700;
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  border-bottom: 2px solid #e2e8f0;
  color: #4a5568;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  padding: 1rem;
}

.table td {
  padding: 1rem;
  vertical-align: middle;
  border-color: #edf2f7;
}

.table-hover tbody tr:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

/* Badges */
.badge {
  font-weight: 600;
  padding: 0.5em 1em;
  border-radius: 20px;
}

.badge.bg-primary {
  background: var(--primary-gradient) !important;
}

/* Modals */
.modal-content {
  border: none;
  border-radius: var(--border-radius-lg);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.modal-header {
  background: linear-gradient(135deg, #f7fafc 0%, #ffffff 100%);
  border-bottom: 1px solid #e2e8f0;
  padding: 1.25rem 1.5rem;
}

.modal-title {
  font-weight: 700;
  color: #2d3748;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  background: linear-gradient(0deg, #f7fafc 0%, #ffffff 100%);
  border-top: 1px solid #e2e8f0;
  padding: 1rem 1.5rem;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #a0aec0 0%, #718096 100%);
  border-radius: 5px;
  border: 2px solid #f1f5f9;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #718096 0%, #4a5568 100%);
}

/* User Dropdown */
.dropdown-menu {
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
  border: none;
  border-radius: var(--border-radius-md);
  padding: 0.5rem;
  overflow: hidden;
}

.dropdown-item {
  border-radius: var(--border-radius-sm);
  padding: 0.6rem 1rem;
  transition: var(--transition-smooth);
  font-weight: 500;
}

.dropdown-item:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.dropdown-divider {
  margin: 0.5rem 0;
  border-color: #e2e8f0;
}

/* Stamp Preview */
.stamp-preview-text {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

/* Alert Animation */
.alert {
  border: none;
  border-radius: var(--border-radius-md);
  animation: slideInDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

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

/* Empty State */
#emptyState {
  color: #718096;
  padding: 60px 20px;
}

#emptyState i {
  opacity: 0.3;
  transition: var(--transition-smooth);
}

#emptyState:hover i {
  opacity: 0.5;
  transform: scale(1.1);
}

#emptyState h5 {
  font-weight: 600;
  margin-top: 1.5rem;
}

#emptyState p {
  font-size: 0.95rem;
}

/* Current File Name Display */
#currentFileName {
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  border-radius: var(--border-radius-sm);
  border-left: 3px solid #667eea;
}

/* Card hover effects */
.card.shadow-sm {
  transition: var(--transition-smooth);
}

.card.shadow-sm:hover {
  box-shadow: var(--card-shadow-hover);
}

/* Library List */
.list-group-item {
  border: none;
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem 1.25rem;
  transition: var(--transition-smooth);
}

.list-group-item:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

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

/* Responsive Adjustments */
@media (max-width: 768px) {
  .pages-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    padding: 12px;
  }

  .page-thumbnail .page-number {
    font-size: 10px;
    padding: 3px 8px;
  }

  .page-thumbnail .page-check {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }

  .navbar-brand {
    font-size: 1.2rem;
  }

  .card-body {
    padding: 1rem;
  }
}

/* Print styles */
@media print {
  .navbar, .card-header, .btn {
    display: none !important;
  }
}

/* Focus states for accessibility */
.btn:focus-visible,
.form-control:focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.5);
  outline-offset: 2px;
}

/* Smooth page transitions */
.page-thumbnail,
.card,
.btn,
.stamp-item {
  will-change: transform;
}
