/* 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 Enhancements */
.search-enhancements {
  background: #f8fafc;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  border: 1px solid #e2e8f0;
}

.search-enhancements summary {
  cursor: pointer;
  font-weight: 500;
  color: #4a5568;
  font-size: 0.9rem;
  user-select: none;
}

.search-enhancements summary:hover {
  color: #667eea;
}

.search-enhancements[open] summary {
  margin-bottom: 0.75rem;
}

.enhancement-options {
  display: grid;
  gap: 0.5rem;
  padding-left: 0.5rem;
}

.enhancement-options .search-option {
  margin: 0;
}

.enhancement-options .search-option label {
  font-size: 0.85rem;
}

/* 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;
  }
}

/* ============================================
   Sources Management Styles
   ============================================ */

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

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

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

/* Tabs */
.sources-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0;
}

.sources-tabs .tab {
  background: none;
  border: none;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  color: #718096;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.sources-tabs .tab:hover {
  color: #4a5568;
}

.sources-tabs .tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
  font-weight: 500;
}

/* Source Panel */
.source-panel {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.panel-header h3 {
  color: #2d3748;
  font-size: 1.2rem;
  font-weight: 600;
}

/* Source List */
.source-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Source Card */
.source-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
  transition: border-color 0.2s;
}

.source-card:hover {
  border-color: #cbd5e0;
}

.source-card.inactive {
  opacity: 0.7;
  background: #f1f5f9;
}

.source-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.source-card-info h4 {
  color: #2d3748;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.source-subtitle {
  color: #718096;
  font-size: 0.85rem;
}

.source-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
  color: #4a5568;
}

.source-description {
  color: #4a5568;
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

.source-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}

.source-card-actions-inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-badge.active {
  background: #c6f6d5;
  color: #276749;
}

.status-badge.inactive {
  background: #fed7d7;
  color: #c53030;
}

/* Sync Status */
.sync-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #718096;
}

.sync-error {
  color: #c53030;
  font-weight: 500;
}

/* Buttons */
.add-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.add-btn:hover {
  background: #5a67d8;
}

.add-btn.small {
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
}

.sync-btn {
  background: #48bb78;
  color: white;
  border: none;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.sync-btn:hover:not(:disabled) {
  background: #38a169;
}

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

.edit-btn {
  background: #edf2f7;
  color: #4a5568;
  border: 1px solid #e2e8f0;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.edit-btn:hover {
  background: #e2e8f0;
}

.delete-btn {
  background: #fff5f5;
  color: #c53030;
  border: 1px solid #fed7d7;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.delete-btn:hover {
  background: #fed7d7;
}

.delete-btn.small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.toggle-btn {
  background: #edf2f7;
  color: #4a5568;
  border: 1px solid #e2e8f0;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
}

.toggle-btn:hover {
  background: #e2e8f0;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: #718096;
}

.empty-state p {
  margin-bottom: 1rem;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: #718096;
}

.loading-state .loading-spinner {
  margin-bottom: 1rem;
}

/* Error State */
.error-state {
  text-align: center;
  padding: 2rem;
  color: #c53030;
  background: #fff5f5;
  border-radius: 8px;
}

.retry-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  margin-top: 1rem;
  cursor: pointer;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
  color: #2d3748;
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #718096;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #4a5568;
}

.modal-content {
  padding: 1.5rem;
}

/* Form Styles */
.source-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #4a5568;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.form-group.checkbox label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.form-group.checkboxes {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.9rem;
  color: #4a5568;
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-hint {
  font-size: 0.75rem;
  color: #718096;
  margin-top: 0.25rem;
}

