@tailwind base;
@tailwind components;
@tailwind utilities;

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Hide scrollbar but keep functionality */
.scrollbar-hide {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;  /* Chrome, Safari, Opera */
}

/* ============================================
   HEADER RESPONSIVE UTILITIES
   These override Tailwind's responsive classes
   to ensure proper mobile/desktop switching
   ============================================ */

/* Mobile-only elements: visible on mobile, hidden on desktop (768px+) */
.mobile-only {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

@media (min-width: 768px) {
  .mobile-only {
    display: none !important;
  }
}

/* Desktop-only elements: hidden on mobile, visible on desktop (768px+) */
.desktop-only {
  display: none;
}

@media (min-width: 768px) {
  .desktop-only {
    display: flex !important;
  }
}

.desktop-only-block {
  display: none;
}

@media (min-width: 768px) {
  .desktop-only-block {
    display: block !important;
  }
}

.desktop-only-table {
  display: none;
}

@media (min-width: 768px) {
  .desktop-only-table {
    display: table !important;
  }
}

/* Desktop-only spacing for header items */
.desktop-space-x-4 > * + * {
  margin-left: 0.5rem; /* space-x-2 on mobile */
}

@media (min-width: 768px) {
  .desktop-space-x-4 > * + * {
    margin-left: 1rem !important; /* space-x-4 on desktop */
  }
}

/* Desktop large screen only (1024px+) */
.desktop-lg-only {
  display: none;
}

@media (min-width: 1024px) {
  .desktop-lg-only {
    display: inline !important;
  }
}

/* ============================================
   NAVIGATION & SIDEBAR RESPONSIVE STYLES
   ============================================ */

/* Note: .sr-only class is provided by Tailwind - no need to redefine it here */

/* Sidebar scrollbar styling */
#sidebar .flex-1.overflow-y-auto::-webkit-scrollbar {
  width: 6px;
}

#sidebar .flex-1.overflow-y-auto::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar .flex-1.overflow-y-auto::-webkit-scrollbar-thumb {
  background: #4B5563; /* gray-600 */
  border-radius: 3px;
}

#sidebar .flex-1.overflow-y-auto::-webkit-scrollbar-thumb:hover {
  background: #6B7280; /* gray-500 */
}

/* Sidebar slide animation - works on all screen sizes */
#sidebar {
  transition: transform 0.3s ease-in-out;
}

#sidebar.-translate-x-full {
  transform: translateX(-100%);
}

#sidebar:not(.-translate-x-full) {
  transform: translateX(0);
}

/* Mobile sidebar overlay - full screen on mobile */
@media (max-width: 767px) {
  #sidebar {
    /* Full screen overlay on mobile */
    width: 100%;
    max-width: 20rem; /* 320px max width for better readability */
  }

  /* Backdrop for mobile sidebar */
  #sidebar-backdrop {
    transition: opacity 0.3s ease-in-out;
  }

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

  #sidebar-backdrop:not(.hidden) {
    opacity: 1;
  }
}

/* Tablet sidebar - icon-only collapsed view */
@media (min-width: 768px) and (max-width: 1023px) and (hover: hover) and (pointer: fine) {
  #sidebar {
    /* Icon-only width on tablet */
    width: 4rem; /* 64px for icons */
    overflow: visible; /* Allow hover expansion */
  }

  /* Hide text labels on tablet, show only icons */
  #sidebar .ml-5 > a span:not(.fas),
  #sidebar .ml-5 > a,
  #sidebar button span:not(.fas) {
    display: none;
  }

  /* Show icons only */
  #sidebar .ml-5 {
    margin-left: 0;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Expand on hover */
  #sidebar:hover {
    width: 16rem; /* 256px - same as desktop */
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }

  #sidebar:hover .ml-5 > a span:not(.fas),
  #sidebar:hover .ml-5 > a,
  #sidebar:hover button span:not(.fas) {
    display: inline;
  }

  #sidebar:hover .ml-5 {
    margin-left: 1.25rem;
  }
}

/* Mobile landscape - full width sidebar like desktop */
/* Touch devices in the tablet width range get full sidebar */
@media (min-width: 768px) and (max-width: 1023px) and (hover: none) {
  #sidebar {
    width: 16rem; /* Full width like desktop */
  }
}

/* Desktop sidebar - full width always visible */
@media (min-width: 1024px) {
  #sidebar {
    width: 16rem; /* 256px */
  }

  /* No backdrop needed on desktop */
  #sidebar-backdrop {
    display: none !important;
  }
}

/* Enhanced active state styles */
.nav-link-active {
  background-color: #1F2937; /* gray-800 */
  border-left: 4px solid #3B82F6; /* blue-500 border indicator */
  color: #FFFFFF !important;
  font-weight: 600;
  padding-left: calc(0.75rem - 4px); /* Adjust padding to account for border */
}

.nav-link-inactive {
  color: #9CA3AF; /* gray-400 */
  border-left: 4px solid transparent;
  padding-left: 0.75rem;
}

.nav-link-inactive:hover {
  color: #FFFFFF;
  background-color: #374151; /* gray-700 */
}

/* Smooth transitions for nav links */
.nav-link-active,
.nav-link-inactive {
  transition: all 0.2s ease-in-out;
}

/* ============================================
   MOBILE RESPONSIVE TABLE CARDS
   ============================================ */

/* Mobile card layout for tables */
@media (max-width: 767px) {
  /* Hide table structure on mobile */
  .mobile-cards table,
  .mobile-cards thead,
  .mobile-cards tbody,
  .mobile-cards th,
  .mobile-cards td,
  .mobile-cards tr {
    display: block;
  }

  /* Hide table headers on mobile */
  .mobile-cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Card styling for each row */
  .mobile-cards tbody tr {
    background: rgb(55, 65, 81); /* gray-700 */
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid rgb(75, 85, 99); /* gray-600 */
  }

  .mobile-cards tbody tr:hover {
    background: rgb(75, 85, 99); /* gray-600 */
  }

  /* Remove default table cell styling */
  .mobile-cards td {
    padding: 0.375rem 0;
    border: none;
    text-align: left;
  }

  /* Data label styling */
  .mobile-cards td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgb(156, 163, 175); /* gray-400 */
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.25rem;
  }

  /* Flex row for inline label:value pairs */
  .mobile-cards td.mobile-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .mobile-cards td.mobile-inline::before {
    display: inline;
    margin-bottom: 0;
    margin-right: 0.5rem;
  }

  /* Hide columns marked for mobile-hide */
  .mobile-cards .mobile-hide {
    display: none !important;
  }

  /* Actions row at bottom of card */
  .mobile-cards td.mobile-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgb(75, 85, 99); /* gray-600 */
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .mobile-cards td.mobile-actions::before {
    display: none;
  }

  /* Primary info styling (larger, bolder) */
  .mobile-cards .mobile-primary {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.25rem;
  }

  .mobile-cards .mobile-primary::before {
    display: none;
  }

  /* Secondary info (smaller, muted) */
  .mobile-cards .mobile-secondary {
    font-size: 0.875rem;
    color: rgb(156, 163, 175); /* gray-400 */
  }

  .mobile-cards .mobile-secondary::before {
    display: none;
  }

  /* Status badges in cards */
  .mobile-cards .mobile-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
  }
}

