/*
  Search Page UI - shadcn/ui Design System
  Consistent styling with Study Mode, Ask the Message, and other shadcn-converted pages
*/

/* ========================================
   SHADCN DESIGN TOKENS IMPORT
   ======================================== */

@import './src/tailwind.css';

/* ========================================
   BASE PAGE STYLING
   ======================================== */

body {
  background: hsl(var(--background));
  min-height: 100vh;
  color: hsl(var(--foreground));
}

/* ========================================
   LAYOUT COMPONENTS
   ======================================== */

.search-container {
  min-height: 100vh;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}

/* Header styling */
.search-header {
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 1.25rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

@media (min-width: 768px) {
  .search-header {
    padding: 1.5rem 2rem;
  }
}

/* Search title */
.search-title {
  color: hsl(var(--foreground));
  font-weight: 700;
  text-align: center;
}

/* Main content area */
.search-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

@media (min-width: 768px) {
  .search-content {
    padding: 2rem 2rem;
  }
}

/* Results section */
.search-results-section {
  display: grid;
  gap: 1.5rem;
  margin-top: 2rem;
}

@media (min-width: 640px) {
  .search-results-section {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .search-results-section {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }
}

/* Footer / Pagination area */
.search-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 2rem 1rem;
}

/* ========================================
   FORM COMPONENTS
   ======================================== */

/* Search input container */
.search-input-container {
  position: relative;
  background: hsl(var(--background));
  border: 2px solid hsl(var(--input));
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
  margin-bottom: 1.25rem;
}

.search-input-container:focus-within {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
}

/* Search input */
.search-input {
  width: 100%;
  background: transparent;
  border: none;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  color: hsl(var(--foreground));
  outline: none;
}

.search-input::placeholder {
  color: hsl(var(--muted-foreground));
}

.search-input:focus {
  outline: none;
  box-shadow: none;
}

.search-input-container input {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

.search-input-container input:focus {
  outline: none !important;
  ring: none !important;
}

/* Search input wrapper (for icon integration) */
.search-input-wrapper {
  position: relative;
  max-width: 48rem;
  margin: 0 auto 1.5rem auto;
}

/* Search type toggle container */
.search-toggle-container {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: hsl(var(--muted));
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  margin-bottom: 1.25rem;
  max-width: 48rem;
  margin-left: auto;
  margin-right: auto;
}

/* Search toggle item */
.search-toggle-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.875rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: all 0.2s ease;
  background: hsl(var(--background));
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
}

.search-toggle-item:hover {
  background: hsl(var(--accent));
}

.search-toggle-item.active {
  background: hsl(var(--primary) / 0.1);
  border-color: hsl(var(--primary) / 0.3);
  color: hsl(var(--primary));
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: hsl(var(--muted));
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid hsl(var(--border));
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: hsl(var(--background));
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch.active {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

.toggle-switch.active::after {
  transform: translateX(20px);
}

/* Quick filter chips */
.quick-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: calc(var(--radius) * 1.5);
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.quick-filter-chip:hover {
  background: hsl(var(--accent));
  border-color: hsl(var(--border));
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.quick-filter-chip.active {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: 0 2px 8px hsl(var(--primary) / 0.35);
}

/* Quick filters container */
#quickFilters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

/* Filter inputs (for advanced filters modal) */
.filter-input {
  width: 100%;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  transition: all 0.2s ease;
}

.filter-input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
}

/* Filter select */
.filter-select {
  width: 100%;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  transition: all 0.2s ease;
  cursor: pointer;
}

.filter-select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
}

/* Topic filter checkboxes */
.topic-filter {
  width: 0.875rem;
  height: 0.875rem;
  accent-color: hsl(var(--primary));
  cursor: pointer;
}

#topicsContainer {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  #topicsContainer {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  #topicsContainer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Auto-complete dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.5rem;
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  z-index: 50;
  max-height: 300px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.15s ease;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

.autocomplete-item:hover {
  background: hsl(var(--accent));
}

.autocomplete-item:not(:last-child) {
  border-bottom: 1px solid hsl(var(--border));
}

/* ========================================
   CARD COMPONENTS (shadcn Card pattern)
   ======================================== */

.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.card-header {
  padding: 1.25rem 1.5rem 0.75rem 1.5rem;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: hsl(var(--card-foreground));
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.card-content {
  padding: 0 1.5rem 1.25rem 1.5rem;
}

.card-footer {
  padding: 0.75rem 1.5rem 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Search result card variant */
.search-result-card {
  display: flex;
  flex-direction: column;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.search-result-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, hsl(var(--primary)) 0%, hsl(var(--primary)) 50%, hsl(var(--accent)) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.search-result-card:hover {
  border-color: hsl(var(--primary) / 0.3);
  box-shadow: 0 12px 32px -8px hsl(var(--primary) / 0.18), 0 6px 12px -4px rgba(0, 0, 0, 0.06);
  transform: translateY(-4px);
}

.search-result-card:hover::before {
  opacity: 1;
}

.search-result-card h3 {
  color: hsl(var(--card-foreground));
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 1.125rem;
  margin-bottom: 0.75rem;
}

/* Result preview text */
.result-preview {
  color: hsl(var(--muted-foreground));
  line-height: 1.7;
  font-size: 0.875rem;
}

.result-preview mark {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  padding: 0.125rem 0.25rem;
  border-radius: calc(var(--radius) - 4px);
  font-weight: 500;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Empty state card */
.empty-state-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.empty-state-feature-card {
  padding: 1.25rem;
  background: hsl(var(--card));
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  text-align: center;
  transition: all 0.2s ease;
}

.empty-state-feature-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.empty-state-feature-icon {
  width: 48px;
  height: 48px;
  border-radius: calc(var(--radius) - 2px);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem auto;
}

.empty-state-feature-icon.purple {
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
}

.empty-state-feature-icon.green {
  background: hsl(142 71% 45% / 0.1);
  color: hsl(142 71% 45%);
}

.empty-state-feature-icon.amber {
  background: hsl(38 92% 50% / 0.1);
  color: hsl(38 92% 50%);
}

/* ========================================
   BADGE COMPONENTS (shadcn Badge variants)
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s;
  border: 1px solid transparent;
}

/* Quality badges */
.badge-quality-excellent {
  background: hsl(142 71% 45% / 0.1);
  color: hsl(142 71% 45%);
  border-color: hsl(142 71% 45% / 0.3);
}

.badge-quality-good {
  background: hsl(217 91% 60% / 0.1);
  color: hsl(217 91% 60%);
  border-color: hsl(217 91% 60% / 0.3);
}

.badge-quality-fair {
  background: hsl(38 92% 50% / 0.1);
  color: hsl(38 92% 50%);
  border-color: hsl(38 92% 50% / 0.3);
}

/* Source badges */
.badge-source-vector,
.badge-ai {
  background: hsl(271 91% 65% / 0.1);
  color: hsl(271 91% 65%);
  border-color: hsl(271 91% 65% / 0.3);
}

.badge-source-text,
.badge-keyword {
  background: hsl(142 71% 45% / 0.1);
  color: hsl(142 71% 45%);
  border-color: hsl(142 71% 45% / 0.3);
}

.badge-source-elasticsearch {
  background: hsl(217 91% 60% / 0.1);
  color: hsl(217 91% 60%);
  border-color: hsl(217 91% 60% / 0.3);
}

.badge-source-pinecone {
  background: hsl(24 84% 60% / 0.1);
  color: hsl(24 84% 60%);
  border-color: hsl(24 84% 60% / 0.3);
}

/* Era badge */
.badge-era,
.badge-capstone {
  background: hsl(38 92% 50% / 0.1);
  color: hsl(38 92% 50%);
  border-color: hsl(38 92% 50% / 0.3);
}

/* Relevance badges with color coding */
.relevance-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
}

.relevance-high {
  background: hsl(142 71% 45% / 0.1);
  color: hsl(142 71% 45%);
  border-color: hsl(142 71% 45% / 0.3);
}

.relevance-medium {
  background: hsl(217 91% 60% / 0.1);
  color: hsl(217 91% 60%);
  border-color: hsl(217 91% 60% / 0.3);
}

.relevance-low {
  background: hsl(38 92% 50% / 0.1);
  color: hsl(38 92% 50%);
  border-color: hsl(38 92% 50% / 0.3);
}

/* Quotability badges (aliases for quality) */
.quotability-excellent {
  background: hsl(142 71% 45% / 0.1);
  color: hsl(142 71% 45%);
  border-color: hsl(142 71% 45% / 0.3);
}

.quotability-good {
  background: hsl(217 91% 60% / 0.1);
  color: hsl(217 91% 60%);
  border-color: hsl(217 91% 60% / 0.3);
}

.quotability-fair {
  background: hsl(38 92% 50% / 0.1);
  color: hsl(38 92% 50%);
  border-color: hsl(38 92% 50% / 0.3);
}

/* ========================================
   BUTTON COMPONENTS (shadcn Button pattern)
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary button */
.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.btn-primary:hover:not(:disabled) {
  background: hsl(var(--primary) / 0.9);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px hsl(var(--primary) / 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

/* Secondary button */
.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--secondary));
}

.btn-secondary:hover:not(:disabled) {
  background: hsl(var(--secondary) / 0.8);
}

/* Outline button */
.btn-outline {
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}

.btn-outline:hover:not(:disabled) {
  background: hsl(var(--accent));
  border-color: hsl(var(--border));
}

/* Ghost button */
.btn-ghost {
  background: transparent;
  color: hsl(var(--foreground));
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: hsl(var(--accent));
}

/* Destructive button */
.btn-destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  border-color: hsl(var(--destructive));
}

.btn-destructive:hover:not(:disabled) {
  background: hsl(var(--destructive) / 0.9);
}

/* Icon button */
.btn-icon {
  padding: 0.5rem;
  aspect-ratio: 1;
}

/* Header action buttons */
.header-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  border: 1px solid transparent;
  cursor: pointer;
}

.header-action-btn-default {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}

.header-action-btn-default:hover {
  background: hsl(var(--accent));
  border-color: hsl(var(--border));
}

/* Make icons more visible */
.header-action-btn i,
.header-action-btn svg {
  opacity: 0.9;
}

/* Override faint gray icon colors with darker, more visible ones */
i[data-lucide].text-gray-400,
svg.text-gray-400 {
  color: #4b5563 !important; /* gray-600 instead of gray-400 */
}

i[data-lucide].text-gray-500,
svg.text-gray-500 {
  color: #374151 !important; /* gray-700 instead of gray-500 */
}

/* Ensure all lucide icons have sufficient contrast and visibility */
i[data-lucide],
svg.lucide,
svg[data-lucide] {
  stroke-width: 2.5;
  opacity: 1;
}

/* Force color inheritance for lucide icons */
svg.lucide,
svg[data-lucide] {
  color: inherit;
}

/* Ensure icons with specific color classes are visible */
svg.text-purple-600,
i.text-purple-600 {
  color: #9333ea !important;
}

svg.text-green-600,
i.text-green-600 {
  color: #16a34a !important;
}

svg.text-blue-600,
i.text-blue-600 {
  color: #2563eb !important;
}

svg.text-orange-500,
i.text-orange-500 {
  color: #f97316 !important;
}

svg.text-amber-600,
i.text-amber-600 {
  color: #d97706 !important;
}

/* Default visible color for icons without specific color class */
svg.lucide:not([class*="text-"]),
svg[data-lucide]:not([class*="text-"]) {
  color: hsl(var(--foreground));
  opacity: 0.9;
}

.header-action-btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.header-action-btn-primary:hover {
  box-shadow: 0 4px 12px hsl(var(--primary) / 0.35);
  transform: translateY(-1px);
}

/* Pagination buttons */
.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: hsl(var(--accent));
  border-color: hsl(var(--border));
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* View toggle buttons */
.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: hsl(var(--background));
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-toggle-btn:hover {
  background: hsl(var(--accent));
}

.view-toggle-btn.active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

/* ========================================
   DIALOG/MODAL COMPONENTS (shadcn Dialog pattern)
   ======================================== */

.dialog-overlay,
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.dialog-overlay:not(.hidden),
.modal:not(.hidden) {
  pointer-events: auto;
  opacity: 1;
}

.dialog-overlay.hidden,
.modal.hidden {
  display: none;
}

.dialog-content,
.modal-content-wrapper {
  position: relative;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 90vw;
  max-height: 90vh;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1.5rem 1rem 1.5rem;
  border-bottom: 1px solid hsl(var(--border));
}

.dialog-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.dialog-close {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: var(--radius);
  background: transparent;
  border: none;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  transition: all 0.2s ease;
}

.dialog-close:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem 1.5rem 1.5rem;
  border-top: 1px solid hsl(var(--border));
}

/* Specific modal variants */
.dialog-history {
  max-width: 64rem;
}

.dialog-saved {
  max-width: 56rem;
}

.dialog-filters {
  max-width: 48rem;
}

.dialog-export {
  max-width: 32rem;
}

.dialog-help {
  max-width: 42rem;
}

.dialog-result {
  max-width: 72rem;
}

/* ========================================
   TABLE COMPONENTS
   ======================================== */

.search-table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
}

