/* Design System Tokens - Import first */
@import url('/static/shared_css/tokens.css');

/* Import overview content styles for table formatting */
@import url('/static/css/overview-content.css');

/* Root font size to normalize scaling across browsers */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Universal box-sizing reset for consistency */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  overflow: hidden;
  background: var(--color-gray-25) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Global scrollbar styling */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--color-gray-50);
  border-left: var(--border-1) solid var(--color-gray-200);
}

::-webkit-scrollbar-thumb {
  background: var(--color-gray-200);
  border-radius: var(--radius-md);
  border: 2px solid var(--color-gray-50);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-gray-300);
}

/* Firefox scrollbar support */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-gray-200) var(--color-gray-50);
}

/* Main Content Wrapper - scrollable area with scrollbar extending to top */
.main-content-wrapper {
  position: fixed;
  top: 0; /* Start at top so scrollbar goes to top */
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 110px; /* Push content down instead */
}

/* Top Bar Styles */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-xs);
  z-index: var(--z-toast);
  border-bottom: var(--border-1) solid rgba(0, 0, 0, 0.08);
}

.header-main {
  height: var(--header-height);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  width: 100%;
  box-sizing: border-box;
  position: relative;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-shrink: 0;
}

.site-logo {
  height: 36px;
  width: 40px;
  max-height: 36px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  cursor: pointer;
  transition: var(--transition-slow);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.2));
}

.site-logo:hover {
  opacity: 0.8;
  transform: scale(1.02);
}

.site-name-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.site-name {
  color: var(--color-white);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-tight);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition-slow);
  font-feature-settings: 'kern' 1;
  line-height: var(--leading-none);
}

.site-beta {
  color: rgba(255, 255, 255, 0.8);
  font-size: var(--text-2xs);
  font-weight: var(--font-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: var(--transition-slow);
  line-height: var(--leading-none);
  margin-top: -2px;
}

.site-name-container:hover .site-name {
  opacity: 0.85;
  transform: translateY(-0.5px);
}

.site-name-container:hover .site-beta {
  opacity: 1;
  transform: translateY(-0.5px);
}

.header-right {
  /* Reserved for future features like search, user menu */
  flex-shrink: 0;
}

.nav-tabs {
  display: flex;
  background: rgba(248, 248, 248, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: var(--border-1) solid rgba(0, 0, 0, 0.06);
  padding: 0 var(--space-6);
  gap: var(--space-2);
  height: var(--nav-height);
  align-items: center;
  overflow: hidden;
}

.nav-tab {
  background: transparent;
  border: none;
  padding: var(--space-2) var(--space-5);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-gray-800);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: var(--transition-normal);
  position: relative;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  min-height: 28px;
  display: flex;
  align-items: center;
  font-feature-settings: 'kern' 1;
}

.nav-tab:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--color-gray-900);
  transform: translateY(-1px);
}

.nav-tab.active {
  background: var(--gradient-primary);
  color: var(--color-white);
  font-weight: var(--font-semibold);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  box-shadow: var(--shadow-primary);
  border: var(--border-1) solid rgba(102, 126, 234, 0.2);
}


/* Main graph SVG only */
body > .main-content-wrapper svg:not(button svg):not(.button svg) {
  width: 100%;
  height: calc(100vh - 110px); /* Account for top bar height */
  background: var(--color-gray-25);
  margin-top: -110px; /* Extend fully under top bar */
  padding-top: 110px; /* Add padding to keep content below top bar */
  min-height: 500px; /* Ensure minimum height so footer doesn't overlap */
}

/* Basic SVG icon styles for buttons */
button svg,
.button svg {
  display: inline-block;
  vertical-align: middle;
  pointer-events: none;
  fill: currentColor;
  stroke: currentColor;
  flex-shrink: 0;
}

/* Mobile responsive SVG - works for both actual mobile and narrow desktop windows */
@media (max-width: 768px) {
  body > .main-content-wrapper svg:not(button svg):not(.button svg) {
    height: calc(100vh - 110px); /* Full height minus top bar */
    margin-top: -110px; /* Extend fully under top bar */
    padding-top: 110px; /* Add padding to keep content below top bar */
    min-height: 400px; /* Smaller minimum height on mobile */
  }
  
  /* When tables are visible on mobile, reduce SVG height to make room */
  .reaction-tables.visible ~ svg:not(button svg):not(.button svg) {
    height: 60vh; /* Reduced height when tables are shown below */
    margin-top: -110px; /* Maintain full extension under top bar */
    padding-top: 110px; /* Maintain padding for content */
    min-height: 300px;
  }
  
  /* Make graph canvas taller on mobile for better viewing */
  body > .main-content-wrapper svg:not(button svg):not(.button svg) {
    height: calc(100vh - 60px) !important; /* Taller canvas - just leave space for breadcrumb */
    min-height: 500px !important; /* Ensure good minimum height */
  }
  
}

/* Mobile layout styles - for CSS media query */
@media (max-width: 768px) {
  /* Mobile responsive reaction tables - stack below graph */
  .reaction-tables.visible {
    position: static; /* Change from absolute to static on mobile */
    display: block !important; /* Only show when visible */
    padding: 15px 10px; /* Reduced padding for better centering */
    background: var(--color-gray-25);
    border-top: 1px solid var(--color-gray-150);
    margin-top: 0;
    flex-direction: column;
    align-items: center; /* Center the tables */
  }
  
  .reaction-tables.visible .reaction-table-container {
    position: static !important; /* Remove absolute positioning */
    width: calc(100% - 20px) !important; /* Full width with small margins */
    max-width: 425px !important; /* Maximum width reduced to 85% */
    height: auto !important; /* Auto height instead of fixed */
    max-height: 400px; /* Limit height for scrolling */
    margin: 0 auto 15px auto !important; /* Center tables with auto margins */
    left: auto !important;
    right: auto !important;
    top: auto !important;
  }
  
  /* Ensure FROM table comes first, then TO table */
  .reaction-tables.visible .reaction-table-container.left {
    order: 1; /* FROM reactions first */
  }
  
  .reaction-tables.visible .reaction-table-container.right {
    order: 2; /* TO reactions second */
    margin-bottom: 0 !important; /* No margin on last table */
  }
  
  .reaction-tables.visible .reaction-table-title {
    font-size: 13.6px; /* Reduced to 85% of 16px */
    padding: 16px 16px 12px 16px;
  }
  
  .reaction-tables.visible .reaction-table {
    font-size: 10.2px; /* Reduced to 85% of 12px */
  }
  
  .reaction-tables.visible .reaction-table th {
    padding: 10px 6px; /* Reduced padding on mobile */
    font-size: 9.35px;
  }
  
  .reaction-tables.visible .reaction-table td {
    padding: 10px 6px; /* Reduced padding on mobile */
  }
  
  .reaction-tables.visible .reagent-cell {
    max-width: 70px; /* Smaller max width on mobile */
  }
  
  .reaction-tables.visible .mechanism-cell {
    max-width: 60px; /* Smaller max width on mobile */
  }
}

/* JavaScript-controlled mobile layout - for desktop browser resizing */
.reaction-tables.mobile-layout.visible {
  position: static; 
  display: block !important; 
  padding: 15px 10px; 
  background: var(--color-gray-25);
  border-top: 1px solid var(--color-gray-150);
  margin-top: 0;
  flex-direction: column;
  align-items: center;
}


.reaction-tables.mobile-layout.visible .reaction-table-container {
  position: static !important;
  width: calc(100% - 20px) !important;
  max-width: 500px !important;
  height: auto !important;
  max-height: 400px;
  margin: 0 auto 15px auto !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
}

.reaction-tables.mobile-layout.visible .reaction-table-container.left {
  order: 1;
}

.reaction-tables.mobile-layout.visible .reaction-table-container.right {
  order: 2;
  margin-bottom: 0 !important;
}

.reaction-tables.mobile-layout.visible .reaction-table-title {
  font-size: 16px;
  padding: 16px 16px 12px 16px;
}

.reaction-tables.mobile-layout.visible .reaction-table {
  font-size: 12px;
}

.reaction-tables.mobile-layout.visible .reaction-table th {
  padding: 10px 6px;
  font-size: 11px;
}

.reaction-tables.mobile-layout.visible .reaction-table td {
  padding: 10px 6px;
}

.reaction-tables.mobile-layout.visible .reagent-cell {
  max-width: 70px;
}

.reaction-tables.mobile-layout.visible .mechanism-cell {
  max-width: 60px;
}

/* SVG height adjustment for JavaScript-controlled mobile layout */
.reaction-tables.mobile-layout.visible ~ svg:not(button svg):not(.button svg) {
  height: 60vh !important; /* Reduced height when tables are shown below */
  margin-top: -110px !important; /* Maintain full extension under top bar */
  padding-top: 110px !important; /* Maintain padding for content */
  min-height: 300px !important;
}

/* JavaScript-controlled mobile layout for content sections */
.reaction-tables.mobile-layout.visible ~ .functional-group-overview-section {
  margin: 20px auto;
  padding: 0 10px;
  max-width: calc(100% - 20px);
}

