/* Enhanced scrolling and animations for the werkbrief generator table */

.tableContainer {
  /* Enhanced custom scrollbar styling with better colors */
  scrollbar-width: thin;
  scrollbar-color: rgba(107, 114, 128, 0.4) rgba(249, 250, 251, 0.5);
  scroll-behavior: smooth;
  /* Prevent layout shifts during scroll */
  contain: layout;
}

.tableContainer::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.tableContainer::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 8px;
  margin: 2px;
  /* Create inset/sunken appearance */
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.08);
}

.tableContainer::-webkit-scrollbar-thumb {
  background: rgba(107, 114, 128, 0.3);
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  background-clip: padding-box;
  /* Very subtle shadow instead of bold gradient */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease-out;
}

.tableContainer::-webkit-scrollbar-thumb:hover {
  background: rgba(107, 114, 128, 0.4);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transform: none; /* Remove scale effect for subtlety */
}

.tableContainer::-webkit-scrollbar-thumb:active {
  background: rgba(107, 114, 128, 0.5);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
  transform: none;
}

.tableContainer::-webkit-scrollbar-corner {
  background: transparent;
  border-radius: 8px;
}

/* Optimized row animations - reduced transform effects to prevent shaking */
.tableRow {
  /* Simplified transition - only background and shadow for smoother scroll */
  transition: background-color 0.15s ease-out, box-shadow 0.15s ease-out;
  /* Removed transform properties that cause layout shifts */
  will-change: background-color, box-shadow;
  /* Improve rendering performance */
  contain: layout style;
}

.tableRow:hover {
  /* Removed transform to prevent table shaking during scroll */
  /* Only subtle shadow and background changes */
  background-color: rgba(59, 130, 246, 0.02) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Dark mode enhanced scrollbar */
@media (prefers-color-scheme: dark) {
  .tableContainer {
    scrollbar-color: rgba(156, 163, 175, 0.3) transparent;
  }

  .tableContainer::-webkit-scrollbar-track {
    background: transparent;
    /* Darker inset shadow for dark mode */
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.2);
  }

  .tableContainer::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.25);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  }

  .tableContainer::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.35);
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  }

  .tableContainer::-webkit-scrollbar-thumb:active {
    background: rgba(156, 163, 175, 0.4);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
  }

  .tableContainer::-webkit-scrollbar-corner {
    background: transparent;
  }
}

/* Optimized sticky header - prevents layout shifts */
.stickyHeader {
  backdrop-filter: blur(12px);
  background: rgba(249, 250, 251, 0.95);
  border-bottom: 1px solid rgba(229, 231, 235, 0.8);
  /* Improved positioning for smooth scroll */
  position: sticky;
  top: 0;
  z-index: 10;
  /* Prevent layout shifts */
  contain: layout style;
}

@media (prefers-color-scheme: dark) {
  .stickyHeader {
    background: rgba(17, 24, 39, 0.95);
    border-bottom: 1px solid rgba(75, 85, 99, 0.8);
  }
}

/* Loading animation for table */
@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.loadingShimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.2) 20%,
    rgba(255, 255, 255, 0.5) 60%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200px 100%;
  animation: shimmer 2s ease-in-out infinite;
}

/* Enhanced focus states - optimized for performance */
.focusInput:focus {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
  /* Removed transform to prevent layout shifts */
  outline: none;
  border-color: rgba(59, 130, 246, 0.5);
}

/* Optimized pagination buttons */
.paginationButton {
  transition: background-color 0.15s ease-out, box-shadow 0.15s ease-out;
  /* Prevent layout shifts by removing transform */
  will-change: background-color, box-shadow;
}