/* Horizontal scroll indicator for remaining overflow tables */
.scroll-indicator {
  position: relative;
}

.scroll-indicator::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 2rem;
  background: linear-gradient(to right, transparent, rgb(17, 24, 39));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.scroll-indicator.has-overflow::after {
  opacity: 1;
}

/* Collapsible filter panel for mobile */
@media (max-width: 767px) {
  .mobile-filters-collapsed {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease-in-out, opacity 0.2s ease-in-out;
  }

  .mobile-filters-collapsed.expanded {
    max-height: 1000px;
    opacity: 1;
  }

  /* Stack filter inputs vertically */
  .mobile-filters-collapsed .flex-wrap {
    flex-direction: column;
  }

  .mobile-filters-collapsed .flex-wrap > * {
    width: 100%;
    min-width: 100%;
  }
}

/* Page header responsive adjustments */
@media (max-width: 767px) {
  .page-header-responsive {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .page-header-responsive h1,
  .page-header-responsive h2 {
    font-size: 1.5rem;
  }

  .page-header-responsive .header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .page-header-responsive .header-actions > * {
    flex: 1;
    min-width: 0;
    text-align: center;
  }
}

/* Touch-friendly button sizes */
@media (max-width: 767px) {
  .touch-target {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ============================================
   NAVIGATION SECTION HEADERS & SUB-GROUPS
   ============================================ */

/* Section headers in navigation */
.nav-section-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9CA3AF; /* gray-400 */
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  margin-top: 0.5rem;
}

/* Sub-group styling within admin sections */
.nav-sub-group {
  margin-bottom: 0.5rem;
}

.nav-sub-group button {
  transition: all 0.15s ease-in-out;
}

.nav-sub-group button:hover {
  color: #FFFFFF;
}

.nav-sub-group button i {
  transition: transform 0.2s ease-in-out;
}

/* Sub-group icon rotation animation */
.nav-sub-group button i.fa-chevron-right {
  transform: rotate(0deg);
}

.nav-sub-group button i.fa-chevron-down {
  transform: rotate(0deg);
}

/* Smooth expand/collapse for sub-groups */
.nav-sub-group [data-sidebar-target$="Links"] {
  transition: max-height 0.3s ease-in-out, opacity 0.2s ease-in-out;
  overflow: hidden;
}

.nav-sub-group [data-sidebar-target$="Links"].hidden {
  max-height: 0;
  opacity: 0;
}

.nav-sub-group [data-sidebar-target$="Links"]:not(.hidden) {
  max-height: 500px; /* Reasonable max height for transitions */
  opacity: 1;
}

/* ============================================
   BREADCRUMB NAVIGATION STYLES
   ============================================ */

/* Breadcrumb container */
nav[aria-label="Breadcrumb"] {
  margin-bottom: 0.75rem;
}

/* Breadcrumb list */
nav[aria-label="Breadcrumb"] ol {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.875rem;
}

/* Breadcrumb items */
nav[aria-label="Breadcrumb"] li {
  display: flex;
  align-items: center;
}

/* Breadcrumb links */
nav[aria-label="Breadcrumb"] a {
  color: #60A5FA; /* blue-400 */
  text-decoration: none;
  transition: color 0.2s ease-in-out;
}

nav[aria-label="Breadcrumb"] a:hover {
  color: #93C5FD; /* blue-300 */
  text-decoration: underline;
}

/* Current page (last breadcrumb) */
nav[aria-label="Breadcrumb"] span[aria-current="page"] {
  color: #9CA3AF; /* gray-400 */
  font-weight: 500;
}

/* Breadcrumb separators */
nav[aria-label="Breadcrumb"] li[aria-hidden="true"] {
  color: #6B7280; /* gray-600 */
  user-select: none;
}

/* Responsive breadcrumbs - truncate on mobile */
@media (max-width: 767px) {
  nav[aria-label="Breadcrumb"] ol {
    font-size: 0.75rem;
  }

  nav[aria-label="Breadcrumb"] span,
  nav[aria-label="Breadcrumb"] a span {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
  }
}

/* Tailwind is fighting me relentlessly, so I'm just going the old school method */
/* Force all challenge cards to equal height */
.category-content .grid > a {
  display: flex;
  height: 100%;
  width: 100%;  
}

.category-content .grid > a > div {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

/* Chat Message */
#chat-container {
  display: flex;
  flex-direction: column;
  height: 100%; /* Use full height of parent container */
  width: 100%; /* Instead of 100vw */
  overflow: hidden; /* Prevents rogue elements from causing a horizontal scroll */
}

#chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden; /* Hides horizontal scrolling */
  word-wrap: break-word; /* Prevents long text from breaking layout */
  white-space: normal; /* Stops preformatted text from causing overflow */
  max-width: 100%;
  padding-bottom: 1rem; /* Adds spacing for input */
  /* Enhanced typography for extended reading */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 0.9375rem; /* 15px - optimal for readability */
  line-height: 1.7; /* Better line spacing for scanning */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.animate-slide-in {
  animation: slide-in 0.3s ease-out;
}

/* Fix EasyMDE Toolbar Icons */
.editor-toolbar button {
  background: transparent !important; /* Remove ugly button bg */
  border: none !important;
  padding: 6px 8px !important;
  transition: background 0.2s ease-in-out;
}

.editor-toolbar button:hover {
  background: rgba(255, 255, 255, 0.1) !important; /* Subtle highlight */
  border-radius: 4px; /* Softer rounded corners */
}

/* Fix EasyMDE Tooltip */
.editor-tooltip {
  background: #1E293B !important; /* Darker tooltip */
  color: #F8FAFC !important; /* Brighter text */
  border-radius: 6px !important;
  padding: 6px 10px !important;
  font-size: 0.875rem !important; /* text-sm */
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.3) !important;
}

/* Ensure tooltip arrow looks good */
.editor-tooltip::after {
  border-top-color: #1E293B !important;
}

/* Match EasyMDE Editor Background to Form Fields */
.EasyMDEContainer .CodeMirror,
.EasyMDEContainer .CodeMirror-scroll {
  background-color: #1F2937 !important; /* Tailwind gray-800 */
  color: #F8FAFC !important; /* Tailwind gray-100 (lighter text) */
}

/* Ensure Editor Text Contrast is Good */
.EasyMDEContainer .CodeMirror pre {
  color: #E5E7EB !important; /* Tailwind gray-300 */
}

/* Match Placeholder Text */
.EasyMDEContainer .CodeMirror-placeholder {
  color: #9CA3AF !important; /* Tailwind gray-400 */
}

/* Border + Focus Ring Similar to Other Inputs */
.EasyMDEContainer .CodeMirror {
  border: 1px solid #374151 !important; /* Tailwind gray-700 */
  border-radius: 6px !important;
}

.EasyMDEContainer .CodeMirror-focused {
  border-color: #3B82F6 !important; /* Tailwind blue-500 */
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.4) !important;
}