.reaction-tables.mobile-layout.visible ~ .functional-group-overview-section .overview-header {
  padding: 20px 16px 16px 16px;
}

.reaction-tables.mobile-layout.visible ~ .functional-group-overview-section .overview-content {
  padding: 20px 16px;
}

.reaction-tables.mobile-layout.visible ~ .related-reactions-section,
.reaction-tables.mobile-layout.visible ~ * .related-reactions-section {
  margin: 20px 10px;
  padding: 20px 15px;
  max-width: calc(100% - 20px);
}

.reaction-tables.mobile-layout.visible ~ .related-reactions-section .related-reactions-grid,
.reaction-tables.mobile-layout.visible ~ * .related-reactions-section .related-reactions-grid {
  grid-template-columns: 1fr;
}

.reaction-tables.mobile-layout.visible ~ .related-reactions-section .related-category,
.reaction-tables.mobile-layout.visible ~ * .related-reactions-section .related-category {
  margin: 0 auto;
  max-width: 100%;
}

.reaction-tables.mobile-layout.visible ~ .related-reactions-section .related-reaction-link,
.reaction-tables.mobile-layout.visible ~ * .related-reactions-section .related-reaction-link {
  margin: 0 auto 8px auto;
  max-width: 100%;
}

.link { stroke: #999; stroke-opacity: 0.6; }
.node { fill: #69b3a2; stroke: #333; stroke-width: 1.5px; }
text { font-size: 10px; pointer-events: none; }

/* Menu Styles */
.control-menu {
  position: absolute;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: var(--border-1) solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 175px);
  overflow-y: auto;
  z-index: var(--z-modal);
  min-width: 200px;
  max-width: 280px;
  display: none;
}

.control-menu.visible {
  display: block;
}

/* Styled scrollbar for control menu */
.control-menu::-webkit-scrollbar {
  width: 6px;
}

.control-menu::-webkit-scrollbar-track {
  background: transparent;
}

.control-menu::-webkit-scrollbar-thumb {
  background: rgba(102, 126, 234, 0.3);
  border-radius: var(--radius-sm);
}

.control-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.5);
}

.menu-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-3);
  text-align: center;
  border-bottom: var(--border-1) solid rgba(0, 0, 0, 0.1);
  padding-bottom: var(--space-2-5);
  color: var(--color-gray-800);
  letter-spacing: var(--tracking-tight);
  font-feature-settings: 'kern' 1;
}

.checkbox-item {
  display: flex;
  align-items: center;
  margin: 8px 0;
  font-size: 12px;
}

.checkbox-item input[type="checkbox"] {
  margin-right: 8px;
  transform: scale(1.1);
}

.checkbox-item label {
  cursor: pointer;
  flex: 1;
}

.menu-buttons {
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid var(--color-gray-300);
}

.menu-button {
  width: 100%;
  padding: 8px 12px;
  margin: 6px 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(248, 248, 248, 0.8);
  cursor: pointer;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  color: #1d1d1f;
  font-feature-settings: 'kern' 1;
}

.menu-button:hover {
  background: var(--color-white);
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 1px 3px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

/* Reaction Tables Styles */
.reaction-tables {
  position: absolute; /* Changed from fixed to absolute */
  top: 120px; /* Right after top bar (110px) + small margin - PERFECT! */
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  pointer-events: none;
  z-index: 500;
  padding: 20px; /* Add padding to create margins from screen edges */
}

.reaction-tables.visible {
  display: flex;
}

.reaction-table-container {
  width: 297.5px; /* Reduced to 85% of original 350px */
  height: calc(100vh - 120px); /* Adjusted for top padding */
  background: rgba(255, 255, 255, 0.98);
  border: none; /* Remove old border */
  border-radius: 16px; /* Rounded corners */
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0, 0, 0, 0.08); /* Modern shadow */
  overflow: hidden; /* Hide overflow for rounded corners */
  pointer-events: auto;
  backdrop-filter: blur(10px); /* Subtle blur effect */
  transition: all 0.3s ease;
}

