/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: #333;
  background: #f8fafc;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  min-height: 100vh;
  flex-direction: column;
}

.loading h2 {
  color: #667eea;
  font-weight: 500;
}

.loading-spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Error state */
.error {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  flex-direction: column;
  text-align: center;
  padding: 2rem;
}

.error h2 {
  color: #e53e3e;
  margin-bottom: 1rem;
}

.error p {
  color: #666;
  margin-bottom: 2rem;
  max-width: 400px;
}

.error button {
  background: #667eea;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.error button:hover {
  background: #5a67d8;
}

/* Login prompt */
.login-prompt {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  flex-direction: column;
  text-align: center;
  padding: 2rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.login-prompt h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.login-prompt p {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  opacity: 0.9;
  max-width: 400px;
}

.login-btn {
  background: white;
  color: #667eea;
  border: none;
  padding: 1rem 2rem;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

/* App header */
.app-header {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
  color: #667eea;
  font-size: 1.5rem;
  font-weight: 600;
}

.logout-btn {
  background: #f7fafc;
  color: #4a5568;
  border: 1px solid #e2e8f0;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: #edf2f7;
  color: #2d3748;
}

/* Main content */
.app-main {
  flex: 1;
  padding: 2rem;
  margin: 0 auto;
  width: 100%;
}

.welcome {
  text-align: center;
  margin-bottom: 3rem;
  padding: 2rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.welcome h2 {
  color: #2d3748;
  font-size: 1.8rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.welcome p {
  color: #666;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

/* Features grid */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.feature-card {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

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

.feature-card h3 {
  color: #2d3748;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.feature-card p {
  color: #666;
  font-size: 0.95rem;
}

/* Search View */
.search-view {
  min-height: 100vh;
  background: #f8fafc;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.back-btn {
  background: #f7fafc;
  color: #4a5568;
  border: 1px solid #e2e8f0;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.back-btn:hover {
  background: #edf2f7;
  color: #2d3748;
}

.search-header h2 {
  color: #2d3748;
  font-size: 1.8rem;
  font-weight: 600;
}

/* Search Form */
.search-form {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.search-input-group {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s;
  white-space: nowrap;
}

.search-btn:hover:not(:disabled) {
  background: #5a67d8;
}

.search-btn:disabled {
  background: #a0aec0;
  cursor: not-allowed;
}

.search-options {
  border-top: 1px solid #e2e8f0;
  padding-top: 1.5rem;
  display: grid;
  gap: 1.5rem;
}

.search-option {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-option label {
  font-weight: 500;
  color: #4a5568;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-option input[type="checkbox"] {
  margin-right: 0.5rem;
  transform: scale(1.1);
  accent-color: #667eea;
}

/* Search Results */
.search-results {
  margin-top: 2rem;
}

.results-count {
  background: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  color: #4a5568;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.search-result-card {
  background: white;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 1rem;
  border-left: 4px solid #667eea;
}

.result-score {
  font-size: 0.8rem;
  color: #718096;
  margin-bottom: 0.5rem;
}

.search-result-card h4 {
  color: #2d3748;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.result-content {
  color: #4a5568;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.result-chunks {
  border-top: 1px solid #e2e8f0;
  padding-top: 1rem;
}

.result-chunks strong {
  color: #2d3748;
  display: block;
  margin-bottom: 0.5rem;
}

.chunk {
  background: #f7fafc;
  padding: 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #4a5568;
  border-left: 2px solid #e2e8f0;
}

.no-results {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  color: #718096;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.image-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1rem 0;
}

.search-result-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.tag {
  background: #edf2f7;
  color: #4a5568;
  padding: 0.25rem 0.75rem;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid #e2e8f0;
  transition: background-color 0.2s;
}

.tag.selected {
  background: #667eea;
  color: white;
}

.tag:hover {
  background: #e2e8f0;
}

.metadata {
  margin-top: 1rem;
  padding: 1rem 2rem;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

/* Responsive design */
@media (max-width: 768px) {
  .app-header {
    padding: 1rem;
  }

  .app-header h1 {
    font-size: 1.3rem;
  }

  .app-main {
    padding: 1rem;
  }

  .login-prompt h1 {
    font-size: 2rem;
  }

  .login-prompt p {
    font-size: 1rem;
  }

  .features {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .feature-card {
    padding: 1.5rem;
  }

  .welcome {
    padding: 1.5rem;
  }

  .search-view {
    padding: 1rem;
  }

  .search-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .search-input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .search-form {
    padding: 1.5rem;
  }

  .search-options {
    gap: 1rem;
  }

  .limit-input {
    width: 80px;
  }

  .search-result-card {
    padding: 1rem;
  }
}

/* Utility classes */
.text-center {
  text-align: center;
}

.mt-4 {
  margin-top: 1rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.p-4 {
  padding: 1rem;
}

/* Markdown content styling */
.markdown-content {
  padding: 1rem;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin: 1rem 0;
  line-height: 1.7;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin: 1.5rem 0 0.75rem 0;
  color: #1f2937;
}

.markdown-content h1:first-child,
.markdown-content h2:first-child,
.markdown-content h3:first-child,
.markdown-content h4:first-child,
.markdown-content h5:first-child,
.markdown-content h6:first-child {
  margin-top: 0;
}

.markdown-content p {
  margin: 0.75rem 0;
  color: #374151;
}

.markdown-content ul,
.markdown-content ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.markdown-content li {
  margin: 0.25rem 0;
  color: #374151;
}

.markdown-content blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: #f3f4f6;
  border-left: 4px solid #d1d5db;
  color: #6b7280;
  font-style: italic;
}

.markdown-content code {
  background: #f3f4f6;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 0.875em;
  color: #e53e3e;
}

.markdown-content pre {
  background: #1f2937;
  color: #f9fafb;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
}

.markdown-content pre code {
  background: none;
  color: inherit;
  padding: 0;
}

.markdown-content a {
  color: #3b82f6;
  text-decoration: underline;
}

.markdown-content a:hover {
  color: #1d4ed8;
}

.markdown-preview {
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
  margin: 0.75rem 0 0.5rem 0;
  color: #2d3748;
}

.markdown-preview h1:first-child,
.markdown-preview h2:first-child,
.markdown-preview h3:first-child,
.markdown-preview h4:first-child,
.markdown-preview h5:first-child,
.markdown-preview h6:first-child {
  margin-top: 0;
}

.markdown-preview p {
  margin: 0.5rem 0;
  color: #4a5568;
}

.markdown-preview ul,
.markdown-preview ol {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.markdown-preview li {
  margin: 0.125rem 0;
  color: #4a5568;
}

.markdown-preview code {
  background: #edf2f7;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 0.8em;
  color: #c53030;
}

.markdown-preview pre {
  background: #2d3748;
  color: #e2e8f0;
  padding: 0.75rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 0.5rem 0;
  font-size: 0.8rem;
}

.markdown-preview pre code {
  background: none;
  color: inherit;
  padding: 0;
}

.markdown-preview blockquote {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  background: #f7fafc;
  border-left: 3px solid #cbd5e0;
  color: #718096;
  font-style: italic;
}

.markdown-preview a {
  color: #4299e1;
  text-decoration: underline;
}

.markdown-preview a:hover {
  color: #2b6cb0;
}

/* Dynamic filters styles */
.modality-filters {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.5rem;
}

.modality-filter-group {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: white;
}

.modality-filter-title {
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: #4a5568;
  background: #f8fafc;
  border-radius: 7px 7px 0 0;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}

.modality-filter-title:hover {
  background: #edf2f7;
}

.modality-filter-group[open] .modality-filter-title {
  border-bottom: 1px solid #e2e8f0;
  border-radius: 7px 7px 0 0;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1rem;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #4a5568;
  margin-bottom: 0.25rem;
}

.filter-input {
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 0.875rem;
  background: white;
  transition: border-color 0.2s;
}

.filter-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 1px #667eea;
}

/* Selectable tags controls */
.selectable-tags-details {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: white;
}

.selectable-tags-summary {
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: #4a5568;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
  border-radius: 7px;
}

.selectable-tags-summary:hover {
  background: #f8fafc;
}

.selectable-tags-details[open] .selectable-tags-summary {
  border-bottom: 1px solid #e2e8f0;
  border-radius: 7px 7px 0 0;
  background: #f8fafc;
}

.tag-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  background: #fafbfc;
}

.tag-control-btn {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: #4a5568;
  cursor: pointer;
  transition: all 0.2s;
}

.tag-control-btn:hover:not(:disabled) {
  background: #edf2f7;
  border-color: #cbd5e0;
}

.tag-control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tag-count {
  font-size: 0.75rem;
  color: #718096;
  font-weight: 500;
}

/* Tag search controls */
.tag-search-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.tag-search-input {
  flex: 1;
  padding: 0.375rem 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 0.875rem;
  background: white;
  transition: border-color 0.2s;
}

.tag-search-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 1px #667eea;
}



.filtered-count {
  font-size: 0.75rem;
  color: #718096;
  font-weight: 500;
  white-space: nowrap;
}

.tags-display-area {
  padding: 1rem;
}

@media (max-width: 768px) {
  .filters-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 0.75rem;
  }

  .modality-filter-title {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }

  .tag-search-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
}