/* Enhanced Content Editor Styling */
/* Rules Editor - Amber focus ring */
.content-editor.rules-editor .EasyMDEContainer .CodeMirror-focused {
  border-color: #F59E0B !important; /* Tailwind amber-500 */
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.3) !important;
}

/* Landing Content Editor - Green focus ring */
.content-editor.landing-editor .EasyMDEContainer .CodeMirror-focused {
  border-color: #10B981 !important; /* Tailwind green-500 */
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.3) !important;
}

/* Enhanced Editor Container Styling */
.content-editor-container {
  position: relative;
  transition: all 0.2s ease-in-out;
}

.content-editor-container:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* Editor Toolbar Enhancement */
.content-editor .editor-toolbar {
  background: #374151 !important; /* Tailwind gray-700 */
  border-bottom: 1px solid #4B5563 !important; /* Tailwind gray-600 */
  border-radius: 8px 8px 0 0 !important;
}

.content-editor .editor-toolbar button.active {
  background: rgba(59, 130, 246, 0.3) !important; /* Blue highlight for active tools */
  color: #3B82F6 !important; /* Blue text for active state */
}

/* Hide unwanted EasyMDE UI elements */
.EasyMDEContainer .editor-preview-side,
.EasyMDEContainer .editor-preview-active-side {
  display: none !important; /* Hide side-by-side preview pane */
}

/* Hide status bar */
.EasyMDEContainer .editor-statusbar {
  display: none !important;
}

/* Hide any close/x buttons and unwanted characters in the editor */
.EasyMDEContainer .editor-toolbar .fa-times,
.EasyMDEContainer .editor-toolbar button[title*="close"],
.EasyMDEContainer .editor-toolbar button[title*="Close"] {
  display: none !important;
}

/* Hide any stray x characters or close buttons */
.EasyMDEContainer .CodeMirror-code .cm-overlay {
  display: none !important;
}

/* Hide the side-by-side toggle button completely */
.EasyMDEContainer .editor-toolbar .fa-columns,
.EasyMDEContainer .editor-toolbar button[title*="Side by Side"] {
  display: none !important;
}

/* Hide all preview elements - no preview functionality */
.EasyMDEContainer .editor-preview-side,
.EasyMDEContainer .editor-preview-active-side,
.EasyMDEContainer .editor-preview {
  display: none !important;
}

/* Hide any stray characters or cursors at top-left */
.EasyMDEContainer .CodeMirror-cursor {
  border-left-color: #F8FAFC !important; /* Match text color for normal cursor */
}

/* Allow CodeMirror to handle cursor naturally */
.EasyMDEContainer .CodeMirror-cursor {
  visibility: visible !important;
  border-left: 1px solid #F8FAFC !important; /* Default cursor color */
  opacity: 1 !important;
  position: absolute !important; /* Let CodeMirror position it */
}

/* Enhanced cursor when focused */
.EasyMDEContainer .CodeMirror-focused .CodeMirror-cursor {
  border-left: 2px solid #3B82F6 !important; /* Blue cursor when focused */
}

/* Remove our custom blinking - let CodeMirror handle it */
.EasyMDEContainer .CodeMirror-cursor {
  animation: none !important; /* Remove custom animation */
}

/* Remove any text content from cursor elements */
.EasyMDEContainer .CodeMirror-cursor::before,
.EasyMDEContainer .CodeMirror-cursor::after {
  content: none !important;
  display: none !important;
}

/* Hide any nbsp or whitespace content in cursor elements, but not the cursor itself */
.EasyMDEContainer .CodeMirror-cursors span:not(.CodeMirror-cursor) {
  display: none !important;
}

/* Don't hide content inside cursor elements - let CodeMirror manage it */
.EasyMDEContainer .CodeMirror-cursor {
  display: block !important;
  visibility: visible !important;
}

/* Ensure cursor container is visible */
.EasyMDEContainer .CodeMirror-cursors {
  visibility: visible !important;
  display: block !important;
}

/* Fix text selection highlighting with better contrast */
.EasyMDEContainer .CodeMirror-selected {
  background: rgba(59, 130, 246, 0.3) !important; /* Semi-transparent blue */
  color: inherit !important; /* Keep original text color */
}

.EasyMDEContainer .CodeMirror-line::selection,
.EasyMDEContainer .CodeMirror-line > span::selection,
.EasyMDEContainer .CodeMirror-line > span > span::selection {
  background: rgba(59, 130, 246, 0.4) !important; /* Semi-transparent blue */
  color: inherit !important; /* Keep original text color for readability */
}

.EasyMDEContainer .CodeMirror-line::-moz-selection,
.EasyMDEContainer .CodeMirror-line > span::-moz-selection,
.EasyMDEContainer .CodeMirror-line > span > span::-moz-selection {
  background: rgba(59, 130, 246, 0.4) !important; /* Semi-transparent blue for Firefox */
  color: inherit !important;
}

