/* Dashboard Specific Styles */

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Stats Overview */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: box-shadow 0.2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  font-size: 2.5rem;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.dashboard-section {
  margin-bottom: 2rem;
}

.dashboard-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.dashboard-card.wide {
  grid-column: span 2;
}

.dashboard-card.full-width {
  width: 100%;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-header select {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
}

.card-content {
  padding: 1.5rem;
}

/* Status Bars */
.status-bars {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.status-bar-item {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-bar-label {
  width: 100px;
  font-size: 0.9rem;
  font-weight: 500;
}

.status-bar-container {
  flex: 1;
  height: 24px;
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
}

.status-bar {
  height: 100%;
  border-radius: 12px;
  transition: width 0.5s ease;
  min-width: 2px;
}

.status-bar.uploaded { background: var(--primary); }
.status-bar.processing { background: var(--warning); }
.status-bar.indexed { background: var(--success); }
.status-bar.failed { background: var(--error); }

.status-bar-count {
  width: 60px;
  text-align: right;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Pipeline Flow */
.pipeline-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 0;
  overflow-x: auto;
  position: relative;
}

.pipeline-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 100px;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s;
}

.pipeline-stage:hover {
  transform: translateY(-4px);
}

.stage-circle {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  transition: all 0.3s;
  position: relative;
  z-index: 2;
}

.stage-circle.active {
  border-color: var(--primary);
  background: #dbeafe;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.stage-circle.has-items {
  animation: pulse 2s infinite;
}

.stage-circle.has-items::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: var(--warning);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.stage-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.stage-count {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 500;
}

.stage-timing {
  font-size: 0.75rem;
  color: var(--secondary);
  background: var(--bg);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
}

.pipeline-connector {
  flex: 1;
  height: 4px;
  background: var(--border);
  margin: 0 -0.5rem;
  position: relative;
  min-width: 30px;
  margin-top: -2rem;
}

.pipeline-connector::after {
  content: '';
  position: absolute;
  right: -4px;
  top: -4px;
  width: 0;
  height: 0;
  border-left: 8px solid var(--border);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.pipeline-connector.active {
  background: var(--primary);
}

.pipeline-connector.active::after {
  border-left-color: var(--primary);
}

/* Flow particles animation */
.pipeline-connector.flowing::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  top: -2px;
  animation: flowParticle 1.5s ease-in-out infinite;
}

@keyframes flowParticle {
  0% { left: 0; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { left: calc(100% - 8px); opacity: 0; }
}

/* Processing indicator */
.stage-processing {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--warning);
  white-space: nowrap;
}

.processing-dot {
  width: 6px;
  height: 6px;
  background: var(--warning);
  border-radius: 50%;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.pipeline-arrow {
  font-size: 1.5rem;
  color: var(--border);
  margin: 0 0.5rem;
}

/* Pipeline Full Width Layout */
.pipeline-full {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pipeline-endpoint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 12px;
  border: 2px dashed var(--border);
  min-width: 90px;
}

.pipeline-endpoint.source {
  border-color: var(--primary);
  background: #eff6ff;
}

.pipeline-endpoint.destination {
  border-color: var(--success);
  background: #f0fdf4;
}

.endpoint-icon {
  font-size: 2rem;
}

.endpoint-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Flow Legend */
.flow-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.legend-dot.active {
  background: var(--primary);
}

.legend-dot.processing {
  background: var(--warning);
  animation: blink 1s infinite;
}

/* Entity List */
.entity-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
}

.entity-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  transition: background 0.2s;
}

.entity-item:hover {
  background: var(--border);
}

.entity-icon {
  font-size: 1.5rem;
}

.entity-info {
  flex: 1;
}

.entity-name {
  font-weight: 500;
  font-size: 0.9rem;
}

.entity-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.entity-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.entity-badge.docs {
  background: #dbeafe;
  color: var(--primary);
}

.entity-badge.unread {
  background: #fef3c7;
  color: var(--warning);
}

/* Activity Feed */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--border);
  transition: background 0.2s;
}

.activity-item:hover {
  background: var(--border);
}

.activity-item.ingested { border-left-color: var(--primary); }
.activity-item.extracted { border-left-color: #8b5cf6; }
.activity-item.classified { border-left-color: #06b6d4; }
.activity-item.chunked { border-left-color: #f59e0b; }
.activity-item.embedded { border-left-color: #22c55e; }
.activity-item.routed { border-left-color: #10b981; }
.activity-item.error { border-left-color: var(--error); }

.activity-icon {
  font-size: 1.25rem;
  min-width: 24px;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.activity-details {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.activity-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.activity-duration {
  font-size: 0.7rem;
  padding: 0.125rem 0.5rem;
  background: var(--bg-card);
  border-radius: 4px;
  color: var(--secondary);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* SSE Status Indicator */
.sse-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: var(--bg);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.connected {
  background: var(--success);
  animation: statusPulse 2s infinite;
}

.status-dot.disconnected {
  background: var(--error);
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  50% { opacity: 0.8; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0); }
}

/* New Activity Animation */
.activity-item.new-activity {
  animation: slideIn 0.5s ease-out;
  background: #fef3c7;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive */
@media (max-width: 900px) {
  .dashboard-card.wide {
    grid-column: span 1;
  }

  .pipeline-container {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .pipeline-arrow {
    display: none;
  }
}

@media (max-width: 600px) {
  .dashboard-stats {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-icon {
    font-size: 1.75rem;
  }

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

/* =====================
   ANALYTICS SECTION
   ===================== */

.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.analytics-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Small Stats Grid */
.stats-grid.analytics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.stat-item-small {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
}

.stat-icon-small {
  font-size: 1.5rem;
}

.stat-value-small {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.stat-label-small {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Feedback Overview */
.feedback-overview {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.feedback-main-stat {
  text-align: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
  border-radius: 12px;
  min-width: 120px;
}

.feedback-big-number {
  display: block;
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
}

.feedback-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.feedback-details {
  flex: 1;
}

.feedback-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.feedback-row:last-child {
  border-bottom: none;
}

.feedback-count {
  font-weight: 600;
  font-size: 0.9rem;
}

.feedback-count.positive {
  color: var(--success);
}

.feedback-count.negative {
  color: var(--error);
}

/* MCP Chart */
.mcp-chart {
  padding: 1rem 0;
}

.mcp-bars {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  height: 120px;
  gap: 1rem;
}

.mcp-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.mcp-bar-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: flex-end;
  height: 100px;
}

.mcp-bar {
  width: 24px;
  border-radius: 4px 4px 0 0;
  transition: height 0.3s ease;
}

.mcp-bar.relevant {
  background: var(--success);
}

.mcp-bar.not-relevant {
  background: var(--error);
}

.mcp-day-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.mcp-legend {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
  font-size: 0.8rem;
}

.mcp-legend .legend-dot {
  width: 12px;
  height: 12px;
}

.legend-dot.relevant {
  background: var(--success);
}

.legend-dot.not-relevant {
  background: var(--error);
}