.reaction-table-container:hover {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 6px 24px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.reaction-table-container.left {
  position: absolute;
  left: 20px; /* Margin from left edge */
  top: 0;
}

.reaction-table-container.right {
  position: absolute;
  right: 20px; /* Margin from right edge */
  top: 0;
}

.reaction-table-title {
  font-size: 15.3px;
  font-weight: 600;
  margin: 0;
  padding: 20px 20px 16px 20px;
  text-align: center;
  color: var(--color-gray-800);
  background: linear-gradient(135deg, var(--color-gray-50) 0%, var(--color-gray-150) 100%);
  border-bottom: 1px solid var(--color-gray-150);
  letter-spacing: 0.5px;
  /* Single line title styling */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.reaction-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11.05px;
  margin: 0;
  background: var(--color-white);
}

.reaction-table th {
  background: var(--gradient-primary);
  color: var(--color-white);
  border: none;
  padding: 12px 8px;
  text-align: left;
  font-weight: 600;
  font-size: 10.2px;
  letter-spacing: 0.3px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.reaction-table th:first-child {
  border-top-left-radius: 0;
}

.reaction-table th:last-child {
  border-top-right-radius: 0;
}

.reaction-table td {
  border: none;
  border-bottom: 1px solid #f1f3f4;
  padding: 12px 8px;
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.4;
}

.reaction-table tr:nth-child(even) {
  background: #fbfcfd;
}

.reaction-table tr:hover {
  background: #f0f8ff;
  transition: background-color 0.2s ease;
}

/* Clickable table row styles */
.clickable-row.has-details {
  position: relative;
  transition: all 0.3s ease;
  cursor: pointer;
}

.clickable-row.has-details:hover {
  background: linear-gradient(135deg, #f0f8ff 0%, #e6f7ff 100%) !important;
  box-shadow: inset 0 0 0 2px rgba(102, 126, 234, 0.3);
  transition: all 0.3s ease;
  transform: translateX(2px);
}

.reagent-cell {
  max-width: 90px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  font-weight: 500;
}

.mechanism-cell {
  max-width: 80px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  font-style: italic;
  color: var(--color-gray-500);
}

.notes-cell {
  max-width: 85px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  font-size: 11px;
  color: var(--color-gray-500);
  line-height: 1.3;
}

.from-to-cell {
  font-weight: 600;
  color: var(--color-primary);
  max-width: 85px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.functional-group-name {
  display: inline-block;
  font-size: 13px;
  line-height: 1.3;
  letter-spacing: 0.3px;
  text-transform: none;
  font-weight: 600;
  color: var(--color-gray-800);
  padding: 2px 0;
  transition: all 0.2s ease;
  max-width: 100%;
  text-align: left;
  width: 100%;
}

.functional-group-name:hover {
  color: #000;
}

.reagent-name {
  display: inline-block;
  font-size: 13px;
  line-height: 1.3;
  letter-spacing: 0.2px;
  text-transform: none;
  font-weight: 500;
  color: var(--color-gray-800);
  padding: 2px 0;
  transition: all 0.2s ease;
  max-width: 100%;
  text-align: left;
  width: 100%;
}

.reagent-name:hover {
  color: #000;
}

/* Add scrollable content area */
.reaction-table-container {
  display: flex;
  flex-direction: column;
}

.table-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.table-content::-webkit-scrollbar {
  width: 6px;
}

.table-content::-webkit-scrollbar-track {
  background: transparent;
}

.table-content::-webkit-scrollbar-thumb {
  background: rgba(102, 126, 234, 0.3);
  border-radius: 3px;
}

.table-content::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.5);
}

/* Node hover effects for reaction tables */
.reaction-tables.node-hover-active {
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reaction-table tr.dimmed {
  opacity: 0.5;
  background: var(--color-gray-50) !important;
  color: #adb5bd;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform: scale(0.98);
}

.reaction-table tr.highlighted {
  opacity: 1;
  background: linear-gradient(135deg, #e3f2fd 0%, #f0f8ff 100%) !important;
  color: #1565c0;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
  border-left: 4px solid var(--color-primary);
  transform: scale(1.02);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
  position: relative;
}

.reaction-table tr.highlighted .from-to-cell {
  color: #1565c0;
  font-weight: 700;
}

.reaction-table tr.highlighted .reagent-cell {
  font-weight: 600;
  color: #2e7d32;
}

/* Pulse animation for detail indicators */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Enhanced hover state when tables are in node-hover mode */
.reaction-tables.node-hover-active .reaction-table-container {
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.15);
  border: 2px solid rgba(102, 126, 234, 0.1);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reaction-tables.node-hover-active .reaction-table-title {
  background: var(--gradient-primary);
  color: var(--color-white);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure highlighted rows remain clickable */
.reaction-table tr.highlighted.clickable-row.has-details:hover {
  background: linear-gradient(135deg, #bbdefb 0%, #e1f5fe 100%) !important;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
  transform: scale(1.03) translateX(3px);
}

/* Functional Group Title Styles */
.functional-group-title {
  position: absolute;
  top: 120px; /* SAME AS FILTER BUTTON - STAY ON PAGE! */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #1d1d1f;
  font-size: 40.8px;
  font-weight: 700;
  padding: 20.4px 40.8px;
  border-radius: 20px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 4px 16px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.08);
  z-index: 1050;
  text-align: center;
  letter-spacing: -1px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  max-width: 80vw;
  word-wrap: break-word;
  font-feature-settings: 'kern' 1;
}

.functional-group-title.visible {
  opacity: 1;
  visibility: visible;
}

/* Reaction Detail Page Styles */
.reaction-detail-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: var(--color-white);
  z-index: 1050;
  overflow-y: auto;
  display: none;
  /* Add top padding to account for fixed header */
  padding-top: 114px; /* Header height (~104px) + some buffer */
  box-sizing: border-box;
}

.reaction-detail-container.visible {
  display: block;
}

.reaction-detail-container.loading {
  display: block;
}

.reaction-detail-container.loading .reaction-detail-content {
  visibility: hidden;
  pointer-events: none;
}

.reaction-detail-container.loading::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-gray-200);
  border-top: 3px solid var(--color-info);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 1051;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.reaction-detail-content {
  padding: 20px 40px 60px;
  max-width: 1200px;
  margin: 0 auto;
  background: var(--color-white);
}

.reaction-detail-content.simple {
  max-width: 800px;
}

.reaction-detail-header {
  text-align: center;
  margin-bottom: 40px;
  position: relative;
}

.reaction-title {
  font-size: 36px;
  color: var(--color-gray-800);
  margin: 10px 0;
  font-weight: 700;
}

.reaction-title-block {
  max-width: 780px;
  margin: 0 auto;
}

.reaction-subtitle {
  font-size: 18px;
  color: var(--color-gray-500);
  font-style: italic;
}

/* Simple Overview Styles */
.simple-overview {
  background: #f9f9f9;
  border-radius: 12px;
  padding: 40px;
  margin: 40px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  text-align: center;
}

.simple-overview p {
  font-size: 18px;
  line-height: 1.8;
  color: #555;
  margin: 0;
  max-width: 600px;
  margin: 0 auto;
}

.detail-section {
  margin: 40px 0;
  background: #f9f9f9;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.detail-section h2 {
  color: var(--color-gray-800);
  font-size: 28px;
  margin-bottom: 20px;
  border-bottom: 3px solid;
  border-image: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%) 1;
  padding-bottom: 10px;
}

.detail-section h3 {
  color: #444;
  font-size: 20px;
  margin: 20px 0 10px;
}

.overview-section h2 {
  margin-bottom: 25px;
  color: var(--color-gray-600);
  font-weight: 600;
}

.overview-section p {
  font-size: 16px;
  line-height: 1.6;
  color: #555;
}

/* Mechanism Section */
.mechanism-content {
  display: grid;
  gap: 20px;
}

.mechanism-info h3 {
  color: var(--color-primary);
  font-size: 22px;
}

.mechanism-image img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.mechanism-video iframe {
  width: 100%;
  height: 400px;
  border-radius: 8px;
}

/* Examples Section */
.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.example-card {
  background: var(--color-white);
  border: 1px solid var(--color-gray-300);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.example-card h4 {
  margin: 0 0 15px 0;
  color: var(--color-gray-800);
  font-size: 16px;
  border-bottom: 1px solid var(--color-gray-150);
  padding-bottom: 8px;
}

.example-content {
  display: grid;
  gap: 10px;
}

.example-equation,
.example-conditions,
.example-yield,
.example-notes {
  font-size: 14px;
  line-height: 1.5;
}

.example-equation strong,
.example-conditions strong,
.example-yield strong,
.example-notes strong {
  color: var(--color-gray-700);
  font-weight: 600;
}

.no-examples-notice {
  background: var(--color-gray-50);
  border: 1px solid var(--color-gray-300);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.no-examples-notice p {
  margin: 0;
  color: var(--color-gray-500);
  font-style: italic;
}

/* Related Links */
.related-link {
  color: var(--color-info);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease;
}

.related-link:hover {
  border-bottom-color: var(--color-info);
}

/* Related Reaction Links */
.related-reaction-link {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.3;
  border-radius: 3px;
  transition: background-color 0.2s ease;
}

.related-reaction-link:hover {
  background-color: rgba(52, 152, 219, 0.1);
  padding: 4px 6px;
}

.from-fg {
  color: var(--color-gray-800);
  font-weight: 600;
  flex-shrink: 0;
}

.reaction-arrow {
  color: var(--color-info);
  font-weight: 500;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  flex-shrink: 0;
}

.to-fg {
  color: #8e44ad;
  font-weight: 600;
  flex-shrink: 0;
}

/* Navigation Helper */
.related-link:hover {
  text-decoration: underline;
}

/* Considerations Section */
.considerations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.consideration-card {
  background: var(--color-white);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.consideration-card h3 {
  color: var(--color-primary);
  font-size: 18px;
  margin-bottom: 10px;
}

.temp-range {
  font-size: 20px;
  font-weight: bold;
  color: var(--color-error);
  margin-bottom: 10px;
}

.substitution-effect {
  margin: 8px 0;
  padding: 8px;
  background: #f0f8ff;
  border-radius: 4px;
}

.side-products {
  background: var(--color-white);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.side-products h3 {
  color: var(--color-error);
  font-size: 18px;
  margin-bottom: 15px;
}

.side-products ul {
  list-style-type: none;
  padding: 0;
}

.side-products li {
  background: #ffeaea;
  margin: 8px 0;
  padding: 10px;
  border-radius: 4px;
  border-left: 3px solid var(--color-error);
}

/* Pros and Cons Section */
.pros-cons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.advantages, .limitations {
  background: var(--color-white);
  border-radius: 8px;
  padding: 25px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.advantages h3 {
  color: var(--color-success);
  font-size: 20px;
  margin-bottom: 15px;
}

.limitations h3 {
  color: var(--color-error);
  font-size: 20px;
  margin-bottom: 15px;
}

.advantages ul, .limitations ul {
  list-style-type: none;
  padding: 0;
}

.advantages li {
  background: #f0f9f0;
  margin: 8px 0;
  padding: 10px;
  border-radius: 4px;
  border-left: 3px solid var(--color-success);
}

.limitations li {
  background: #ffeaea;
  margin: 8px 0;
  padding: 10px;
  border-radius: 4px;
  border-left: 3px solid var(--color-error);
}

/* Related Reactions Section */
.related-reactions-section {
  margin-top: 40px;
  grid-column: 1 / -1; /* Full width like references section */
  background: var(--color-gray-50);
  padding: 25px;
  border-radius: 8px;
  border: 1px solid var(--color-gray-300);
}

.related-reactions-section h2 {
  margin-bottom: 25px;
  color: var(--color-gray-600);
  font-weight: 600;
  border-bottom: 3px solid;
  border-image: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%) 1;
  padding-bottom: 8px;
}

.related-reactions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  align-items: start;
  max-width: 100%;
}

.related-category {
  background: var(--color-white);
  padding: 20px;
  border-radius: 6px;
  border: 1px solid var(--color-gray-150);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  height: fit-content;
  display: flex;
  flex-direction: column;
}



.related-links-container {
  overflow-x: hidden; /* Still prevent horizontal scroll */
  margin-top: 0;
  padding-top: 5px;
}

/* Grid layout for reactions - multiple per row */
.related-reactions-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

/* Collapsible functionality */
.related-category {
  position: relative;
}

.related-category-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  cursor: pointer;
  padding: 5px 0;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  min-height: 80px;
}

.related-category-header:hover {
  background-color: var(--color-gray-50);
}

.related-category h3 {
  margin: 0 0 15px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-gray-600);
  border-bottom: 3px solid;
  border-image: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%) 1;
  padding-bottom: 8px;
  word-wrap: break-word;
  flex: 1;
  min-height: 60px;
  display: flex;
  align-items: flex-start;
  line-height: 1.3;
}

.related-category-header h3 {
  margin: 0;
  margin-bottom: 15px;
  min-height: 60px;
  display: flex;
  align-items: flex-start;
  line-height: 1.3;
}

.collapse-toggle {
  font-size: 14px;
  color: var(--color-gray-500);
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 3px;
  transition: all 0.2s ease;
  min-width: fit-content;
}

.collapse-toggle:hover {
  background-color: var(--color-gray-150);
  color: var(--color-gray-600);
}

.related-category.collapsed .related-links-container {
  display: none;
}

.related-category.collapsed h3 {
  margin-bottom: 5px;
}

/* Show more button */
.show-more-btn {
  background: var(--color-gray-50);
  border: 1px solid var(--color-gray-200);
  color: var(--color-gray-500);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
  text-align: center;
  margin-top: 8px;
  width: 100%;
}

.show-more-btn:hover {
  background: var(--color-gray-150);
  color: var(--color-gray-600);
  border-color: #adb5bd;
}

/* Hidden reactions styling */
.hidden-reactions {
  display: none;
}

.hidden-reactions.expanded {
  display: block;
}

/* Enhanced related reaction link styles - Compact Professional Design */
.related-reactions-section .related-reaction-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  margin-bottom: 8px;
  background: var(--gradient-primary);
  border: 2px solid var(--color-gray-500);
  position: relative;
  overflow: hidden;
  min-height: 80px;
  flex: 1;
  min-width: 0;
}

.related-reactions-section .related-reaction-link:hover {
  background: var(--gradient-primary-hover);
  border-color: var(--color-gray-600);
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
}

/* Reaction flow container - centered horizontal layout */
.reaction-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  gap: 18px;
  padding: 0 10px;
}