/* Ensure selection is visible when focused */
.EasyMDEContainer .CodeMirror-focused .CodeMirror-selected {
  background: rgba(37, 99, 235, 0.4) !important; /* Slightly more opaque when focused */
}

/* Remove horizontal scrollbar */
.EasyMDEContainer .CodeMirror-scroll {
  overflow-x: hidden !important; /* Hide horizontal scroll */
  overflow-y: auto !important; /* Keep vertical scroll */
}

.EasyMDEContainer .CodeMirror {
  overflow: hidden !important; /* Prevent any overflow scrollbars */
}

/* Ensure text wraps instead of horizontal scrolling */
.EasyMDEContainer .CodeMirror pre {
  word-wrap: break-word !important;
  white-space: pre-wrap !important;
  overflow-wrap: break-word !important;
}

/* Hide any overlay elements that might show x or other characters */
.EasyMDEContainer .CodeMirror-lines::before,
.EasyMDEContainer .CodeMirror-lines::after {
  content: none !important;
  display: none !important;
}

/* Ensure fullscreen mode doesn't show unwanted elements */
.EasyMDEContainer.editor-fullscreen .editor-preview-side,
.EasyMDEContainer.editor-fullscreen .editor-statusbar {
  display: none !important;
}

/* Clean up any placeholder or watermark text */
.EasyMDEContainer .CodeMirror-placeholder {
  opacity: 0.6 !important;
  color: #9CA3AF !important;
}

/* Clean up any leftover side-by-side elements */
.EasyMDEContainer .CodeMirror-sided {
  width: 100% !important;
}

/* Final cleanup - hide any remaining unwanted elements */
.EasyMDEContainer .editor-preview-side,
.EasyMDEContainer .editor-preview-active-side,
.EasyMDEContainer .CodeMirror-sided .CodeMirror-sizer,
.EasyMDEContainer .CodeMirror-sided .CodeMirror-gutters {
  display: none !important;
}

/* Ensure single editor view only */
.EasyMDEContainer.editor-preview-active .editor-preview {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  position: absolute !important;
  top: 37px !important; /* Account for toolbar height */
  left: 0 !important;
  background: #1F2937 !important;
  border: 1px solid #374151 !important;
  border-top: none !important;
  border-radius: 0 0 8px 8px !important;
  z-index: 9 !important;
}

/* Hide editor content when in preview mode */
.EasyMDEContainer.editor-preview-active .CodeMirror {
  display: none !important;
}

/* Hide CodeMirror line-like elements with X characters */
.EasyMDEContainer .CodeMirror-line-like,
.EasyMDEContainer .CodeMirror-measure,
.EasyMDEContainer .CodeMirror-measure pre {
  display: none !important;
}

/* Hide any empty line elements that create spacing */
.EasyMDEContainer .CodeMirror-lines .CodeMirror-line:empty,
.EasyMDEContainer .CodeMirror-lines .CodeMirror-line-like:empty {
  display: none !important;
}