.paginationButton:hover {
  /* Only background and subtle shadow changes */
  background-color: rgba(59, 130, 246, 0.05);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Optimized search container */
.searchContainer {
  transition: box-shadow 0.2s ease-out;
  /* Prevent layout shifts by removing transform */
}

.searchContainer:focus-within {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* Optimized table expand/collapse - smoother animations */
.tableExpanded {
  animation: expandTable 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes expandTable {
  from {
    max-width: 1280px;
    opacity: 0.9;
  }
  to {
    max-width: none;
    opacity: 1;
  }
}

.tableCollapsed {
  animation: collapseTable 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes collapseTable {
  from {
    max-width: none;
    opacity: 0.9;
  }
  to {
    max-width: 1280px;
    opacity: 1;
  }
}

/* Enhanced scroll indicator */
.scrollIndicator {
  transition: all 0.2s ease-in-out;
  opacity: 0;
}

.tableContainer:hover .scrollIndicator {
  opacity: 1;
}

/* Optimized sort icon animations */
.sortIcon {
  transition: color 0.15s ease-out;
  /* Prevent layout shifts by removing scale transform */
}

.sortHeader:hover .sortIcon {
  color: rgba(59, 130, 246, 0.8);
}

/* Optimized action buttons with subtle ripple effect */
.actionButton {
  position: relative;
  overflow: hidden;
  transition: background-color 0.15s ease-out, box-shadow 0.15s ease-out;
  /* Prevent layout shifts */
  will-change: background-color, box-shadow;
}

.actionButton::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(
    circle,
    rgba(59, 130, 246, 0.1) 0%,
    transparent 70%
  );
  transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 0;
  pointer-events: none;
}

.actionButton:hover::before {
  width: 40px;
  height: 40px;
}

.actionButton:active::before {
  width: 60px;
  height: 60px;
  background: radial-gradient(
    circle,
    rgba(59, 130, 246, 0.15) 0%,
    transparent 70%
  );
}

/* Performance optimization for large tables */
.virtualizedRow {
  contain: layout style paint;
  will-change: transform;
  /* Optimized for smooth scrolling */
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Improved scroll performance */
.tableContainer {
  /* GPU acceleration for smooth scrolling */
  transform: translateZ(0);
  -webkit-overflow-scrolling: touch;
}

/* Prevent text selection during rapid scrolling */
.tableContainer.scrolling {
  user-select: none;
  -webkit-user-select: none;
}

/* Optimized mobile card animations */
@media (max-width: 768px) {
  .tableContainer {
    font-size: 0.875rem;
  }

  .mobileCard {
    background: white;
    border-radius: 12px;
    margin: 8px 0;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.15s ease-out, background-color 0.15s ease-out;
    /* Prevent layout shifts on mobile */
    will-change: box-shadow, background-color;
  }

  .mobileCard:hover {
    /* Only subtle shadow changes on mobile */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    background-color: rgba(59, 130, 246, 0.02);
  }
}

/* Accessibility enhancements - optimized focus states */
.accessibleFocus:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.6);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Enhanced scroll indicators with smooth transitions */
.scrollIndicator {
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
  opacity: 0;
  /* Prevent layout shifts */
  will-change: opacity, transform;
}

.tableContainer:hover .scrollIndicator {
  opacity: 0.8;
}

.scrollIndicator:hover {
  opacity: 1;
  transform: scaleX(1.2);
}

/* Prevent table row jumping during hover */
.tableRow td {
  /* Ensure consistent cell heights */
  vertical-align: middle;
  /* Prevent content shifts */
  overflow-wrap: break-word;
}

/* Stable sticky column positioning */
.tableRow td.sticky {
  position: sticky;
  /* Prevent z-index stacking issues */
  z-index: 1;
}

/* Enhanced scrolling physics for better UX */
.tableContainer {
  /* Momentum scrolling on iOS */
  -webkit-overflow-scrolling: touch;
  /* Smooth scrolling behavior */
  scroll-behavior: smooth;
  /* Better scroll snapping */
  scroll-padding: 1rem;
  /* GPU acceleration for smooth scrolling */
  transform: translateZ(0);
  /* Additional optimizations */
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .tableContainer {
    scroll-behavior: auto;
  }

  .tableRow,
  .actionButton,
  .paginationButton,
  .focusInput,
  .searchContainer,
  .scrollIndicator {
    transition: none;
  }

  .tableExpanded,
  .tableCollapsed {
    animation: none;
  }

  .loadingShimmer {
    animation: none;
    background: rgba(156, 163, 175, 0.2);
  }

  .tableContainer::-webkit-scrollbar-thumb {
    transition: none;
  }

  .tableContainer::-webkit-scrollbar-thumb:hover {
    transform: none;
  }
}

/* Additional optimizations for smooth scrolling */
.tableContainer * {
  /* Prevent unnecessary repaints during scroll */
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Optimize loading shimmer for dark mode */
@media (prefers-color-scheme: dark) {
  .loadingShimmer {
    background: linear-gradient(
      90deg,
      rgba(55, 65, 81, 0) 0%,
      rgba(55, 65, 81, 0.2) 20%,
      rgba(55, 65, 81, 0.4) 60%,
      rgba(55, 65, 81, 0) 100%
    );
  }
}
