/**
 * Responsive fixes for comparison section
 * Ensures the comparison table is properly visible on mobile devices
 */

/* Make the comparison table responsive - ENHANCED VERSION */
.comparison-section {
  width: 100%;
  overflow-x: hidden !important; /* Prevent horizontal scrolling at the section level */
  position: relative !important; /* Required for absolute positioning of children */
  display: block !important;
  max-width: 100vw !important;
  margin: 0 !important;
  padding: 1rem !important;
  box-sizing: border-box !important;
}

/* Properly enable horizontal scrolling - ENHANCED FOR ALL MOBILE BROWSERS */
.comparison-table-wrapper {
  width: 100% !important; /* Use full width */
  max-width: 100% !important; /* Ensure it doesn't overflow the parent */
  overflow-x: auto !important; /* Force horizontal scrolling */
  overflow-y: visible !important;
  -webkit-overflow-scrolling: touch !important; /* Smooth scrolling on iOS */
  scrollbar-width: thin !important; /* Slimmer scrollbar on Firefox */
  position: relative !important; /* For positioning the gradient indicator */
  padding-bottom: 15px !important; /* Make room for scrollbar */
  display: block !important; /* Force display */
  touch-action: pan-x !important; /* Explicitly enable horizontal touch swiping */
  user-select: none !important; /* Prevent text selection interfering with scrolling */
}

/* Style the scrollbar - ENHANCED VERSION */
.comparison-table-wrapper::-webkit-scrollbar {
  height: 8px !important;
  width: 8px !important;
}

.comparison-table-wrapper::-webkit-scrollbar-track {
  background: #f1f1f1 !important;
  border-radius: 10px !important;
}

.comparison-table-wrapper::-webkit-scrollbar-thumb {
  background: #4F46E5 !important;
  border-radius: 10px !important;
}

.comparison-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #3730a3 !important;
}

/* Add visual feedback when dragging */
.comparison-table-wrapper.active {
  cursor: grabbing !important;
}

.comparison-table-wrapper {
  cursor: grab !important;
}

/* Add subtle scrolling indicator */
.comparison-table-wrapper::after {
  content: "→" !important;
  position: absolute !important;
  right: 10px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  font-size: 24px !important;
  color: #4F46E5 !important;
  opacity: 0.6 !important;
  pointer-events: none !important;
  animation: fade-pulse 2s infinite !important;
}

@keyframes fade-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.3; }
}

/* Ensure fixed width for columns - ENHANCED FOR CROSS-DEVICE COMPATIBILITY */
.comparison-table-wrapper table {
  width: 100% !important;
  min-width: 640px !important; /* Reduced minimum width for better compatibility */
  max-width: none !important; /* Remove any max-width constraints */
  table-layout: fixed !important; /* Fixed table layout for consistent column widths */
  border-collapse: collapse !important; /* Ensure consistent border handling */
  display: table !important; /* Force table display mode */
  margin: 0 !important; /* Remove any margin that might cause issues */
}

.comparison-table-wrapper table th,
.comparison-table-wrapper table td {
  width: 25% !important; /* 4 columns, equal width */
  min-width: 140px !important; /* Slightly reduced minimum width */
  white-space: normal !important; /* Allow text to wrap */
  word-wrap: break-word !important; /* Break long words */
  padding: 12px !important; /* Ensure sufficient padding */
  box-sizing: border-box !important; /* Ensure padding doesn't increase width */
}

/* Make first column sticky */
.comparison-table-wrapper table th:first-child,
.comparison-table-wrapper table td:first-child {
  position: sticky !important; /* Make first column sticky */
  left: 0 !important;
  z-index: 2 !important;
  background-color: inherit !important; /* Match the row background */
  box-shadow: 5px 0 8px rgba(0,0,0,0.1) !important;
}

/* Adjust backgrounds based on alternating rows */
.comparison-table-wrapper table tr:nth-child(odd) td:first-child {
  background-color: #ffffff !important;
}

.comparison-table-wrapper table tr:nth-child(even) td:first-child {
  background-color: #f9fafb !important;
}

/* Indicators and mobile-specific fixes - ENHANCED VERSION */
@media (max-width: 767px) {
  /* Force scrolling container to behave */
  .comparison-section {
    padding: 1rem 0 !important; /* Remove horizontal padding */
  }
  
  .comparison-table-wrapper {
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: scroll !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Highlight the scroll area with a border */
  .comparison-table-wrapper {
    border: 1px solid rgba(0,0,0,0.1) !important;
    border-radius: 8px !important;
  }
  
  /* Clear and prominent scroll instruction */
  .mobile-scroll-hint {
    display: block !important;
    text-align: center !important;
    font-size: 16px !important;
    color: #4F46E5 !important;
    padding: 10px !important;
    font-weight: 600 !important;
    margin: 0 0 15px 0 !important;
    background-color: #f0f4ff !important;
    border-radius: 8px !important;
    border: 1px dashed #4F46E5 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
  }
  
  /* Add animated arrows to draw attention to scrollability */
  .mobile-scroll-hint:before,
  .mobile-scroll-hint:after {
    content: "→" !important;
    display: inline-block !important;
    margin: 0 5px !important;
    animation: pulse-arrow 1s infinite !important;
  }
  
  .mobile-scroll-hint:before {
    content: "←" !important;
  }
  
  @keyframes pulse-arrow {
    0% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 0.7; }
  }
  
  /* Force first column to remain visible */
  .comparison-table-wrapper table th:first-child,
  .comparison-table-wrapper table td:first-child {
    position: sticky !important;
    left: 0 !important;
    z-index: 10 !important;
  }
  
  /* Make sure backgrounds are solid for sticky columns */
  .comparison-table-wrapper table thead th:first-child {
    background-color: #4F46E5 !important;
    box-shadow: 2px 0 5px rgba(0,0,0,0.2) !important;
  }
  
  /* Ensure column widths are mobile-friendly */
  .comparison-table-wrapper table th,
  .comparison-table-wrapper table td {
    min-width: 130px !important;
  }
  
  /* Force the scrollable area to be visible */
  .comparison-table-wrapper table {
    visibility: visible !important;
    display: table !important;
    margin: 0 !important;
    border: none !important;
  }
}