/* Remove top padding and margin that creates empty space */
.EasyMDEContainer .CodeMirror-lines {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

.EasyMDEContainer .CodeMirror-scroll {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

/* Ensure first line starts immediately */
.EasyMDEContainer .CodeMirror-sizer {
  padding-top: 0 !important;
  margin-top: 0 !important;
  border-right-width: 0 !important; /* Remove right border white space */
}

/* Hide any measuring elements that might contain X's */
.EasyMDEContainer .CodeMirror-linewidget,
.EasyMDEContainer .CodeMirror-widget {
  display: none !important;
}

/* Clean up any artifacts in the editor */
.EasyMDEContainer .CodeMirror-lines > div > div:first-child {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

/* Ensure editor takes full width when not in side-by-side mode */
.EasyMDEContainer .editor-preview-active {
  width: 100% !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  background: #1F2937 !important; /* Match our dark theme */
  color: #F8FAFC !important;
  padding: 1rem !important;
  border-radius: 0 0 8px 8px !important;
  z-index: 10 !important;
}

/* PAGINATION STYLES */
/* Ensure the nav container aligns correctly */
.pagy.nav {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  background-color: #1f2937; /* Tailwind gray-800 */
  padding: 10px 16px;
  border-radius: 8px;
  flex-wrap: wrap;
  max-width: 100%;
}

/* Mobile pagination - more compact */
@media (max-width: 767px) {
  .pagy.nav {
    gap: 4px;
    padding: 8px 12px;
  }

  .pagy.nav a {
    padding: 6px 10px;
    font-size: 0.875rem;
  }

  /* Hide page numbers except current, first, last on mobile */
  .pagy.nav a:not(.current):not([aria-label="Previous"]):not([aria-label="Next"]):not(.gap):not(:first-child):not(:last-child) {
    display: none;
  }

  /* But show the current page and immediate neighbors */
  .pagy.nav a.current,
  .pagy.nav a.current + a,
  .pagy.nav a:has(+ a.current) {
    display: inline-block;
  }
}

/* Style page links */
.pagy.nav a {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 6px;
  background-color: #374151; /* Tailwind gray-700 */
  color: #d1d5db; /* Tailwind gray-300 */
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

/* Hover effect */
.pagy.nav a:hover {
  background-color: #4b5563; /* Tailwind gray-600 */
  color: #ffffff;
}

/* Active page */
.pagy.nav a.current {
  background-color: #2563eb; /* Tailwind blue-600 */
  color: #ffffff;
  font-weight: bold;
  pointer-events: none;
}

/* Disabled gap dots */
.pagy.nav a.gap {
  background: transparent;
  color: #9ca3af; /* Tailwind gray-400 */
  cursor: default;
  padding: 8px 12px;
}

/* Previous & Next Buttons */
.pagy.nav a[aria-label="Previous"],
.pagy.nav a[aria-label="Next"] {
  padding: 8px 14px;
  border-radius: 6px;
  background-color: #1f2937; /* Tailwind gray-800 */
  color: #ffffff;
  text-decoration: none;
}

.pagy.nav a[aria-label="Previous"]:hover,
.pagy.nav a[aria-label="Next"]:hover {
  background-color: #374151; /* Tailwind gray-700 */
}


.animate-bounce {
    animation: bounce 1s infinite;
    font-size: 3rem;
}

@keyframes bounce {
    0%, 100% {
	transform: translateY(0);
    }
    50% {
	transform: translateY(-20px);
    }
}

/* Markdown Heading Sizing */
.markdown h1,
.tater-markdown h1 {
  font-size: 2.5rem; /* ~40px */
  font-weight: bold;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.markdown h2,
.tater-markdown h2 {
  font-size: 2rem; /* ~32px */
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 1rem;
}

.markdown h3,
.tater-markdown h3 {
  font-size: 1.5rem; /* ~24px */
  font-weight: 500;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.markdown h4,
.tater-markdown h4 {
  font-size: 1.25rem; /* ~20px */
  font-weight: 500;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.markdown h5,
.tater-markdown h5 {
  font-size: 1.125rem; /* ~18px */
  font-weight: 500;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.markdown h6,
.tater-markdown h6 {
  font-size: 1rem; /* ~16px */
  font-weight: 500;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}


/* Default Markdown */
.markdown {
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  font-size: 0.9375rem; /* 15px - optimal for readability */
  color: #d1d5db; /* Tailwind gray-300 */
  line-height: 1.7; /* Better line spacing for scanning */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headings */
.markdown h1 {
  text-align: center;
  color: #f3f4f6; /* Tailwind gray-100 */
}

.markdown h2 {
  color: #e5e7eb; /* Tailwind gray-200 */
}

.markdown h3 {
  color: #d1d5db; /* Tailwind gray-300 */
}

/* Paragraphs */
.markdown p {
  margin-bottom: 1rem;
}

/* Lists */
.markdown ul,
.markdown ol {
  padding-left: 1.5rem;
  margin: 1rem 0;
}

.markdown ol {
  list-style-type: decimal;
}

.markdown ul {
  list-style-type: disc;
}

/* Inline Code */
.markdown code {
  background-color: #374151; /* Tailwind gray-700 */
  color: #86efac; /* Tailwind green-300 */
  padding: 0.2em 0.4em;
  border-radius: 0.25rem;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.8125rem; /* 13px */
}

/* Code Blocks */
.markdown pre {
  background-color: #374151; /* Tailwind gray-700 */
  color: #f3f4f6; /* Tailwind gray-100 */
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.8125rem; /* 13px */
  line-height: 1.5;
  margin-bottom: 1rem;
  white-space: pre-wrap;
}

/* Links */
.markdown a {
  color: #38bdf8; /* Tailwind cyan-400 */
  font-weight: 600;
  text-decoration: underline;
  transition: color 0.2s ease-in-out;
}

.markdown a:hover {
  color: #fbbf24; /* Tailwind amber-400 */
  text-decoration: none;
}

/* Blockquotes */
.markdown blockquote {
  border-left: 4px solid #4b5563; /* Tailwind gray-600 */
  padding-left: 1rem;
  margin: 1rem 0;
  color: #9ca3af; /* Tailwind gray-400 */
  font-style: italic;
}

/* Horizontal Rule */
.markdown hr {
  border-top: 1px solid #4b5563; /* Tailwind gray-600 */
  margin: 2rem 0;
}

/* Footnotes */
.markdown .footnotes {
  font-size: 0.875rem;
  color: #9ca3af; /* gray-400 */
  border-top: 1px solid #374151; /* gray-700 */
  margin-top: 2rem;
  padding-top: 1rem;
}

.markdown .footnotes ol {
  padding-left: 1rem;
}

.markdown .footnotes li {
  margin-bottom: 0.5rem;
}

.markdown sup {
  font-size: 0.75rem;
  vertical-align: super;
  line-height: 0;
}

/* Tables */
.markdown table,
.markdown .markdown-table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  background-color: transparent;
}

.markdown table th,
.markdown .markdown-table th {
  background-color: #374151; /* Tailwind gray-700 */
  color: #f3f4f6; /* Tailwind gray-100 */
  font-weight: 600;
  padding: 0.75rem;
  text-align: left;
  border: 1px solid #4b5563; /* Tailwind gray-600 */
}

.markdown table td,
.markdown .markdown-table td {
  padding: 0.75rem;
  border: 1px solid #4b5563; /* Tailwind gray-600 */
  color: #e5e7eb; /* Tailwind gray-200 */
}

.markdown table tr:nth-child(even),
.markdown .markdown-table tbody tr:nth-child(even) {
  background-color: #1f2937; /* Tailwind gray-800 */
}

.markdown table tr:hover,
.markdown .markdown-table tbody tr:hover {
  background-color: #374151; /* Tailwind gray-700 */
}


/* Tater Markdown */
.tater-markdown {
  line-height: 1.5;
  font-size: 1rem;
  color: #111827; /* Tailwind gray-900 */
  word-break: break-word;
  font-family: system-ui, sans-serif;
}

.tater-markdown h1,
.tater-markdown h2,
.tater-markdown h3,
.tater-markdown h4,
.tater-markdown h5,
.tater-markdown h6 {    
  color: #374151; /* Tailwind gray-700 */
  margin-bottom: 0.5rem;
  margin-top: 1.25rem;
}

.tater-markdown p {
  margin: 0.75rem 0;
}

.tater-markdown ul,
.tater-markdown ol {
  padding-left: 1.5rem;
  margin: 0.75rem 0;
  color: #111827; /* Tailwind gray-900 */
}

.tater-markdown ul:not(:first-child),
.tater-markdown ol:not(:first-child) {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.tater-markdown ul ul,
.tater-markdown ol ol {
  margin: 0.25rem 0;
}

.tater-markdown ol {
  list-style-type: decimal;
}

.tater-markdown ul {
  list-style-type: disc;
}

.tater-markdown li {
  margin: 0.5rem 0;
}

.tater-markdown pre {
  background-color: #1f2937; /* Tailwind gray-800 */
  color: #f3f4f6; /* Tailwind gray-100 */
  padding: 0.75rem;
  border-radius: 0.375rem;
  overflow: auto;
  font-size: 0.875rem;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  letter-spacing: -0.015em;
  line-height: 1.5;
  margin: 0.75rem 0;
  white-space: pre-wrap; /* Re-added here for pre specifically */
}

.tater-markdown code {
  background-color: #1f2937; /* Tailwind gray-800 */
  color: #86efac; /* Tailwind green-300 */
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  letter-spacing: -0.015em;
}

.tater-markdown a {
  color: #06b6d4; /* Tailwind cyan-400 */
  text-decoration: underline;
  transition: color 0.2s ease-in-out;
}

.tater-markdown a:hover {
  color: #fbbf24; /* Tailwind amber-400 */
  text-decoration: none;
}

.tater-markdown blockquote {
  border-left: 4px solid #6b7280; /* Tailwind gray-500 */
  padding-left: 0.75rem;
  color: #6b7280; /* Tailwind gray-500 */
  font-style: italic;
  margin: 0.75rem 0;
}

.tater-markdown .footnotes {
  font-size: 0.875rem; /* text-sm */
  color: #4b5563; /* Tailwind gray-600 */
  border-top: 1px solid #e5e7eb; /* Tailwind gray-200 */
  margin-top: 1.5rem;
  padding-top: 1rem;
}

.tater-markdown .footnotes ol {
  padding-left: 1rem;
}

.tater-markdown .footnotes li {
  margin-bottom: 0.5rem;
}

.tater-markdown sup {
  font-size: 0.75rem;
  vertical-align: super;
  line-height: 0;
}

/* Tater Tables */
.tater-markdown table,
.tater-markdown .markdown-table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75rem 0;
  background-color: transparent;
}

.tater-markdown table th,
.tater-markdown .markdown-table th {
  background-color: #e5e7eb; /* Tailwind gray-200 */
  color: #111827; /* Tailwind gray-900 */
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  text-align: left;
  border: 1px solid #d1d5db; /* Tailwind gray-300 */
}

.tater-markdown table td,
.tater-markdown .markdown-table td {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db; /* Tailwind gray-300 */
  color: #111827; /* Tailwind gray-900 */
}

.tater-markdown table tr:nth-child(even),
.tater-markdown .markdown-table tbody tr:nth-child(even) {
  background-color: #f9fafb; /* Tailwind gray-50 */
}

/* Tater LaTeX Styling */
.tater-markdown .katex-display {
  margin: 0.75rem 0;
  text-align: center;
}

.tater-markdown .katex {
  color: #111827; /* Tailwind gray-900 - dark text for light theme */
  font-size: 1.1em;
}

/* Clean Markdown */
.clean-markdown {
  max-width: 100%;
  color: #1f2937; /* Tailwind gray-800 */
  font-size: 1rem;
  line-height: 1.75rem;
  word-break: break-word;
}

.clean-markdown h1,
.clean-markdown h2,
.clean-markdown h3 {
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 1rem;
  line-height: 1.25;
  color: #111827; /* Tailwind gray-900 */
}

.clean-markdown h1 {
  font-size: 2rem;
  border-bottom: 1px solid #e5e7eb; /* Tailwind gray-200 */
  padding-bottom: 0.5rem;
}

.clean-markdown h2 {
  font-size: 1.5rem;
}

.clean-markdown h3 {
  font-size: 1.25rem;
}

.clean-markdown p {
  margin-bottom: 1rem;
}

.clean-markdown ul,
.clean-markdown ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.clean-markdown ul {
  list-style-type: disc;
}

.clean-markdown ol {
  list-style-type: decimal;
}

.clean-markdown a {
  color: #2563eb; /* Tailwind blue-600 */
  font-weight: 500;
  text-decoration: underline;
}

.clean-markdown a:hover {
  color: #1d4ed8; /* Tailwind blue-700 */
}

.clean-markdown blockquote {
  margin: 1rem 0;
  padding-left: 1rem;
  border-left: 4px solid #e5e7eb; /* gray-200 */
  color: #6b7280; /* gray-500 */
  font-style: italic;
}

.clean-markdown code {
  background-color: #f3f4f6; /* gray-100 */
  color: #111827;
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.875rem;
}

.clean-markdown pre {
  background-color: #f3f4f6;
  padding: 1rem;
  overflow-x: auto;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

/* Clean Tables */
.clean-markdown table,
.clean-markdown .markdown-table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  background-color: transparent;
}

.clean-markdown table th,
.clean-markdown .markdown-table th {
  background-color: #f3f4f6; /* Tailwind gray-100 */
  color: #111827; /* Tailwind gray-900 */
  font-weight: 600;
  padding: 0.75rem;
  text-align: left;
  border: 1px solid #d1d5db; /* Tailwind gray-300 */
}

.clean-markdown table td,
.clean-markdown .markdown-table td {
  padding: 0.75rem;
  border: 1px solid #d1d5db; /* Tailwind gray-300 */
  color: #111827; /* Tailwind gray-900 */
}

.clean-markdown table tr:nth-child(even),
.clean-markdown .markdown-table tbody tr:nth-child(even) {
  background-color: #f9fafb; /* Tailwind gray-50 */
}

/* Clean LaTeX Styling */
.clean-markdown .katex-display {
  margin: 1rem 0;
  text-align: center;
}

.clean-markdown .katex {
  color: #111827; /* Tailwind gray-900 - dark text for light theme */
  font-size: 1.1em;
}

/* LaTeX/KaTeX Styling */
.markdown .katex-display {
  margin: 1rem 0;
  text-align: center;
}

.markdown .katex {
  color: #e5e7eb; /* Tailwind gray-200 - light text for dark theme */
  font-size: 1.1em;
}

.markdown .katex-display .katex {
  font-size: 1.2em;
}

/* LaTeX error and fallback styling */
.latex-error {
  color: #ef4444 !important; /* Tailwind red-500 */
  background-color: #1f2937; /* Tailwind gray-800 */
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #ef4444;
}

.latex-fallback {
  background-color: #374151 !important; /* Tailwind gray-700 */
  color: #d1d5db !important; /* Tailwind gray-300 */
  padding: 2px 6px !important;
  border-radius: 4px !important;
  border: 1px solid #4b5563; /* Tailwind gray-600 */
}

/* Server-side LaTeX placeholders (will be processed by KaTeX on client) */
.katex-display-server,
.katex-inline-server {
  font-family: monospace;
  background-color: #374151; /* Tailwind gray-700 */
  color: #d1d5db; /* Tailwind gray-300 */
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #4b5563; /* Tailwind gray-600 */
}

.katex-display-server {
  display: block;
  text-align: center;
  margin: 1rem 0;
}

/* List indentation classes for nested lists */
.markdown li.indent-1,
.tater-markdown li.indent-1,
.clean-markdown li.indent-1 {
  margin-left: 1.5rem; /* 24px */
}

.markdown li.indent-2,
.tater-markdown li.indent-2,
.clean-markdown li.indent-2 {
  margin-left: 3rem; /* 48px */
}

.markdown li.indent-3,
.tater-markdown li.indent-3,
.clean-markdown li.indent-3 {
  margin-left: 4.5rem; /* 72px */
}

.markdown li.indent-4,
.tater-markdown li.indent-4,
.clean-markdown li.indent-4 {
  margin-left: 6rem; /* 96px */
}

/* ============================================
   SEARCH MODAL STYLES
   ============================================ */

/* Search modal backdrop */
.search-modal {
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-in-out;
}

.search-backdrop {
  animation: fadeIn 0.3s ease-in-out;
}

/* Search container animation */
.search-container {
  animation: slideDown 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* Search input focus ring */
#global-search-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* Search results scrollbar styling */
.search-results::-webkit-scrollbar {
  width: 8px;
}

.search-results::-webkit-scrollbar-track {
  background: #1F2937; /* gray-800 */
}

.search-results::-webkit-scrollbar-thumb {
  background: #4B5563; /* gray-600 */
  border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
  background: #6B7280; /* gray-500 */
}

/* Search result item hover effect */
.search-result-item {
  transition: all 0.15s ease-in-out;
}

.search-result-item:hover {
  transform: translateX(4px);
}

/* Search result highlight mark */
.search-results mark {
  padding: 1px 3px;
  border-radius: 2px;
}

/* Keyboard shortcuts hint positioning */
#search-hint {
  animation: slideInFromRight 0.5s ease-out 1s both;
}

@keyframes slideInFromRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Hide search hint after 10 seconds */
#search-hint {
  animation: slideInFromRight 0.5s ease-out 1s both, fadeOut 0.5s ease-out 10s forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    pointer-events: none;
  }
}

/* ============================================
   NOTIFICATION BADGE STYLES
   ============================================ */

/* Notification badge base styling */
.notification-badge {
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  transition: all 0.2s ease-in-out;
}

/* Badge animation on appearance */
@keyframes badgePulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/* Pulse animation for urgent badges */
.notification-badge[aria-label*="notification"]:not([aria-label="0 notifications"]) {
  animation: badgePulse 2s ease-in-out infinite;
}

/* Badge positioning in nav links */
.nav-link-text {
  flex: 1;
  min-width: 0;
}

/* Ensure badges align properly */
nav a:has(.notification-badge) {
  justify-content: space-between;
}

/* ============================================
   KEYBOARD SHORTCUTS MODAL
   ============================================ */

/* Keyboard shortcut keys */
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.375rem 0.5rem;
  background-color: #374151; /* gray-700 */
  border: 1px solid #4B5563; /* gray-600 */
  border-radius: 0.375rem;
  color: #D1D5DB; /* gray-300 */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  display: inline-block;
  white-space: nowrap;
}

/* Keyboard shortcuts modal animations */
#keyboard-shortcuts-modal {
  animation: fadeIn 0.2s ease-in-out;
}

#keyboard-shortcuts-modal > div:last-child {
  animation: slideDown 0.3s ease-out;
}

/* ============================================
   QUICK CREATE MENU ENHANCEMENTS
   ============================================ */

/* Quick create button active state */
.quick-create-button:active {
  transform: scale(0.95);
}

/* Quick create menu item icons */
.quick-create-menu-item i {
  transition: transform 0.2s ease-in-out;
}

.quick-create-menu-item:hover i {
  transform: scale(1.1);
}

/* ============================================
   RESPONSIVE ADJUSTMENTS FOR PHASE 3
   ============================================ */

/* Hide search text on mobile */
@media (max-width: 1023px) {
  #search-hint {
    display: none;
  }
}

/* Adjust search modal on mobile */
@media (max-width: 767px) {
  .search-container {
    max-width: 100%;
    margin: 0 1rem;
  }

  .search-results {
    max-height: 70vh;
  }
}

/* ============================================
   TAB NAVIGATION STYLES (PHASE 4)
   ============================================ */

/* Tab buttons */
.tab-active,
.tab-inactive {
  position: relative;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

/* Active tab styling */
.tab-active {
  color: #3B82F6; /* blue-500 */
  border-bottom-color: #3B82F6; /* blue-500 */
  background-color: rgba(59, 130, 246, 0.1); /* subtle blue background */
}

/* Inactive tab styling */
.tab-inactive {
  color: #9CA3AF; /* gray-400 */
  border-bottom-color: transparent;
}

.tab-inactive:hover {
  color: #D1D5DB; /* gray-300 */
  background-color: rgba(255, 255, 255, 0.05);
}

/* Focus state for accessibility */
.tab-active:focus,
.tab-inactive:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
  border-radius: 0.25rem;
}

/* Tab count badge */
.tab-active .bg-gray-700,
.tab-inactive .bg-gray-700 {
  transition: background-color 0.2s ease-in-out;
}

.tab-active .bg-gray-700 {
  background-color: #3B82F6 !important; /* blue-500 */
  color: #FFFFFF !important;
}

/* Mobile tab dropdown */
@media (max-width: 767px) {
  .tab-active,
  .tab-inactive {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
  }
}

/* ============================================
   TABLET TOOLTIP ENHANCEMENTS (PHASE 4)
   ============================================ */

/* Tooltip container for icon-only sidebar on tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  /* Nav link wrapper for tooltip positioning */
  #sidebar a[href],
  #sidebar button {
    position: relative;
  }

  /* Tooltip on hover */
  #sidebar a[href]:hover::after,
  #sidebar button:hover::after {
    content: attr(data-tooltip);
    position: fixed;
    left: 5rem; /* Position next to icon sidebar (64px + 16px) */
    background-color: #1F2937; /* gray-800 */
    color: #FFFFFF;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease-in-out 0.3s forwards;
  }

  /* Tooltip arrow */
  #sidebar a[href]:hover::before,
  #sidebar button:hover::before {
    content: '';
    position: fixed;
    left: 4.75rem; /* Position arrow to point to icon */
    border-width: 0.375rem;
    border-style: solid;
    border-color: transparent #1F2937 transparent transparent;
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease-in-out 0.3s forwards;
  }

  /* Tooltip fade-in animation */
  @keyframes tooltipFadeIn {
    from {
      opacity: 0;
      transform: translateX(-4px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  /* Smooth icon sizing */
  #sidebar i.fas,
  #sidebar i.fa-solid {
    font-size: 1.25rem;
    transition: font-size 0.2s ease-in-out;
  }

  #sidebar:hover i.fas,
  #sidebar:hover i.fa-solid {
    font-size: 1rem;
  }
}