/* Functional group images - larger size with shadows */
.related-reactions-section .from-fg,
.related-reactions-section .to-fg {
  width: 65px;
  height: 65px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-gray-50);
  border: 2px solid var(--color-gray-500);
  background-size: calc(100% - 10px);
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  flex-grow: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.08);
  /* Hide text labels - images only */
  text-indent: -9999px;
  font-size: 0;
}

.related-reactions-section .from-fg:hover,
.related-reactions-section .to-fg:hover {
  background-color: var(--color-gray-150);
  border-color: var(--color-gray-600);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

/* Professional arrow design - white on gradient */
.related-reactions-section .reaction-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 4px;
  background: var(--color-white);
  border: 1px solid var(--color-gray-500);
  border-radius: 2px;
  width: 80px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.related-reactions-section .reaction-arrow::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid white;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  filter: drop-shadow(1px 0 1px var(--color-gray-500)) drop-shadow(-1px 0 1px var(--color-gray-500)) drop-shadow(0 1px 1px var(--color-gray-500)) drop-shadow(0 -1px 1px var(--color-gray-500));
}

/* Compact reagent label with text wrapping */
.related-reactions-section .reagent-label {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-white);
  color: var(--color-gray-600);
  font-size: 9px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 3px;
  border: 1px solid var(--color-gray-500);
  max-width: 100px;
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  line-height: 1.2;
}

.no-results {
  color: var(--color-gray-500);
  font-style: italic;
  text-align: center;
  padding: 20px;
  background: var(--color-gray-25);
  border-radius: 4px;
  border: 1px dashed var(--color-gray-300);
}

/* Mobile responsiveness for related reactions */
@media (max-width: 768px) {
  .related-reactions-section {
    margin: 20px 10px; /* Reduced margin for better centering */
    padding: 20px 15px; /* Reduced padding */
    max-width: calc(100% - 20px); /* Ensure it doesn't exceed screen width */
  }
  
  .related-reactions-grid {
    gap: 15px;
    grid-template-columns: 1fr; /* Stack columns on mobile */
  }
  
  .related-category {
    padding: 15px;
    margin: 0 auto; /* Center the categories */
    max-width: 100%;
  }
  
  .related-reactions-row {
    gap: 8px;
  }
  
  .related-reactions-section .related-reaction-link {
    min-height: 70px;
    padding: 8px 12px;
    margin: 0 auto 8px auto; /* Center the reaction links */
    max-width: 100%;
  }
  
  .reaction-flow {
    gap: 12px;
    width: 100%;
  }
  
  .related-reactions-section .from-fg,
  .related-reactions-section .to-fg {
    width: 50px;
    height: 50px;
    background-size: contain;
    flex-shrink: 0;
    flex-grow: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.08);
  }
  
  .related-reactions-section .reaction-arrow {
    width: 50px;
    height: 2px;
  }
  
  .related-reactions-section .reaction-arrow::after {
    border-left: 6px solid white;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    right: -4px;
    filter: drop-shadow(1px 0 1px var(--color-gray-500)) drop-shadow(-1px 0 1px var(--color-gray-500)) drop-shadow(0 1px 1px var(--color-gray-500)) drop-shadow(0 -1px 1px var(--color-gray-500));
  }
  
  .related-reactions-section .reagent-label {
    font-size: 8px;
    padding: 2px 4px;
    top: -12px;
    max-width: 80px;
    line-height: 1.1;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .header-main {
    height: 52px;
    padding: 0 16px;
  }
  
  .site-name {
    font-size: 18px;
  }
  
  .site-logo {
    height: 30px;
    width: 32px;
  }
  
  
  .nav-tabs {
    overflow: hidden;
    flex-wrap: nowrap;
    padding: 0 16px;
    height: 40px;
    justify-content: space-evenly;
  }
  
  .nav-tabs::-webkit-scrollbar {
    height: 3px;
  }
  
  .nav-tab {
    padding: 6px 12px;
    font-size: 14px;
    white-space: nowrap;
    flex: 1;
    text-align: center;
  }
  
  .functional-group-title {
    font-size: 20.4px;
    padding: 8px 16px; /* Reduced padding for more compact title */
    letter-spacing: -0.5px;
    top: 115px; /* Position closer to top bar */
  }
  
  .reaction-detail-container {
    padding-top: 100px; /* Adjust for smaller mobile header */
  }
  
  .reaction-detail-content {
    padding: 15px 20px 40px;
  }
  
  .reaction-detail-content.simple {
    padding: 15px 20px 40px;
  }
  
  .reaction-title {
    font-size: 28px;
  }
  
  .simple-overview {
    padding: 25px 20px;
    margin: 25px 0;
  }
  
  .simple-overview p {
    font-size: 16px;
    line-height: 1.6;
  }
  
  .pros-cons-grid {
    grid-template-columns: 1fr;
  }
  
  .considerations-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .header-main {
    padding: 0 12px;
    height: 48px;
  }
  
  .header-left {
    gap: 12px;
  }
  
  
  .site-name {
    font-size: 16px;
  }
  
  .site-logo {
    height: 26px;
    width: 28px;
  }
  
  .nav-tabs {
    padding: 0 12px;
    height: 36px;
    justify-content: space-evenly;
    overflow: hidden;
  }
  
  .nav-tab {
    padding: 6px 10px;
    font-size: 13px;
    flex: 1;
    text-align: center;
  }
  
  .functional-group-title {
    font-size: 17px;
    padding: 6px 12px; /* More compact padding for phones */
    letter-spacing: -0.3px;
    top: 115px; /* Position closer to top bar */
  }
  
  .reaction-detail-container {
    padding-top: 92px; /* Adjust for smaller mobile header */
  }
  
  .reaction-title {
    font-size: 24px;
  }
  
  .reaction-detail-content.simple {
    padding: 15px 15px 30px;
  }
  
  .simple-overview {
    padding: 20px 15px;
    margin: 20px 0;
  }
  
  .simple-overview p {
    font-size: 15px;
  }
  
  .detail-section {
    padding: 20px 15px;
  }
  
  .examples-grid,
  .related-reactions-grid {
    grid-template-columns: 1fr;
  }
}

/* Footer Styles */
.site-footer {
  background: var(--gradient-primary);
  color: var(--color-white);
  margin-top: 80px;
  padding: 60px 0 0 0;
  position: relative;
  z-index: 1;
  box-shadow: 0 -1px 30px rgba(0, 0, 0, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Footer inside reaction detail pages - full width */
.reaction-detail-content .site-footer {
  margin-left: -30px;
  margin-right: -30px;
  margin-bottom: -60px;
  width: calc(100% + 60px);
}

/* For study guide style with max-width constraint */
.reaction-detail-content.study-guide-style .site-footer {
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  width: 100vw;
  margin-bottom: -60px;
}

@media (max-width: 768px) {
  .reaction-detail-content .site-footer {
    margin-left: -20px;
    margin-right: -20px;
    margin-bottom: -40px;
    width: calc(100% + 40px);
  }
  
  .reaction-detail-content.study-guide-style .site-footer {
    margin-bottom: -40px;
  }
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 40px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 40px 40px 40px;
}

.footer-section h3 {
  color: rgba(255, 255, 255, 0.95);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.3px;
  position: relative;
  padding-bottom: 12px;
}

/* Ensure footer colors are preserved in reaction detail pages */
.reaction-detail-content .footer-section h3,
.reaction-detail-content.study-guide-style .footer-section h3 {
  color: rgba(255, 255, 255, 0.95) !important;
}

.reaction-detail-content .footer-section p,
.reaction-detail-content.study-guide-style .footer-section p {
  color: rgba(255, 255, 255, 0.8) !important;
}

.reaction-detail-content .footer-section ul li a,
.reaction-detail-content.study-guide-style .footer-section ul li a {
  color: rgba(255, 255, 255, 0.75) !important;
}

.reaction-detail-content .footer-section ul li a:hover,
.reaction-detail-content.study-guide-style .footer-section ul li a:hover {
  color: rgba(255, 255, 255, 1) !important;
}

.reaction-detail-content .footer-copyright p,
.reaction-detail-content.study-guide-style .footer-copyright p {
  color: rgba(255, 255, 255, 0.8) !important;
}

.footer-section h3::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.2));
  border-radius: 1px;
}

.footer-section p {
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.7;
  font-size: 15px;
  margin-bottom: 20px;
  font-weight: 400;
  letter-spacing: 0.2px;
}

.footer-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-section ul li {
  margin-bottom: 8px;
}