.form-error {
  background: #fff5f5;
  color: #c53030;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

.cancel-btn {
  background: #edf2f7;
  color: #4a5568;
  border: 1px solid #e2e8f0;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.cancel-btn:hover {
  background: #e2e8f0;
}

.submit-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 0.5rem 1.5rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

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

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

/* Tags Input */
.tags-input {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.tags-input .tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #edf2f7;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.tags-input .tag button {
  background: none;
  border: none;
  color: #718096;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.tags-input .tag button:hover {
  color: #c53030;
}

.tag-input {
  padding: 0.375rem 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Interval Input */
.interval-input {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.interval-input label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #4a5568;
}

.interval-controls {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.interval-controls input {
  width: 60px;
  padding: 0.375rem 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 0.9rem;
  text-align: center;
}

.interval-controls span {
  color: #718096;
  font-size: 0.85rem;
}

/* Confirm Dialog */
.confirm-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.confirm-dialog {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  max-width: 400px;
  text-align: center;
}

.confirm-dialog p {
  margin-bottom: 1rem;
  color: #4a5568;
}

.confirm-dialog-buttons {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.confirm-btn {
  background: #e53e3e;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
}

.confirm-btn:hover {
  background: #c53030;
}

/* GitHub Account Card */
.github-account-card,
.google-account-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
}

.repos-section,
.folders-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

.repos-header,
.folders-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.repos-header h5,
.folders-header h5 {
  font-size: 0.9rem;
  color: #4a5568;
  font-weight: 500;
}

.repos-list,
.folders-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.repo-card,
.folder-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.repo-card.inactive,
.folder-card.inactive {
  opacity: 0.6;
}

.repo-info,
.folder-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.repo-path {
  font-weight: 500;
  color: #2d3748;
}

.folder-name {
  font-weight: 500;
  color: #2d3748;
  text-decoration: none;
}

a.folder-name:hover {
  color: #667eea;
  text-decoration: underline;
}

.folder-path {
  font-size: 0.8rem;
  color: #718096;
}

.repo-tracking,
.folder-settings {
  display: flex;
  gap: 0.375rem;
}

.tracking-badge,
.setting-badge {
  background: #e2e8f0;
  color: #4a5568;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-size: 0.7rem;
}

.repo-actions,
.folder-actions {
  display: flex;
  gap: 0.375rem;
}

.no-repos,
.no-folders {
  color: #718096;
  font-size: 0.9rem;
  font-style: italic;
}

.sync-error-banner {
  background: #fff5f5;
  color: #c53030;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  margin: 0.5rem 0;
}

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

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

  .sources-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sources-tabs .tab {
    padding: 0.5rem 1rem;
    white-space: nowrap;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .source-card-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .source-card-actions {
    flex-wrap: wrap;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .repo-card,
  .folder-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .repo-actions,
  .folder-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

/* === Folder Browser === */

.folder-browser {
  display: flex;
  flex-direction: column;
  min-height: 400px;
  max-height: 60vh;
}

.folder-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.875rem;
}

.breadcrumb-sep {
  color: #a0aec0;
  margin: 0 0.25rem;
}

.breadcrumb-item {
  background: none;
  border: none;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  color: #667eea;
  cursor: pointer;
  font-size: 0.875rem;
}

.breadcrumb-item:hover:not(:disabled) {
  background: #edf2f7;
}

.breadcrumb-item.current {
  color: #2d3748;
  font-weight: 500;
  cursor: default;
}

.folder-loading,
.folder-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: #718096;
  font-size: 0.875rem;
  padding: 2rem;
}

.folder-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  transition: background 0.15s;
}

.folder-item:hover {
  background: #f7fafc;
}

.folder-item.selected {
  background: #ebf8ff;
}

.folder-item-checkbox {
  display: flex;
  align-items: center;
}

.folder-item-checkbox input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.folder-item-icon {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
}

.folder-item-name {
  flex: 1;
  font-size: 0.875rem;
  color: #2d3748;
  text-decoration: none;
}

a.folder-item-name {
  color: #4a5568;
}

a.folder-item-name:hover {
  color: #667eea;
  text-decoration: underline;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-item-recursive {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: #718096;
  margin-left: auto;
  padding: 0.25rem 0.5rem;
  background: #f7fafc;
  border-radius: 4px;
}

.folder-item-recursive input {
  width: 14px;
  height: 14px;
}

.folder-item-enter {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  color: #667eea;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.15s;
}

.folder-item-enter:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.folder-browser-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.selected-count {
  font-size: 0.875rem;
  color: #718096;
}

.folder-browser-actions {
  display: flex;
  gap: 0.5rem;
}

.folders-actions {
  display: flex;
  gap: 0.5rem;
}

.add-btn.secondary {
  background: #f7fafc;
  color: #4a5568;
  border: 1px solid #e2e8f0;
}

.add-btn.secondary:hover {
  background: #edf2f7;
}