/* ============================================
   RECENT ITEMS SECTION STYLES (PHASE 4)
   ============================================ */

/* Recent items container */
[data-controller="recent-items"] {
  max-height: 300px;
  overflow-y: auto;
}

/* Recent items scrollbar styling */
[data-controller="recent-items"]::-webkit-scrollbar {
  width: 4px;
}

[data-controller="recent-items"]::-webkit-scrollbar-track {
  background: transparent;
}

[data-controller="recent-items"]::-webkit-scrollbar-thumb {
  background: #4B5563; /* gray-600 */
  border-radius: 2px;
}

[data-controller="recent-items"]::-webkit-scrollbar-thumb:hover {
  background: #6B7280; /* gray-500 */
}

/* Recent item link animation */
[data-recent-items-target="list"] a {
  transition: all 0.15s ease-in-out;
}

[data-recent-items-target="list"] a:hover {
  transform: translateX(2px);
}

/* Recent items empty state */
[data-recent-items-target="empty"] {
  opacity: 0.6;
}

/* ============================================
   SWIPE GESTURE VISUAL FEEDBACK (PHASE 4)
   ============================================ */

/* Smooth transitions for swipe gestures */
#sidebar {
  transition: transform 0.3s ease-out;
  will-change: transform;
}

/* Swipe in progress - disable transition for smooth tracking */
#sidebar[style*="transition: none"] {
  transition: none !important;
}