.search-result-table,
.search-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.search-table-header,
.search-result-table thead {
  background: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border));
}

.search-table-header th,
.search-result-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.search-table-row,
.search-result-table tbody tr,
.search-result-row {
  border-bottom: 1px solid hsl(var(--border));
  transition: background 0.15s ease;
  cursor: pointer;
}

.search-table-row:hover,
.search-result-table tbody tr:hover,
.search-result-row:hover {
  background: hsl(var(--accent));
}

.search-result-row.selected {
  background: hsl(var(--primary) / 0.1);
}

.search-table-cell,
.search-result-table td {
  padding: 0.75rem 1rem;
  color: hsl(var(--foreground));
}

@media (max-width: 768px) {
  .search-table-container {
    overflow-x: auto;
  }

  .search-result-table {
    min-width: 600px;
  }
}

/* ========================================
   STATE COMPONENTS
   ======================================== */

/* Loading state */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem 2rem;
  min-height: 400px;
}

.loading-spinner {
  width: 3rem;
  height: 3rem;
  border: 4px solid hsl(var(--border));
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#loadingText {
  font-size: 1.125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
}

#loadingSubtext {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

/* Error state */
.error-state {
  padding: 2rem;
  background: hsl(var(--destructive) / 0.1);
  border: 1px solid hsl(var(--destructive) / 0.3);
  border-radius: var(--radius);
  color: hsl(var(--destructive));
  text-align: center;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 1.5rem;
  color: hsl(var(--muted-foreground));
  opacity: 0.5;
}

