/* =============================================================================
   Pipeline Controller — Design System Tokens & Styles
   Based on VM Control Center / @toolr/ui-design dark-theme design system
   ============================================================================= */

/* Design tokens — semantic, purpose-based */
:root {
  --background: #000000;
  --surface: #141414;
  --surface-secondary: #0a0a0a;
  --surface-hover: #1a1a1a;
  --border: #383838;
  --border-subtle: #141414;
  --text-primary: rgba(255, 255, 255, 0.83);
  --text-secondary: rgba(255, 255, 255, 0.46);
  --text-tertiary: rgba(255, 255, 255, 0.64);
  --text-emphasis: #ffffff;
  --popover: rgba(0, 0, 0, 0.8);
  --dialog-backdrop: rgba(0, 0, 0, 0.95);
  --ring: #60a5fa;
}

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

body {
  background-color: var(--background);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

/* Surface containers */
.surface {
  background-color: var(--surface);
  border: 1px solid var(--border);
}

.surface-secondary {
  background-color: var(--surface-secondary);
}

/* Status badges — bordered outline with semi-transparent accent */
.status-running {
  background-color: rgba(34, 197, 94, 0.1);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-stopped {
  background-color: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-unknown {
  background-color: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.46);
  border: 1px solid var(--border);
}

/* Action buttons — bordered outline style */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.33;
  border-radius: 4px;
  border: 1px solid;
  background: transparent;
  transition: background-color 0.15s, border-color 0.15s;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-blue {
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}
.btn-blue:hover:not(:disabled) {
  background-color: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.5);
}

.btn-green {
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.3);
}
.btn-green:hover:not(:disabled) {
  background-color: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.5);
}

.btn-red {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-red:hover:not(:disabled) {
  background-color: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
}

.btn-neutral {
  color: var(--text-tertiary);
  border-color: var(--border);
}
.btn-neutral:hover:not(:disabled) {
  background-color: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Icon action buttons */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  transition: background-color 0.15s, border-color 0.15s;
  cursor: pointer;
  font-size: 13px;
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.icon-btn-blue {
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}
.icon-btn-blue:hover:not(:disabled) {
  background-color: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.5);
}

.icon-btn-red {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}
.icon-btn-red:hover:not(:disabled) {
  background-color: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
}

.icon-btn-green {
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.3);
}
.icon-btn-green:hover:not(:disabled) {
  background-color: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.5);
}

.icon-btn-orange {
  color: #fb923c;
  border-color: rgba(249, 115, 22, 0.3);
}
.icon-btn-orange:hover:not(:disabled) {
  background-color: rgba(249, 115, 22, 0.15);
  border-color: rgba(249, 115, 22, 0.5);
}