.footer-section ul li a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: 15px;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: block;
  padding: 6px 0;
  font-weight: 400;
  letter-spacing: 0.1px;
  border-radius: 4px;
  position: relative;
}

.footer-section ul li a:hover {
  color: rgba(255, 255, 255, 1);
  padding-left: 8px;
  transform: translateX(4px);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.social-links {
  display: flex;
  gap: 15px;
  margin-top: 15px;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  text-decoration: none;
  padding: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  width: 44px;
  height: 44px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.social-links a:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
}

.footer-copyright {
  text-align: center;
  padding: 30px 0 40px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 40px;
}

.footer-copyright p {
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.2px;
}


.legal-links {
  display: flex;
  gap: 20px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.legal-links a {
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  font-weight: 400;
  letter-spacing: 0.1px;
}

.legal-links a:hover {
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.footer-info {
  text-align: right;
}

.footer-info p {
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
  letter-spacing: 0.1px;
}

.footer-info .version {
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  margin-top: 6px;
  font-weight: 300;
}

/* Responsive Footer */
@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 25px;
  }
  
  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 15px;
  }
  
  .footer-info {
    text-align: center;
  }
  
  .legal-links {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .footer-content {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .footer-section h3 {
    font-size: 15px;
  }
  
  .social-links {
    justify-content: center;
  }
  
  .legal-links {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
}

/* Study Guide Style Reaction Details Page */
.reaction-detail-content.study-guide-style {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 30px 60px;
  background: var(--color-white);
  font-family: var(--font-sans);
  line-height: 1.6;
  color: var(--color-gray-800);
}

.reaction-detail-content.study-guide-style h1 {
  font-size: 28px;
  margin-bottom: 20px;
  color: var(--color-gray-800);
}

.reaction-detail-content.study-guide-style h2 {
  font-size: 22px;
  margin-top: 30px;
  margin-bottom: 15px;
  color: var(--color-gray-800);
  border-bottom: 3px solid;
  border-image: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%) 1;
  padding-bottom: 8px;
}

.reaction-detail-content.study-guide-style h3 {
  font-size: 18px;
  margin-top: 25px;
  margin-bottom: 12px;
  color: var(--color-gray-700);
}

.reaction-detail-content.study-guide-style h4 {
  font-size: 15px;
  margin-top: 15px;
  margin-bottom: 8px;
  color: var(--color-gray-700);
  font-weight: 600;
}

/* Reaction Banner */
.reaction-banner {
  background: var(--gradient-primary);
  color: var(--color-white);
  padding: 25px;
  border-radius: 8px;
  margin: 25px 0 30px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.reaction-scheme-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.reaction-scheme-placeholder {
  background: rgba(255, 255, 255, 0.95);
  color: var(--color-gray-800);
  border-radius: 6px;
  padding: 20px;
  width: 100%;
  text-align: center;
}

.scheme-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.scheme-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--color-gray-800);
}

.scheme-equation {
  font-size: 18px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  color: var(--color-info);
  padding: 10px;
  background: var(--color-gray-50);
  border-radius: 4px;
  border: 2px dashed var(--color-info);
}

.scheme-note {
  font-size: 13px;
  color: var(--color-gray-500);
  margin: 5px 0 0 0;
  font-style: italic;
}

.mechanism-classification {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 15px;
  border-radius: 4px;
  backdrop-filter: blur(5px);
}

/* Two-Column Layout */
.reaction-content-wrapper {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 30px;
  margin-top: 30px;
}

.reaction-main-content {
  /* Left column - main content */
}

/* Study Guide Infobox (Right Column) */
.reaction-infobox {
  background: #ffffff;
  border: 2px solid #e1e8ed;
  border-radius: 12px;
  padding: 0;
  height: fit-content;
  position: sticky;
  top: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}

.reaction-infobox:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
}

.infobox-header {
  background: var(--gradient-primary);
  color: var(--color-white);
  padding: 18px 24px;
  border-radius: 0;
  text-align: center;
  position: relative;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.infobox-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, rgba(255,255,255,0.2), rgba(255,255,255,0.1), rgba(255,255,255,0.2));
}

.reaction-infobox .infobox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.reaction-infobox .infobox-header h3 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #ffffff !important;
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.debug-toggle-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--color-white);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.debug-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

.debug-toggle-btn.debug-active {
  background: rgba(255, 255, 255, 0.9);
  color: var(--color-link);
  border-color: rgba(255, 255, 255, 0.8);
}

.debug-toggle-btn #debugToggleIcon {
  font-size: 14px;
}

/* Smart hiding system for empty fields */
.info-item.empty-field {
  display: none;
}

.infobox-section.empty-section {
  display: none;
}

.infobox-section.collapsed-section {
  opacity: 0.6;
}

.infobox-section.collapsed-section h4::after {
  content: " (no data)";
  color: var(--color-gray-400);
  font-weight: 400;
  font-size: 12px;
}

/* Debug mode shows everything */
.debug-mode .info-item.empty-field {
  display: flex;
}

.debug-mode .infobox-section.empty-section {
  display: block;
}

.debug-mode .infobox-section.collapsed-section {
  opacity: 1;
}

.debug-mode .infobox-section.collapsed-section h4::after {
  display: none;
}

/* Visual indicator for debug mode */
.debug-mode .reaction-infobox {
  border: 2px solid #fbbf24;
  box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

.debug-mode .reaction-infobox::before {
  content: "🔍 DEBUG MODE - Showing all fields";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: #fbbf24;
  color: #92400e;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  z-index: 10;
}

.infobox-content {
  padding: 0;
  background: #ffffff;
}

.infobox-section {
  margin-bottom: 0;
  padding: 18px 24px 16px;
  border-bottom: 1px solid #f1f3f4;
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  transition: background-color 0.2s ease;
}

.infobox-section:hover {
  background: linear-gradient(180deg, #fafbfc 0%, #f5f7fa 100%);
}

.infobox-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  border-radius: 0 0 10px 10px;
}

.infobox-section:nth-child(odd) {
  background: linear-gradient(180deg, #fdfdfe 0%, var(--color-gray-50) 100%);
}

.infobox-section:nth-child(odd):hover {
  background: linear-gradient(180deg, var(--color-gray-50) 0%, #f3f4f6 100%);
}

.infobox-section h4 {
  margin: 0 0 14px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--color-link);
  letter-spacing: 0.3px;
  padding-bottom: 6px;
  border-bottom: 2px solid #e5e9f0;
  position: relative;
}

.infobox-section h4::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 30px;
  height: 2px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  border-radius: 1px;
}

.info-item {
  display: grid;
  grid-template-columns: 1fr 1.5fr auto;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 13px;
  padding: 6px 0;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}

.info-item:hover {
  background-color: rgba(102, 126, 234, 0.03);
  padding-left: 8px;
  padding-right: 8px;
}

.info-item label {
  font-weight: 600;
  color: var(--color-gray-700);
  font-size: 12px;
  line-height: 1.4;
  align-self: start;
  padding-top: 1px;
}

.info-item span {
  color: var(--color-gray-800);
  word-wrap: break-word;
  line-height: 1.4;
  font-weight: 500;
  align-self: start;
}

/* Special styling for different value types */
.info-item span:not([id*="NULL"]) {
  color: var(--color-gray-800);
  font-weight: 500;
}

.info-item span[id*="NULL"] {
  color: var(--color-gray-400);
  font-style: italic;
  font-weight: 400;
}

/* Emoji column styling */
.emoji-column {
  font-size: 16px;
  text-align: center;
  align-self: center;
  width: 24px;
  justify-self: center;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.info-item:hover .emoji-column {
  opacity: 1;
}

/* Substrate Compatibility Table in Summary Panel */
.infobox-section .substrate-compatibility-display {
  margin: 8px 0;
}

.infobox-section .substrate-compatibility-display .compatibility-table {
  margin: 0 auto;
  max-width: 100%;
  width: auto;
  min-width: 200px;
}

.infobox-section .substrate-compatibility-display .compatibility-group {
  margin-bottom: 1rem;
}

/* Emoji Admin Panel Styles */
.emoji-admin-panel {
  background: var(--color-white);
  border: 1px solid var(--color-gray-300);
  border-radius: 8px;
  padding: 20px;
  margin: 20px 0;
  max-width: 800px;
}

.emoji-admin-panel h3 {
  margin-top: 0;
  color: var(--color-gray-800);
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 10px;
}

.admin-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--color-gray-300);
}

.admin-tab {
  background: var(--color-gray-50);
  border: 1px solid var(--color-gray-300);
  border-bottom: none;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: all 0.2s ease;
}

.admin-tab:hover {
  background: var(--color-gray-150);
}

.admin-tab.active {
  background: var(--color-white);
  border-bottom: 1px solid white;
  margin-bottom: -1px;
  color: var(--color-primary);
  font-weight: 600;
}

.tab-panel {
  display: none;
  padding: 20px 0;
}

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

.field-selector {
  margin-bottom: 20px;
}

.field-selector label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: var(--color-gray-800);
}

.field-selector select {
  width: 100%;
  max-width: 300px;
  padding: 8px 12px;
  border: 1px solid var(--color-gray-300);
  border-radius: 4px;
  font-size: 14px;
}