.empty-state-icon svg {
  width: 100%;
  height: 100%;
}

.empty-state h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin-bottom: 0.75rem;
}

.empty-state p {
  font-size: 1rem;
  color: hsl(var(--muted-foreground));
  max-width: 32rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

[data-theme="dark"] {
  /* Ensure icons are visible in dark mode */
  svg.lucide,
  svg[data-lucide],
  i[data-lucide] {
    opacity: 1;
  }

  svg.lucide:not([class*="text-"]),
  svg[data-lucide]:not([class*="text-"]) {
    color: hsl(var(--foreground));
  }

  /* Improve text readability in dark mode */
  .text-blue-700 {
    color: #60a5fa !important; /* Lighter blue-400 for dark mode */
  }

  .text-blue-600 {
    color: #60a5fa !important; /* blue-400 */
  }

  .text-gray-500 {
    color: #9ca3af !important; /* Lighter gray for dark mode */
  }

  .text-gray-600 {
    color: #d1d5db !important; /* gray-300 for dark mode */
  }

  .text-gray-700 {
    color: #e5e7eb !important; /* gray-200 for dark mode */
  }

  .text-gray-800 {
    color: #f3f4f6 !important; /* gray-100 for dark mode */
  }

  #searchTip .bg-blue-50 {
    background-color: rgba(59, 130, 246, 0.1) !important;
  }

  /* Cards get enhanced shadows in dark mode */
  .card,
  .search-result-card,
  .empty-state-card,
  .empty-state-feature-card {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  .card:hover,
  .search-result-card:hover,
  .empty-state-feature-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  }

  /* Input fields */
  .search-input,
  .filter-input,
  .filter-select {
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    border-color: hsl(var(--border));
  }

  /* Badges - adjust for better visibility */
  .badge-quality-excellent {
    background: hsl(142 71% 45% / 0.2);
    color: hsl(142 71% 65%);
  }

  .badge-quality-good {
    background: hsl(217 91% 60% / 0.2);
    color: hsl(217 91% 75%);
  }

  .badge-quality-fair {
    background: hsl(38 92% 50% / 0.2);
    color: hsl(38 92% 70%);
  }

  .badge-source-vector,
  .badge-ai {
    background: hsl(271 91% 65% / 0.2);
    color: hsl(271 91% 80%);
  }

  .badge-source-text,
  .badge-keyword {
    background: hsl(142 71% 45% / 0.2);
    color: hsl(142 71% 65%);
  }

  .badge-source-elasticsearch {
    background: hsl(217 91% 60% / 0.2);
    color: hsl(217 91% 75%);
  }

  .badge-source-pinecone {
    background: hsl(24 84% 60% / 0.2);
    color: hsl(24 84% 75%);
  }

  .badge-era,
  .badge-capstone {
    background: hsl(38 92% 50% / 0.2);
    color: hsl(38 92% 70%);
  }

  /* Modals */
  .dialog-content,
  .modal-content-wrapper {
    background: hsl(var(--background));
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  }

  /* Table rows */
  .search-table-row:hover,
  .search-result-table tbody tr:hover,
  .search-result-row:hover {
    background: hsl(var(--accent) / 0.5);
  }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Mobile (< 640px) */
@media (max-width: 640px) {
  .search-container,
  .search-content {
    padding: 1rem;
  }

  .search-results-section {
    grid-template-columns: 1fr;
  }

  .result-card,
  .search-result-card {
    padding: 1rem;
  }

  .badge-era {
    display: none; /* Save space on mobile */
  }

  #quickFilters {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  #quickFilters::-webkit-scrollbar {
    display: none;
  }

  .btn,
  .header-action-btn {
    min-height: 44px; /* Touch-friendly */
  }

  .dialog-content,
  .modal-content-wrapper {
    max-width: 95vw;
    max-height: 95vh;
  }

  .dialog-header,
  .dialog-body,
  .dialog-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Tablet (640px - 1024px) */
@media (min-width: 640px) and (max-width: 1024px) {
  .search-results-section {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .search-header {
    padding: 1.5rem;
  }
}

/* Desktop (> 1024px) */
@media (min-width: 1024px) {
  .search-results-section {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }

  .search-header {
    padding: 2rem;
  }

  .result-card:hover,
  .search-result-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.search-input:focus-visible,
.filter-input:focus-visible,
.filter-select:focus-visible,
.btn:focus-visible,
.header-action-btn:focus-visible,
.pagination-btn:focus-visible,
.view-toggle-btn:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.quick-filter-chip:focus-visible,
.autocomplete-item:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 1px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

.result-card,
.search-result-card {
  contain: layout style paint;
  will-change: transform;
}

.dialog-content,
.modal-content-wrapper {
  will-change: transform, opacity;
}

.btn,
.header-action-btn {
  will-change: transform;
}

/* Scroll area optimization */
.dialog-body,
.autocomplete-dropdown {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.hidden {
  display: none !important;
}

.flex-1 {
  flex: 1;
}

.flex-shrink-0 {
  flex-shrink: 0;
}

/* Search tip */
#searchTip {
  margin-bottom: 1.25rem;
}

/* Make search tip text more readable */
#searchTip .text-blue-700,
.text-blue-700 {
  color: #1e40af !important; /* Darker blue-800 for better contrast */
}

#searchTip .text-sm {
  font-weight: 500; /* Medium weight for better readability */
}

/* Improve readability of light text colors */
.text-gray-500 {
  color: #6b7280 !important; /* Keep gray-500 but ensure it's visible */
}

.text-gray-600 {
  color: #4b5563 !important; /* gray-600 */
}

.text-gray-700 {
  color: #374151 !important; /* gray-700 */
}

.text-gray-800 {
  color: #1f2937 !important; /* gray-800 */
}

/* Ensure good contrast for blue text */
.text-blue-600 {
  color: #2563eb !important; /* blue-600 */
}

.text-blue-800 {
  color: #1e40af !important; /* blue-800 */
}

/* Page info indicator */
#pageInfo {
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  padding: 0 0.5rem;
}

/* Result stats and meta */
#resultStats {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

#resultMeta {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

/* Sermon content formatting in modals */
.sermon-paragraph {
  margin-bottom: 1rem;
  display: flex;
}

.paragraph-number {
  font-weight: bold;
  min-width: 3rem;
  color: hsl(var(--muted-foreground));
  margin-right: 0.5rem;
}

/* Modal content typography */
#modalContent h1,
#modalContent h2,
#modalContent h3 {
  color: hsl(var(--foreground));
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

#modalContent h1 {
  font-size: 1.5rem;
}

