:root {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --border-active: #6366f1;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --accent-blue: #2563eb;
  --accent-indigo: #4f46e5;
  --accent-purple: #7c3aed;
  --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  
  --glow-shadow: 0 4px 20px rgba(99, 102, 241, 0.08);
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.04);
  --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  
  --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Plus Jakarta Sans', 'Outfit', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px;
  flex-shrink: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.logo-icon {
  font-size: 20px;
}

.brand h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.filter-list {
  list-style: none;
}

.filter-list li {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.filter-list li:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.filter-list li.active {
  background: rgba(79, 70, 229, 0.05);
  color: var(--accent-indigo);
  font-weight: 600;
  border-left: 2px solid var(--accent-indigo);
  padding-left: 8px;
}

.filter-list li.muted,
.filter-list li.error {
  cursor: default;
  color: var(--text-muted);
}

.filter-list li.muted:hover,
.filter-list li.error:hover {
  background: transparent;
  color: var(--text-muted);
}

.filter-list li.error {
  color: #b45309;
}

.sidebar-footer {
  margin-top: auto;
}

.status-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  font-size: 11px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  align-items: center;
}

.status-label {
  color: var(--text-secondary);
}

.status-value {
  font-weight: 600;
  color: var(--text-primary);
}

.status-value.loading {
  color: #d97706;
}

.status-value.connected {
  color: #059669;
}

.status-value.code {
  font-family: monospace;
  font-size: 9px;
  background: var(--bg-tertiary);
  padding: 1px 4px;
  border-radius: 3px;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-value.time {
  font-size: 9px;
  color: var(--text-secondary);
  max-width: 112px;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-value.coverage {
  max-width: 112px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 9px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usage-meter-container {
  margin-top: 10px;
}

.usage-row {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.meter {
  height: 3px;
  background-color: var(--bg-tertiary);
  border-radius: 1.5px;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 1.5px;
  transition: width 0.5s ease;
}

.warning-alert {
  margin-top: 10px;
  background-color: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.1);
  color: #dc2626;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 9px;
  text-align: center;
  font-weight: 500;
}

.hidden {
  display: none !important;
}

body.auth-pending .app-container {
  visibility: hidden;
}

body.auth-pending #login-container.hidden {
  display: flex !important;
}

.login-container {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-primary);
  padding: 24px;
}

.login-card {
  width: min(100%, 380px);
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--card-shadow-hover);
  padding: 28px;
}

.login-logo {
  font-size: 28px;
  margin-bottom: 14px;
}

.login-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.login-card p {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 18px;
}

.login-card input {
  width: 100%;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 12px 14px;
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: var(--transition-smooth);
  margin-bottom: 10px;
}

.login-card input:focus {
  border-color: var(--accent-indigo);
  background-color: var(--bg-secondary);
  box-shadow: var(--glow-shadow);
}

.login-card .btn-primary {
  width: 100%;
  margin-top: 4px;
}

.login-card .btn-primary:disabled {
  cursor: wait;
  opacity: 0.75;
  transform: none;
}

.login-error {
  background-color: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.14);
  color: #b91c1c;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
}

.search-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
}

.search-input-wrapper {
  display: flex;
  gap: 10px;
  max-width: 800px;
}

#search-input {
  flex: 1;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 12px 16px;
  font-size: 15px;
  font-family: var(--font-sans);
  outline: none;
  transition: var(--transition-smooth);
}

#search-input:focus {
  border-color: var(--accent-indigo);
  background-color: var(--bg-secondary);
  box-shadow: var(--glow-shadow);
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: var(--transition-smooth);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-0.5px);
}

.search-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  max-width: 800px;
}

.results-count {
  font-size: 12px;
  color: var(--text-secondary);
}

.search-type-badge {
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 700;
  background-color: rgba(79, 70, 229, 0.08);
  color: var(--accent-indigo);
  padding: 2px 6px;
  border-radius: 8px;
}

/* Results Area */
.results-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.results-list {
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  max-width: 440px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.8;
}

.empty-state h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

/* Spinner */
.spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  border-top-color: var(--accent-indigo);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Search Card */
.result-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  transition: var(--transition-smooth);
}

.result-card:hover {
  border-color: var(--border-active);
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-1px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.card-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.path-crumb {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition-smooth);
}

.card-title:hover {
  color: var(--accent-indigo);
}

.score-badge {
  font-size: 10px;
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  padding: 3px 6px;
  border-radius: 5px;
}

.card-snippet {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  margin-bottom: 12px;
}

.card-snippet mark {
  background-color: rgba(253, 224, 71, 0.5);
  color: #854d0e;
  padding: 0 1px;
  border-radius: 2px;
  font-weight: 500;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--bg-tertiary);
  padding-top: 10px;
  font-size: 11px;
}

.footer-left {
  display: flex;
  gap: 10px;
  align-items: center;
}

.lang-tag {
  background-color: var(--bg-tertiary);
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
}

.commit-tag {
  font-family: monospace;
  font-size: 9px;
  color: var(--text-muted);
}

.btn-github {
  display: flex;
  align-items: center;
  gap: 4px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition-smooth);
}

.btn-github:hover {
  background-color: var(--border-color);
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.15);
}

/* Responsiveness (Highly Mobile Optimized) */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    height: auto;
  }
  
  .brand {
    margin-bottom: 8px;
    justify-content: center;
  }
  
  .sidebar-section {
    display: block;
    margin-bottom: 8px;
  }
  
  /* Scrollable folders list horizontally on mobile */
  .filter-list {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  
  .filter-list li {
    flex-shrink: 0;
    font-size: 12px;
    padding: 6px 10px;
    margin-bottom: 0;
  }
  
  .filter-list li.active {
    border-left: none;
    border-bottom: 2px solid var(--accent-indigo);
    border-radius: 4px;
    padding-left: 10px;
  }
  
  .sidebar-footer {
    display: none; /* Hide status/stats block in sidebar on mobile to save vertical space */
  }
  
  .main-content {
    flex: 1;
    overflow: hidden;
  }
  
  .search-header {
    padding: 12px 16px;
  }
  
  .search-input-wrapper {
    gap: 6px;
  }
  
  #search-input {
    padding: 10px 12px;
    font-size: 14px;
  }
  
  .btn-primary {
    padding: 10px 16px;
    font-size: 14px;
  }
  
  .results-container {
    padding: 16px;
  }
  
  .result-card {
    padding: 16px;
  }
  
  .card-title {
    font-size: 15px;
  }
}
