/* StackScope Dashboard - Component Styles */

/* Log Stream Components */
.log-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.log-stream {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  height: 600px;
  overflow-y: auto;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  position: relative;
}

.log-entry {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
  align-items: start;
}

.log-entry:hover {
  background-color: var(--bg-secondary);
}

.log-timestamp {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.log-message {
  font-size: 0.875rem;
  line-height: 1.4;
  word-break: break-word;
}

.log-source {
  font-size: 0.75rem;
  font-weight: 600;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  white-space: nowrap;
}

.log-level {
  font-size: 0.75rem;
  font-weight: 700;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  white-space: nowrap;
  min-width: 50px;
  text-align: center;
}

/* Log level colors */
.log-level.error {
  background-color: var(--error);
  color: white;
}

.log-level.warn {
  background-color: var(--warning);
  color: white;
}

.log-level.info {
  background-color: var(--info);
  color: white;
}

.log-level.debug {
  background-color: var(--text-muted);
  color: white;
}

/* Log source colors */
.log-source.browser {
  background-color: #8b5cf6;
  color: white;
}

.log-source.worker {
  background-color: #06b6d4;
  color: white;
}

.log-source.github {
  background-color: #f59e0b;
  color: white;
}

.log-source.collector {
  background-color: #10b981;
  color: white;
}

/* Recent Activity */
.recent-activity {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow);
}

.recent-activity h3 {
  margin-bottom: var(--spacing-md);
  color: var(--text-primary);
  font-weight: 600;
}

.activity-feed {
  max-height: 400px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  align-items: start;
  gap: var(--spacing-md);
  padding: var(--spacing-md) 0;
  border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  font-size: 1.25rem;
  opacity: 0.8;
  flex-shrink: 0;
  margin-top: var(--spacing-xs);
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-message {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: var(--spacing-xs);
}

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

/* Sessions */
.sessions-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--spacing-lg);
  height: 600px;
}

.session-list {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-y: auto;
}

.session-item {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}

.session-item:hover {
  background-color: var(--bg-secondary);
}

.session-item.active {
  background-color: var(--accent-primary);
  color: white;
}

.session-id {
  font-size: 0.875rem;
  font-weight: 600;
  font-family: 'SF Mono', Monaco, monospace;
  margin-bottom: var(--spacing-xs);
}

.session-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-item.active .session-meta {
  color: rgba(255, 255, 255, 0.8);
}

.session-details {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  overflow-y: auto;
}

.session-timeline {
  position: relative;
}

.timeline-item {
  display: flex;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 24px;
  bottom: -16px;
  width: 2px;
  background-color: var(--border-color);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  flex-shrink: 0;
  margin-top: 2px;
  z-index: 1;
  position: relative;
}

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-message {
  font-size: 0.875rem;
  margin-bottom: var(--spacing-xs);
}

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

/* Performance Metrics */
.performance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--spacing-lg);
}

.metric-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow);
  height: 250px;
  display: flex;
  flex-direction: column;
}

.metric-card canvas {
  max-height: 200px !important;
  height: 200px !important;
  flex: 1;
}

.metric-card h3 {
  margin-bottom: var(--spacing-md);
  color: var(--text-primary);
  font-weight: 600;
}

.web-vitals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-md);
}

.vital {
  text-align: center;
  padding: var(--spacing-md);
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.vital-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--spacing-xs);
}

.vital-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-xs);
}

.vital-rating {
  font-size: 0.75rem;
  font-weight: 600;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.vital-rating.good {
  background-color: var(--success);
  color: white;
}

.vital-rating.needs-improvement {
  background-color: var(--warning);
  color: white;
}

.vital-rating.poor {
  background-color: var(--error);
  color: white;
}

/* Workflow Stats */
.workflow-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
}

.workflow-stat {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  text-align: center;
  box-shadow: var(--shadow);
}

.workflow-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--spacing-xs);
}

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

.workflow-list {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.workflow-item {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: var(--spacing-md);
  align-items: center;
}

.workflow-item:last-child {
  border-bottom: none;
}

.workflow-status {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.workflow-status.success { background-color: var(--success); }
.workflow-status.failure { background-color: var(--error); }
.workflow-status.skipped { background-color: var(--text-muted); }

.workflow-name {
  font-weight: 600;
  color: var(--text-primary);
}

.workflow-repo {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'SF Mono', Monaco, monospace;
}

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

/* Query Builder */
.query-builder {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--spacing-lg);
  height: 600px;
}

.query-form {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  overflow-y: auto;
}

.form-row {
  margin-bottom: var(--spacing-md);
}

.form-row.full-width {
  grid-column: 1 / -1;
}

.form-row label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
}

.form-row select[multiple] {
  height: 80px;
}

.form-row textarea {
  width: 100%;
  height: 100px;
  resize: vertical;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.75rem;
}

.query-results {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  overflow-y: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.results-table th {
  background-color: var(--bg-secondary);
  padding: var(--spacing-sm);
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  position: sticky;
  top: 0;
}

.results-table td {
  padding: var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.results-table tr:hover {
  background-color: var(--bg-secondary);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sessions-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .session-list {
    height: 300px;
  }
  
  .query-builder {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .log-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .log-controls > * {
    width: 100%;
  }
  
  .performance-grid {
    grid-template-columns: 1fr;
  }
  
  .web-vitals {
    grid-template-columns: 1fr;
  }
  
  .workflow-item {
    grid-template-columns: auto 1fr;
    gap: var(--spacing-sm);
  }
  
  .workflow-time {
    grid-column: 2;
    justify-self: end;
  }
}

/* Test Page Styles */
.test-status {
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  border-radius: var(--radius-md);
  background-color: var(--accent-secondary);
  border: 1px solid var(--accent-primary);
  color: var(--text-primary);
  font-weight: 500;
}

.test-status.success {
  background-color: var(--success-light, #f0f9ff);
  border-color: var(--success);
  color: var(--success);
}

.test-status.error {
  background-color: var(--error-light, #fef2f2);
  border-color: var(--error);
  color: var(--error);
}

.test-output-container {
  margin-bottom: var(--spacing-lg);
}

.test-output {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  font-family: var(--font-mono, 'Monaco', 'Menlo', 'Ubuntu Mono', monospace);
  font-size: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.4;
}

.test-sections {
  display: grid;
  gap: var(--spacing-lg);
}

.test-section {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow);
}

.test-section h3 {
  margin-bottom: var(--spacing-md);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1rem;
}

.test-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.test-buttons button {
  background-color: var(--accent-primary);
  color: white;
  border: none;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
}

.test-buttons button:hover {
  background-color: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.test-buttons button.error-button {
  background-color: var(--error);
}

.test-buttons button.error-button:hover {
  background-color: var(--error-hover, #dc2626);
}

.test-form-section {
  margin-top: var(--spacing-md);
  padding: var(--spacing-md);
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.test-form-section label {
  display: block;
  margin-bottom: var(--spacing-xs);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.test-form-section input,
.test-form-section textarea,
.test-form-section select {
  width: 100%;
  padding: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  box-sizing: border-box;
}

.test-form-section input:focus,
.test-form-section textarea:focus,
.test-form-section select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.session-info {
  display: grid;
  gap: var(--spacing-sm);
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm);
  background-color: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.info-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.info-value {
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-mono, 'Monaco', 'Menlo', 'Ubuntu Mono', monospace);
}

@media (max-width: 768px) {
  .test-buttons {
    flex-direction: column;
  }
  
  .test-buttons button {
    width: 100%;
  }
}