#modalContent h2 {
  font-size: 1.3rem;
}

#modalContent h3 {
  font-size: 1.1rem;
}

#modalContent p {
  margin-bottom: 1rem;
  line-height: 1.7;
  text-align: justify;
  color: hsl(var(--foreground));
}

/* Biblical quotes and references */
#modalContent blockquote {
  border-left: 4px solid hsl(var(--primary));
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: hsl(var(--muted));
  font-style: italic;
  color: hsl(var(--muted-foreground));
  border-radius: calc(var(--radius) - 2px);
}

#modalContent blockquote p {
  margin-bottom: 0.5rem;
}

#modalContent blockquote p:last-child {
  margin-bottom: 0;
}

#modalContent blockquote em {
  font-weight: 500;
  color: hsl(var(--foreground));
}

/* Paragraph number styling */
#modalContent p strong {
  color: hsl(var(--muted-foreground));
  font-size: 0.9rem;
  margin-right: 0.5rem;
}

#modalContent .paragraph-number {
  color: hsl(var(--muted-foreground));
  font-size: 0.9rem;
  margin-right: 0.75rem;
  display: inline-block;
  min-width: 2.5rem;
  font-weight: 600;
  text-align: right;
}

/* Modal scrollbar styling */
.modal-content::-webkit-scrollbar,
.dialog-body::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track,
.dialog-body::-webkit-scrollbar-track {
  background: hsl(var(--muted));
  border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb,
.dialog-body::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.3);
  border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb:hover,
.dialog-body::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.5);
}
