/* Layout */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--pico-card-background-color);
  border-right: 1px solid var(--pico-muted-border-color);
  padding: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sidebar header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0 0;
}

.sidebar nav a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  text-decoration: none;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}

#main-content {
  padding: 2rem;
  max-width: 1200px;
  overflow-y: auto;
}

/* Connection status */
.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.connected {
  background: #22c55e;
}

.status-dot.disconnected {
  background: #ef4444;
}

/* Toast notifications */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  color: white;
  font-size: 0.875rem;
  max-width: 400px;
  animation: toast-in 0.3s ease;
}

.toast.success {
  background: #22c55e;
}

.toast.error {
  background: #ef4444;
}

.toast.info {
  background: #3b82f6;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(1rem); }
  to { opacity: 1; transform: translateX(0); }
}

/* Score badges */
.score-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: monospace;
}

.score-high {
  background: #dcfce7;
  color: #166534;
}

.score-medium {
  background: #fef9c3;
  color: #854d0e;
}

.score-low {
  background: #fecaca;
  color: #991b1b;
}

/* Debug timing bars */
.timing-bars {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 1rem 0;
}

.timing-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.timing-label {
  width: 140px;
  font-size: 0.8rem;
  text-align: right;
  flex-shrink: 0;
}

.timing-bar-container {
  flex: 1;
  height: 22px;
  background: var(--pico-muted-border-color);
  border-radius: 0.2rem;
  overflow: hidden;
}

.timing-bar {
  height: 100%;
  border-radius: 0.2rem;
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
}

.timing-bar.search {
  background: #3b82f6;
}

.timing-bar.context {
  background: #8b5cf6;
}

.timing-bar.llm {
  background: #f59e0b;
}

.timing-bar.total {
  background: #10b981;
}

/* Source cards */
.source-card {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

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

.source-card .snippet {
  font-size: 0.875rem;
  color: var(--pico-muted-color);
  white-space: pre-wrap;
}

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

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Table tweaks */
.compact-table td,
.compact-table th {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

/* Compare panels */
.compare-panels {
  display: grid;
  gap: 1rem;
}

.compare-panels.panels-2 {
  grid-template-columns: 1fr 1fr;
}

.compare-panels.panels-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.compare-panels.panels-4 {
  grid-template-columns: 1fr 1fr;
}

.compare-panel {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.5rem;
  padding: 1rem;
}

.compare-panel h4 {
  margin-top: 0;
}

/* Feedback buttons */
.feedback-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.feedback-buttons button {
  padding: 0.3rem 0.75rem;
  font-size: 1.2rem;
  width: auto;
  margin: 0;
}

.feedback-buttons button.active-up {
  background: #22c55e;
  color: white;
}

.feedback-buttons button.active-down {
  background: #ef4444;
  color: white;
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.stat-card {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.5rem;
  padding: 1rem;
}

.stat-card h4 {
  margin-top: 0;
  font-size: 0.95rem;
  color: var(--pico-muted-color);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

/* Utility */
.muted {
  color: var(--pico-muted-color);
  font-size: 0.85rem;
}

.mb-1 { margin-bottom: 1rem; }
.mt-1 { margin-top: 1rem; }

kbd {
  font-size: 0.8rem;
  padding: 0.1rem 0.4rem;
}

/* Advanced prompt override */
.advanced-section {
  margin-top: 0.75rem;
  margin-bottom: 0;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
}

.advanced-section summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--pico-muted-color);
}

.advanced-section textarea {
  font-family: monospace;
  font-size: 0.85rem;
}