.mappings-container {
  background: var(--color-gray-50);
  border: 1px solid var(--color-gray-300);
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 20px;
  min-height: 100px;
}

.mapping-list {
  display: grid;
  gap: 10px;
}

.mapping-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 15px;
  padding: 10px;
  background: var(--color-white);
  border: 1px solid var(--color-gray-150);
  border-radius: 4px;
  align-items: center;
}

.mapping-item.has-mapping {
  border-color: var(--color-success);
  background: #f8fff8;
}

.mapping-item.no-mapping {
  border-color: #ffc107;
  background: #fffef8;
}

.mapping-value {
  font-family: monospace;
  background: #f1f3f4;
  padding: 4px 8px;
  border-radius: 3px;
  font-size: 13px;
}

.mapping-emoji {
  font-size: 18px;
  text-align: center;
  min-width: 30px;
}

.remove-mapping {
  background: var(--color-error);
  color: var(--color-white);
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.remove-mapping:hover {
  background: #c82333;
}

.save-mapping {
  background: var(--color-success);
  color: var(--color-white);
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 24px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.save-mapping:hover {
  background: #218838;
}

.add-mapping {
  background: #e8f5e8;
  border: 1px solid #c3e6c3;
  border-radius: 6px;
  padding: 15px;
  margin-top: 20px;
}

.add-mapping h4 {
  margin-top: 0;
  color: #2d5a2d;
}

.add-mapping input {
  width: 100%;
  max-width: 200px;
  padding: 8px 12px;
  margin: 5px 10px 5px 0;
  border: 1px solid var(--color-gray-300);
  border-radius: 4px;
  font-size: 14px;
}

.add-mapping button {
  background: var(--color-success);
  color: var(--color-white);
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s ease;
}

.add-mapping button:hover {
  background: #218838;
}

.bulk-operations {
  display: grid;
  gap: 15px;
}

.bulk-operations h4 {
  margin-top: 0;
  color: var(--color-gray-800);
}

.bulk-operations button {
  background: var(--color-primary);
  color: var(--color-white);
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s ease;
}

.bulk-operations button:hover {
  background: #5a67d8;
}

.bulk-operations textarea {
  width: 100%;
  height: 200px;
  padding: 10px;
  border: 1px solid var(--color-gray-300);
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
}

/* Quick Links in Infobox */
.quick-links {
  font-size: 12px;
}

.link-category {
  margin-bottom: 10px;
}

.link-category label {
  font-weight: 600;
  color: var(--color-gray-700);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.link-list {
  margin-top: 5px;
  padding-left: 10px;
  max-height: 200px;
  overflow-y: auto;
}

.link-list::-webkit-scrollbar {
  width: 4px;
}

.link-list::-webkit-scrollbar-track {
  background: transparent;
}

.link-list::-webkit-scrollbar-thumb {
  background: rgba(52, 152, 219, 0.3);
  border-radius: 2px;
}

.link-list::-webkit-scrollbar-thumb:hover {
  background: rgba(52, 152, 219, 0.5);
}

/* Mechanism Videos */
.mechanism-videos {
  margin-top: 25px;
  background: var(--color-gray-50);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--color-gray-300);
}

.video-container {
  margin-top: 15px;
}

/* Scheme Placeholders */
.mechanism-scheme-placeholder {
  background: var(--color-gray-50);
  border: 2px dashed var(--color-gray-300);
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  margin: 20px 0;
}

.mechanism-scheme-placeholder .scheme-box {
  color: var(--color-gray-500);
}

.mechanism-scheme-placeholder .scheme-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-gray-700);
}

/* Examples Section */
.examples-section {
  margin-top: 30px;
}

.examples-section h2 {
  margin-bottom: 25px;
  color: var(--color-gray-600);
  font-weight: 600;
  border-bottom: 3px solid;
  border-image: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%) 1;
  padding-bottom: 8px;
}

.examples-container {
  margin-top: 15px;
}

/* References Section */
.references-section {
  margin-top: 40px;
  grid-column: 1 / -1; /* Full width */
  background: var(--color-gray-50);
  padding: 25px;
  border-radius: 8px;
  border: 1px solid var(--color-gray-300);
}

.references-section h2 {
  margin-bottom: 25px;
  color: var(--color-gray-600);
  font-weight: 600;
  border-bottom: 3px solid;
  border-image: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%) 1;
  padding-bottom: 8px;
}

.references-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.citation-section,
.metadata-section {
  background: var(--color-white);
  padding: 15px;
  border-radius: 6px;
  border: 1px solid var(--color-gray-150);
}

.citation-content {
  margin-top: 10px;
}

.citation-content p {
  margin: 0;
  line-height: 1.6;
  font-size: 14px;
  color: var(--color-gray-800);
}

.citation-section h4 {
  margin: 0 0 10px 0;
  color: var(--color-gray-600);
  font-size: 16px;
  font-weight: 600;
}

.further-reading-link {
  color: var(--color-info);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
  font-weight: 500;
  display: inline-block;
  margin-right: 0.5em;
  margin-bottom: 0.25em;
}

.further-reading-link:hover {
  color: #2980b9;
  border-bottom-color: var(--color-info);
  text-decoration: none;
}

.further-reading-link::after {
  content: ' ↗';
  font-size: 12px;
  color: var(--color-gray-500);
  margin-left: 2px;
}

/* Citation text styling for non-URL citations */
.citation-text {
  color: var(--color-gray-800);
  font-style: italic;
  display: inline-block;
  margin-right: 0.5em;
  margin-bottom: 0.25em;
}

.citation-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--color-gray-500);
  font-style: italic;
  line-height: 1.4;
}

.metadata-grid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.metadata-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.metadata-item label {
  font-weight: 600;
  color: var(--color-gray-700);
  min-width: 90px;
  font-size: 12px;
}