.icon-btn-neutral {
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.1);
}
.icon-btn-neutral:hover:not(:disabled) {
  background-color: var(--surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

/* Form inputs — dark themed */
.input {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  transition: border-color 0.15s;
  width: 100%;
}

.input:focus {
  outline: none;
  border-color: #3b82f6;
}

.input::placeholder {
  color: var(--text-secondary);
}

/* Modal styles */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: var(--dialog-backdrop);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.hidden { display: none; }

.modal-dialog {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 12px 20px;
  background-color: var(--surface-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Table styles */
.dark-table {
  width: 100%;
  border-collapse: collapse;
}

.dark-table thead {
  border-bottom: 1px solid var(--border);
}

.dark-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dark-table td {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
}

.dark-table tbody tr:hover {
  background-color: var(--surface-hover);
}

.dark-table tbody tr:last-child td {
  border-bottom: none;
}

/* Tab styles */
.tab {
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: #60a5fa;
  border-bottom-color: #3b82f6;
}

/* Loading spinner */
.spinner {
  border: 2px solid var(--border);
  border-top-color: #3b82f6;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  animation: spin 0.8s linear infinite;
}

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

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
}

.badge-blue {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.badge-green {
  background-color: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

/* Info boxes */
.info-box {
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 500;
}

.info-box-yellow {
  background-color: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.2);
  color: #fde047;
}

.info-box-red {
  background-color: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  border-radius: 4px;
  border: 1px solid;
  font-size: 12px;
  font-weight: 500;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-success {
  background-color: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

.toast-error {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.toast-info {
  background-color: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

/* Link styles */
a.accent-link {
  color: #60a5fa;
  text-decoration: none;
  transition: color 0.15s;
}

a.accent-link:hover {
  color: #93c5fd;
}

/* Tooltip */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--popover);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 4px;
  border: 1px solid var(--border);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 50;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* Focus styles */
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Pipeline state badges */
.pipeline-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.pipeline-state-done {
  background-color: rgba(34, 197, 94, 0.1);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.pipeline-state-failed {
  background-color: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.pipeline-state-active {
  background-color: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.pipeline-state-merge {
  background-color: rgba(234, 179, 8, 0.1);
  color: #fde047;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.pipeline-state-idle {
  background-color: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.46);
  border: 1px solid var(--border);
}

/* Pipeline stats bar */
.pipeline-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.pipeline-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  min-width: 100px;
}

.pipeline-stat-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-emphasis);
  line-height: 1;
}

.pipeline-stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Pipeline stuck warning */
.pipeline-stuck-banner {
  background-color: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.2);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

/* Pipeline expandable row */
.pipeline-expand-row td {
  padding: 0 !important;
  border-bottom: 1px solid var(--border-subtle) !important;
}

.pipeline-expand-content {
  padding: 12px 16px;
  background: var(--surface-secondary);
}

/* Pipeline clickable row */
.dark-table tbody tr.pipeline-run-row {
  cursor: pointer;
}

.dark-table tbody tr.pipeline-run-row:hover {
  background-color: var(--surface-hover);
}

/* Container */
.container-main {
  max-width: 100%;
  margin: 0 auto;
  padding: 24px;
}

/* Navigation */
.navbar {
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-emphasis);
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.tab-group {
  display: flex;
  gap: 2px;
}

/* Section */
.section {
  margin-top: 16px;
}

/* Form group */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

/* Tag / chip for review focuses */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.1);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

/* Health dot */
.health-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.health-dot-green { background-color: #4ade80; }
.health-dot-red { background-color: #f87171; }
.health-dot-gray { background-color: rgba(255, 255, 255, 0.2); }

/* Primary badge for repos */
.primary-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 500;
  border-radius: 3px;
  background: rgba(34, 197, 94, 0.1);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state i {
  font-size: 32px;
  margin-bottom: 12px;
  display: block;
}

.empty-state h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-emphasis);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 12px;
}

/* Loading state */
.loading-state {
  text-align: center;
  padding: 48px 24px;
}

.loading-state p {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Utility classes */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.ml-auto { margin-left: auto; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-secondary { color: var(--text-secondary); }
.text-emphasis { color: var(--text-emphasis); }
.font-medium { font-weight: 500; }
.rounded-lg { border-radius: 8px; }
.overflow-x-auto { overflow-x: auto; }

/* Scan tree */
.scan-tree-node {
  display: flex;
  align-items: center;
  padding: 3px 12px;
  gap: 4px;
  font-size: 12px;
  min-height: 26px;
}

.scan-tree-node:hover {
  background-color: var(--surface-hover);
}

.scan-tree-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 9px;
  border-radius: 3px;
}

.scan-tree-chevron:hover {
  color: var(--text-primary);
  background-color: var(--surface-hover);
}

.scan-tree-spacer {
  width: 16px;
  flex-shrink: 0;
}

.scan-tree-checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 13px;
  border-radius: 3px;
}

.scan-tree-checkbox:hover {
  opacity: 0.75;
}

.scan-tree-icon {
  flex-shrink: 0;
  font-size: 12px;
  margin-right: 2px;
}

.scan-tree-label {
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scan-tree-remote {
  color: var(--text-secondary);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

.scan-tree-children.hidden {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  .container-main { padding: 12px; }
  .pipeline-stats { flex-direction: column; }
  .dark-table thead { display: none; }
  .dark-table tbody tr {
    display: block;
    padding: 12px;
    border-bottom: 1px solid var(--border);
  }
  .dark-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    border-bottom: none;
  }
  .dark-table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    margin-right: 12px;
  }
}