/* Mobile backdrop fade during swipe */
@media (max-width: 767px) {
  #sidebar-backdrop {
    transition: opacity 0.2s ease-in-out;
  }
}

/* ============================================
   MOBILE CHAT/ASSESSMENT PAGE STYLES
   ============================================ */

@media (max-width: 767px) {
  /* Transparent header bar on mobile */
  #chat-header {
    background-color: transparent !important;
    border-bottom: none !important;
    box-shadow: none !important;
  }

  /* Adjust chat container height on mobile (no breadcrumb = more space) */
  .assessment-chat-container {
    height: calc(100vh - 5rem) !important;
  }

  /* Align input area items to center on mobile for same y-level */
  .chat-input-row {
    align-items: center !important;
  }

  /* Constrain slideout panel widths on mobile */
  #model-sidebar,
  #conversation-sidebar,
  #prompts-sidebar {
    width: 85vw !important;
    max-width: 320px !important;
  }

  /* Truncate long text in slideout panels */
  #model-sidebar .truncate,
  #conversation-sidebar .truncate,
  #prompts-sidebar .truncate {
    max-width: 100% !important;
  }

  /* Ensure conversation list items fit on mobile */
  #conversation-sidebar a,
  #prompts-sidebar .prompt-item {
    word-break: break-word;
  }

  /* ============================================
     MOBILE MODAL FIXES
     ============================================ */

  /* Stack modal buttons on very narrow screens for better touch targets */
  [data-fork-target="modal"] .flex.justify-end.gap-2,
  [data-report-target="modal"] .flex.justify-end.gap-2,
  [data-submission-target="modal"] .flex.justify-end.gap-2,
  [data-chat-target="editModal"] .flex.justify-end.gap-2,
  [data-chat-target="rerunModal"] .flex.justify-end.gap-2,
  [data-chat-target="convertToWorkflowModal"] .flex.justify-end.gap-2 {
    flex-wrap: wrap;
  }

  [data-fork-target="modal"] .flex.justify-end.gap-2 button,
  [data-report-target="modal"] .flex.justify-end.gap-2 button,
  [data-submission-target="modal"] .flex.justify-end.gap-2 button,
  [data-chat-target="editModal"] .flex.justify-end.gap-2 button,
  [data-chat-target="rerunModal"] .flex.justify-end.gap-2 button,
  [data-chat-target="convertToWorkflowModal"] .flex.justify-end.gap-2 button {
    flex: 1 1 auto;
    min-width: 0;
  }
}