.metadata-item span {
  color: var(--color-gray-800);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .reaction-content-wrapper {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .reaction-infobox {
    position: static;
    order: -1; /* Move to top on mobile */
  }
  
  .references-content {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .reaction-detail-content.study-guide-style {
    padding: 20px 15px 40px;
  }
  
  .reaction-banner {
    padding: 20px 15px;
  }
  
  .scheme-equation {
    font-size: 16px;
  }
}

/* Video Embed Containers */
.video-embed-container {
  margin-bottom: 20px;
}

.video-embed-placeholder {
  background: var(--color-gray-50);
  border: 2px dashed var(--color-gray-300);
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  color: var(--color-gray-500);
  font-style: italic;
}

.video-embed-container iframe {
  width: 100%;
  height: 315px;
  border-radius: 8px;
  border: none;
}

/* Mechanism Section Styles */
.mechanism-details {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.mechanism-schema-section,
.mechanism-videos-section {
  background: var(--color-gray-50);
  border-radius: 8px;
  padding: 1.5rem;
  border: 1px solid var(--color-gray-150);
}

.mechanism-schema-section h3,
.mechanism-videos-section h3 {
  margin-bottom: 1rem;
  color: var(--color-gray-600);
  font-size: 1.2rem;
  border-bottom: 3px solid;
  border-image: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%) 1;
  padding-bottom: 0.5rem;
}

.mechanism-scheme-container {
  text-align: center;
  padding: 1rem;
  background: var(--color-white);
  border-radius: 6px;
  border: 1px solid var(--color-gray-200);
}

.mechanism-scheme-container img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-gray-300);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.no-schema-placeholder,
.no-videos-placeholder {
  text-align: center;
  padding: 2rem;
  background: var(--color-white);
  border-radius: 6px;
  border: 1px solid var(--color-gray-200);
}

/* Video Items */
.video-item {
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: 6px;
  margin-bottom: 1rem;
  overflow: hidden;
}

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

.video-content {
  padding: 1rem;
  background: var(--color-white);
}

.video-content iframe {
  width: 100%;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.video-link-fallback {
  text-align: center;
  padding: 2rem;
}

.video-link-fallback .btn {
  margin-bottom: 0.5rem;
}

/* Video Caption Styles */
.video-embed-wrapper {
  margin-bottom: 0.25rem;
}

.video-caption {
  text-align: left;
  margin-top: 0.25rem;
  padding: 0;
  line-height: 1.2;
}

.video-caption small {
  color: var(--color-gray-500);
  font-size: 0.75rem;
}

.channel-link {
  color: var(--color-link);
  text-decoration: none;
  font-weight: 500;
}

.channel-link:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .mechanism-details {
    gap: 1rem;
  }
  
  .mechanism-schema-section,
  .mechanism-videos-section {
    padding: 1rem;
  }
  
  .video-content {
    padding: 0.5rem;
  }
  
  .video-content iframe {
    height: 200px;
  }
}

/* ===========================================
   REACTION SCHEME IMAGE STYLES
   =========================================== */

.reaction-scheme-image-container {
    background: var(--color-white);
    border: 1px solid var(--color-gray-300);
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.scheme-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.scheme-header h4 {
    margin: 0;
    color: var(--color-gray-800);
    font-size: 16px;
}

.scheme-mechanism {
    background: var(--color-info);
    color: var(--color-white);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.scheme-image-wrapper {
    text-align: center;
    margin: 15px 0;
}

.reaction-scheme-image {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--color-gray-300);
    border-radius: 4px;
    transition: transform 0.2s ease;
}

.reaction-scheme-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.scheme-footer {
    text-align: center;
    margin-top: 10px;
}

.scheme-footer .text-muted {
    color: var(--color-gray-500);
    font-size: 11px;
}

/* Loading state */
.scheme-loading {
    text-align: center;
    padding: 20px;
    color: var(--color-gray-500);
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--color-info);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

/* Unavailable scheme placeholder */
.scheme-unavailable {
    text-align: center;
    padding: 20px;
    background: var(--color-gray-50);
    border: 1px dashed var(--color-gray-200);
    border-radius: 8px;
    color: var(--color-gray-500);
}

.scheme-unavailable .scheme-box {
    max-width: 300px;
    margin: 0 auto;
}

.scheme-unavailable .scheme-title {
    font-weight: 600;
    color: var(--color-gray-600);
    display: block;
    margin-bottom: 10px;
}

.scheme-unavailable .scheme-equation {
    margin: 10px 0;
    font-size: 14px;
}

.scheme-unavailable .scheme-note {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.4;
}

/* Full-size overlay */
.reaction-scheme-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.scheme-overlay-content {
    background: var(--color-white);
    border-radius: 12px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.scheme-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: var(--color-gray-50);
    border-radius: 12px 12px 0 0;
}

.scheme-overlay-header h3 {
    margin: 0;
    color: var(--color-gray-800);
    font-size: 18px;
}

.close-overlay {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-gray-500);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.close-overlay:hover {
    background: var(--color-gray-150);
    color: var(--color-gray-600);
}

.scheme-overlay-body {
    padding: 20px;
    text-align: center;
}

.scheme-overlay-image {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--color-gray-200);
    border-radius: 8px;
    margin-bottom: 15px;
}

.scheme-overlay-info {
    text-align: left;
    margin-top: 15px;
    padding: 15px;
    background: var(--color-gray-50);
    border-radius: 6px;
}

.scheme-overlay-info p {
    margin: 5px 0;
    font-size: 14px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .reaction-scheme-image-container {
        padding: 10px;
    }
    
    .scheme-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .scheme-overlay-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .scheme-overlay-header {
        padding: 15px;
    }
    
    .scheme-overlay-body {
        padding: 15px;
    }
}

/* Integration with existing reaction detail styles */
.reaction-banner .reaction-scheme-container {
    margin-bottom: 20px;
}

.reaction-scheme-placeholder {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================
   HALOGEN VARIANT CYCLING STYLES
   ========================================== */

.cycling-variants {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.scheme-image-wrapper {
    position: relative;
    display: inline-block;
}

.variant-controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 8px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.variant-indicator {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--color-white);
    padding: 4px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.variant-indicator.cl { background-color: #00AA00; }
.variant-indicator.br { background-color: #CC4400; }
.variant-indicator.i { background-color: #6600CC; }

.cycle-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cycle-btn {
    background: none;
    border: none;
    font-size: 1.1em;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.cycle-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.variant-dots {
    display: flex;
    gap: 4px;
}

.variant-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.variant-dot.cl { background-color: #00AA00; }
.variant-dot.br { background-color: #CC4400; }
.variant-dot.i { background-color: #6600CC; }

.variant-dot:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.variant-dot.active {
    transform: scale(1.3);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.halogen-legend {
    margin-top: 10px;
    display: flex;
    gap: 12px;
    font-size: 0.9em;
    justify-content: center;
}

.legend-item {
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--color-white);
    font-weight: 600;
    min-width: 24px;
    text-align: center;
}

.legend-item.cl { background-color: #00AA00; }
.legend-item.br { background-color: #CC4400; }
.legend-item.i { background-color: #6600CC; }

.variant-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--color-white);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.variant-badge.cl { background-color: #00AA00; }
.variant-badge.br { background-color: #CC4400; }
.variant-badge.i { background-color: #6600CC; }

/* Fade transition for image changes */
.scheme-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Loading and error states */
.scheme-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.scheme-loading-state .loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--color-link);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.scheme-loading-state p {
    margin: 0;
    color: var(--color-gray-500);
    font-size: 0.9em;
}

.scheme-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--color-error);
}

.scheme-error-state .error-icon {
    font-size: 2em;
    margin-bottom: 10px;
}

.scheme-error-state p {
    margin: 5px 0;
    font-weight: 600;
}

.scheme-error-state small {
    color: #999;
    font-size: 0.8em;
}

@media (max-width: 768px) {
    .variant-controls {
        position: static;
        transform: none;
        margin-top: 10px;
        background: rgba(255, 255, 255, 0.98);
        border-radius: 12px;
        padding: 10px;
    }

    .variant-indicator {
        font-size: 0.8em;
        padding: 3px 6px;
    }

    .halogen-legend {
        font-size: 0.8em;
        gap: 8px;
    }
}

/* Single scheme and variant containers */
.reaction-scheme-container.single-scheme,
.reaction-scheme-container.single-variant {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.reaction-scheme-container.single-variant {
    position: relative;
}

.variant-label {
    margin-top: 10px;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--color-gray-800);
    background: #ecf0f1;
    padding: 4px 12px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Error states */
.reaction-scheme-container.error-state {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    min-height: 200px;
}

.scheme-error {
    text-align: center;
    color: var(--color-gray-500);
    max-width: 400px;
}

.scheme-error p {
    margin: 8px 0;
}

.scheme-error .error-details {
    font-size: 0.9em;
    color: #95a5a6;
    font-style: italic;
}

/* Cycling variants styles */
.cycling-variants {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.scheme-image-wrapper {
    position: relative;
    display: inline-block;
}

.variant-controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 8px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.variant-indicator {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--color-white);
    padding: 4px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 24px;
    text-align: center;
}

.variant-indicator.Cl {
    background: linear-gradient(135deg, #00AA00, #00CC00);
}

.variant-indicator.Br {
    background: linear-gradient(135deg, #CC4400, #FF5500);
}

.variant-indicator.I {
    background: linear-gradient(135deg, #6600CC, #7700DD);
}

.cycle-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cycle-btn {
    background: none;
    border: none;
    font-size: 1.1em;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.cycle-btn:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

.cycle-btn:active {
    transform: scale(0.95);
}

.variant-dots {
    display: flex;
    gap: 6px;
}

.variant-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.variant-dot.Cl {
    background: #00AA00;
}

.variant-dot.Br {
    background: #CC4400;
}

.variant-dot.I {
    background: #6600CC;
}

.variant-dot.active {
    transform: scale(1.3);
    border-color: rgba(0, 0, 0, 0.3);
}

.variant-dot:hover {
    transform: scale(1.2);
}

/* Halogen legend */
.halogen-legend {
    margin-top: 15px;
    padding: 10px 15px;
    background: var(--color-gray-50);
    border-radius: 8px;
    border: 1px solid var(--color-gray-150);
}

.halogen-legend h4 {
    margin: 0 0 8px 0;
    font-size: 0.9em;
    color: var(--color-gray-600);
    text-align: center;
}

.legend-items {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-color.Cl {
    background: #00AA00;
}

.legend-color.Br {
    background: #CC4400;
}

.legend-color.I {
    background: #6600CC;
}

/* Loading states */
.variant-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    color: var(--color-gray-500);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #ecf0f1;
    border-top: 3px solid var(--color-info);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

/* Responsive design for variants */
@media (max-width: 768px) {
    .variant-controls {
        bottom: 5px;
        padding: 6px 10px;
        border-radius: 16px;
    }
    
    .variant-indicator {
        font-size: 0.8em;
        padding: 3px 6px;
    }
    
    .cycle-btn {
        width: 24px;
        height: 24px;
        font-size: 1em;
    }
    
    .legend-items {
        gap: 10px;
    }
    
    .legend-item {
        font-size: 0.8em;
    }
}

/* Functional Group Overview Section - Modern Design */
.functional-group-overview-section {
  width: 100%;
  max-width: 1200px;
  margin: 60px auto 40px auto;
  padding: 0 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  transform: translateY(20px);
  position: relative;
  z-index: 10;
  clear: both;
}

.functional-group-overview-section.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Header with gradient background matching reaction tables */
.overview-header {
  background: var(--gradient-primary);
  padding: 40px;
  border-radius: 20px 20px 0 0;
  position: relative;
  overflow: hidden;
}


.overview-title-section {
  display: flex;
  align-items: center;
  gap: 24px;
  position: relative;
  z-index: 1;
}

.overview-heading-block {
  flex: 1;
}

.fg-image-container {
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.fg-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  border-radius: 16px;
}

.overview-header h2 {
  margin: 0;
  font-size: 42px;
  font-weight: 700;
  color: var(--color-white);
  line-height: 1.2;
  flex: 1;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.overview-subtitle {
  margin: 12px 0 0 0;
  max-width: 760px;
  font-size: 18px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
}

/* Gradient separator between header and content */
.overview-content {
  background: var(--color-white);
  padding: 48px 40px 40px 40px;
  line-height: 1.7;
  color: var(--color-gray-700);
  border-radius: 0 0 20px 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-top: none;
  position: relative;
}

/* Add gradient border between header and content - removed */

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.content-block {
  margin-bottom: 20px;
}

.content-block:last-child {
  margin-bottom: 0;
}

.text-block p,
.markdown-block p {
  margin: 0 0 16px 0;
  font-size: 16px;
  line-height: 1.7;
}

.markdown-block h1,
.markdown-block h2,
.markdown-block h3 {
  margin: 24px 0 12px 0;
  font-weight: 600;
  color: var(--color-gray-800);
}

.markdown-block h1 { font-size: 24px; }
.markdown-block h2 { font-size: 20px; }
.markdown-block h3 { font-size: 18px; }

.markdown-block strong {
  font-weight: 600;
  color: var(--color-gray-800);
}

.markdown-block em {
  font-style: italic;
}

.markdown-block code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 14px;
  color: #d97706;
}

.markdown-block ul,
.markdown-block ol {
  margin: 16px 0;
  padding-left: 24px;
}

.markdown-block li {
  margin: 8px 0;
}

.image-block {
  text-align: center;
  margin: 32px 0;
}

.image-block img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.image-caption {
  margin-top: 12px;
  font-size: 14px;
  color: var(--color-gray-500);
  font-style: italic;
}

.overview-loading {
  padding: 60px 32px;
  text-align: center;
  color: var(--color-gray-500);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-gray-200);
  border-top: 3px solid var(--color-info);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px auto;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .functional-group-overview-section {
    margin: 20px auto;
    padding: 0 10px; /* Reduced padding for better centering */
    max-width: calc(100% - 20px); /* Ensure it doesn't exceed screen width */
  }
  
  .overview-header {
    padding: 20px 16px 16px 16px; /* Reduced padding */
  }
  
  .overview-title-section {
    gap: 16px;
  }

  .overview-heading-block {
    width: 100%;
  }
  
  .fg-image-container {
    width: 60px;
    height: 60px;
    padding: 8px;
  }
  
  .overview-header h2 {
    font-size: 24px;
  }

  .overview-subtitle {
    font-size: 16px;
    margin-top: 8px;
  }
  
  .overview-content {
    padding: 20px 16px; /* Reduced padding */
  }
}

/* Mechanism Scheme and Main Scheme Hover Effect and Fullscreen Modal */
.mechanism-scheme-image,
.main-scheme-image {
  transition: all 0.3s ease;
  cursor: pointer;
}

.mechanism-scheme-image:hover,
.main-scheme-image:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  border-color: var(--color-info) !important;
}

/* Fullscreen Modal for Reaction Schemes */
.scheme-fullscreen-modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.scheme-fullscreen-modal.active {
  display: block;
  opacity: 1;
}

.scheme-modal-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.scheme-modal-close {
  position: absolute;
  top: 20px;
  right: 40px;
  color: #fff;
  font-size: 40px;
  font-weight: 300;
  cursor: pointer;
  z-index: 10001;
  transition: transform 0.2s ease;
}

.scheme-modal-close:hover {
  transform: scale(1.1);
  color: #f3f4f6;
}

.scheme-modal-body {
  max-width: 95%;
  max-height: 95%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scheme-modal-image {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  background-color: var(--color-white);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Fix footer styling on reaction detail pages */
.reaction-detail-content .site-footer {
  /* Break out of the container to be full width */
  position: relative;
  left: 50%;
  margin-left: -50vw;
  width: 100vw;
  margin-bottom: 0;
}

/* Prevent horizontal scroll from footer */
.reaction-detail-container {
  overflow-x: hidden;
}

/* Ensure footer text colors remain consistent on reaction detail pages */
.reaction-detail-content .site-footer h3 {
  color: rgba(255, 255, 255, 0.95) !important;
}

.reaction-detail-content .site-footer p {
  color: rgba(255, 255, 255, 0.8) !important;
}

.reaction-detail-content .site-footer a {
  color: rgba(255, 255, 255, 0.75) !important;
}

.reaction-detail-content .site-footer a:hover {
  color: rgba(255, 255, 255, 1) !important;
}

/* Breadcrumb Navigation Styles */
.breadcrumb-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999; /* Higher z-index to ensure it appears above everything */
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-top: 2px solid var(--color-gray-200);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.breadcrumb-nav {
  max-width: 1200px;
  margin: 0 auto;
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  gap: 8px;
  flex-wrap: wrap;
}

.breadcrumb-item {
  text-decoration: none;
  color: var(--color-gray-500);
  transition: color 0.15s ease;
  white-space: nowrap;
}

.breadcrumb-item:hover {
  color: var(--color-gray-700);
  text-decoration: underline;
}

.breadcrumb-item.current {
  color: var(--color-gray-900);
  font-weight: 500;
}

.breadcrumb-separator {
  color: var(--color-gray-400);
  user-select: none;
  margin: 0 4px;
}

/* Adjust main content when breadcrumbs are present */
.main-content-wrapper.has-breadcrumbs {
  padding-bottom: 60px; /* Space for bottom breadcrumbs */
}

/* Ensure reaction detail pages don't have extra white space */
.reaction-detail-container {
  padding-bottom: 0; /* Remove extra padding - breadcrumbs will handle spacing */
  margin-bottom: 60px; /* Add margin instead for proper spacing */
}

.reaction-detail-container .breadcrumb-item {
  color: #4b5563;
}

.reaction-detail-container .breadcrumb-item:hover {
  color: var(--color-gray-800);
}

.reaction-detail-container .breadcrumb-item.current {
  color: var(--color-gray-900);
}

/* Related Reactions Section Styles */
.related-reactions-section {
  margin: 40px 0;
  padding: 24px;
  background: var(--color-gray-50);
  border-radius: 12px;
  border: 1px solid var(--color-gray-200);
}

.related-group {
  margin-bottom: 32px;
}

.related-group:last-child {
  margin-bottom: 0;
}

.related-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-gray-700);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-gray-200);
}

.related-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.related-reaction-link {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.15s ease;
  gap: 12px;
}

.related-reaction-link:hover {
  border-color: var(--color-info);
  background: #f0f9ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.reaction-summary {
  font-weight: 500;
  color: var(--color-gray-700);
  min-width: 0;
  flex: 1;
}

.reaction-arrow {
  color: var(--color-gray-500);
  font-size: 14px;
  flex-shrink: 0;
}

.reaction-product {
  color: #059669;
  font-weight: 500;
  min-width: 0;
  flex: 1;
  text-align: right;
}

.related-fg-link,
.related-home-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--gradient-primary);
  color: var(--color-white);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.15s ease;
  font-weight: 500;
}

.related-fg-link:hover,
.related-home-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.related-home-link {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.fg-link-count {
  font-size: 13px;
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 12px;
}

/* Responsive design for related reactions */
@media (max-width: 768px) {
  .related-reactions-section {
    margin: 24px 0;
    padding: 16px;
  }
  
  .related-reaction-link {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .reaction-arrow {
    align-self: center;
    margin: 4px 0;
  }
  
  .reaction-product {
    text-align: left;
  }
  
  .related-fg-link,
  .related-home-link {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
}

/* =================================
   FUNCTIONAL GROUPS HUB PAGE
   ================================= */

.functional-groups-hub {
  display: none;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease-in;
}

.functional-groups-hub.visible {
  display: block;
}

.hub-header {
  text-align: center;
  margin-bottom: 3rem;
}

.hub-header h1 {
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--color-gray-800);
  margin: 0 0 1rem 0;
}

.hub-header p {
  font-size: 1.1rem;
  color: var(--color-gray-500);
  margin: 0;
  max-width: 600px;
  margin: 0 auto;
}

.functional-groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1.275rem;
  margin-bottom: 3rem;
}

.fg-panel {
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: 12px;
  padding: 0;
  transition: all 0.2s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: hidden;
  position: relative;
  min-height: 170px;
}

.fg-panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  border-color: var(--color-info);
}

.fg-panel-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 0;
  border: none;
  position: absolute;
  top: 0;
  left: 0;
}

.fg-panel-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.fg-panel h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-white);
  margin: 0;
  line-height: 1.3;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  z-index: 1;
}

/* Responsive design */
@media (max-width: 768px) {
  .functional-groups-hub {
    padding: 1rem;
  }
  
  .hub-header h1 {
    font-size: 2rem;
  }
  
  .functional-groups-grid {
    grid-template-columns: repeat(auto-fill, minmax(127px, 1fr));
    gap: 0.85rem;
  }
  
  .fg-panel {
    padding: 0;
    min-height: 127px;
  }
  
  .fg-panel-image {
    width: 100%;
    height: 100%;
  }
  
  .fg-panel-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  
  .fg-panel h3 {
    font-size: 1rem;
  }
}

/* Hide Mechanism column in reaction tables on FG pages */
.reaction-table th:nth-child(3),
.mechanism-cell {
  display: none;
} 