/* ============================================
   BENCHMARKS SECTION STYLES
   ============================================ */

/* Metric progress bar animations */
.benchmark-progress-bar {
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Score value highlight animation */
@keyframes scoreHighlight {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.benchmark-score-highlight {
  animation: scoreHighlight 0.3s ease-in-out;
}

/* Leaderboard row hover effect */
.benchmark-leaderboard-row {
  transition: all 0.2s ease-in-out;
}

.benchmark-leaderboard-row:hover {
  transform: translateX(4px);
}

/* Rank badge glow effect for top 3 */
.benchmark-rank-1 {
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
}

.benchmark-rank-2 {
  box-shadow: 0 0 15px rgba(156, 163, 175, 0.3);
}

.benchmark-rank-3 {
  box-shadow: 0 0 15px rgba(251, 146, 60, 0.3);
}

/* Collapsible section smooth transitions */
.benchmark-collapsible-content {
  transition: max-height 0.3s ease-in-out, opacity 0.2s ease-in-out;
  overflow: hidden;
}

.benchmark-collapsible-icon {
  transition: transform 0.2s ease-in-out;
}

/* File upload dropzone states */
.benchmark-dropzone {
  transition: all 0.2s ease-in-out;
}

.benchmark-dropzone.dragover {
  border-color: #6366f1; /* indigo-500 */
  background-color: rgba(99, 102, 241, 0.1);
  transform: scale(1.02);
}

/* Metric card hover effects */
.benchmark-metric-card {
  transition: all 0.2s ease-in-out;
}

.benchmark-metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Status badge pulse for processing state */
@keyframes processingPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.benchmark-status-processing {
  animation: processingPulse 1.5s ease-in-out infinite;
}

/* Responsive adjustments for benchmark tables */
@media (max-width: 767px) {
  .benchmark-table-responsive {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .benchmark-table-responsive table {
    min-width: 600px;
  }
}

/* Score color gradient backgrounds */
.benchmark-score-excellent {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(16, 185, 129, 0.05));
  border-color: rgba(34, 197, 94, 0.3);
}

.benchmark-score-good {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(20, 184, 166, 0.05));
  border-color: rgba(16, 185, 129, 0.3);
}

.benchmark-score-fair {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(234, 179, 8, 0.05));
  border-color: rgba(245, 158, 11, 0.3);
}

.benchmark-score-poor {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.1), rgba(239, 68, 68, 0.05));
  border-color: rgba(249, 115, 22, 0.3);
}

/* Subtle grid pattern for hero sections */
.benchmark-hero-pattern {
  background-image:
    linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}
