@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #0a0a0a;
  --bg-surface: #111111;
  --bg-hover: #1a1a1a;
  --bg-active: #222222;
  --border: #2a2a2a;
  --border-light: #333333;
  --text: #e0e0e0;
  --text-dim: #888888;
  --text-muted: #555555;
  --accent: #00ff88;
  --accent-dim: #00cc6a;
  --accent-bg: rgba(0, 255, 136, 0.08);
  --red: #ff4444;
  --red-dim: #cc3333;
  --yellow: #ffaa00;
  --blue: #4488ff;
  --purple: #aa66ff;
}

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

body {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dim); text-decoration: underline; }

/* Layout */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-brand h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 1px;
}

.sidebar-brand .version {
  font-size: 10px;
  color: var(--text-muted);
}

.nav-section {
  padding: 8px 0;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 4px 16px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  color: var(--text-dim);
  font-size: 12px;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-hover);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-bg);
}

.nav-link .icon { width: 16px; text-align: center; }

.main {
  margin-left: 220px;
  flex: 1;
  padding: 24px;
  min-height: 100vh;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.page-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.page-header .subtitle {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-surface);
  color: var(--text);
}

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

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }

.btn-danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn-danger:hover { background: rgba(255, 68, 68, 0.1); }

.btn-sm { padding: 3px 8px; font-size: 11px; }

.btn-group { display: flex; gap: 8px; }

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 12px;
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
}

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

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
}

/* Tables */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

tr:hover td { background: var(--bg-hover); }

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-running { background: rgba(68, 136, 255, 0.15); color: var(--blue); }
.badge-completed { background: rgba(0, 255, 136, 0.15); color: var(--accent); }
.badge-failed { background: rgba(255, 68, 68, 0.15); color: var(--red); }
.badge-timeout { background: rgba(255, 170, 0, 0.15); color: var(--yellow); }
.badge-enabled { background: rgba(0, 255, 136, 0.15); color: var(--accent); }
.badge-disabled { background: rgba(85, 85, 85, 0.15); color: var(--text-muted); }

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
}

textarea.form-control {
  min-height: 120px;
  resize: vertical;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}

.checkbox-label:hover { border-color: var(--border-light); }
.checkbox-label input:checked + span { color: var(--accent); }

/* Modal / Slide panel */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
}

.modal-backdrop.active { display: block; }

.slide-panel {
  position: fixed;
  top: 0;
  right: -600px;
  width: 600px;
  max-width: 92vw;
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  z-index: 101;
  transition: right 0.3s ease;
  overflow-y: auto;
  padding: 24px;
}

.slide-panel.active { right: 0; }

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

.slide-panel-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  font-family: inherit;
}

/* Run log view */
.run-log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  max-height: 600px;
  overflow-y: auto;
  font-size: 12px;
}

.run-msg {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.run-msg:last-child { border-bottom: none; }

.run-msg-role {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.run-msg-role.system { color: var(--purple); }
.run-msg-role.user { color: var(--blue); }
.run-msg-role.assistant { color: var(--accent); }
.run-msg-role.tool { color: var(--yellow); }

.run-msg-content {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim);
}

/* Event feed */
.event-feed {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
  font-size: 11px;
}

.event-item {
  padding: 4px 0;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.event-item:last-child { border-bottom: none; }
.event-time { color: var(--text-muted); margin-right: 8px; }
.event-type { color: var(--accent); font-weight: 600; margin-right: 8px; }

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

.empty-state .icon { font-size: 32px; margin-bottom: 12px; }
.empty-state p { font-size: 13px; }

/* Grid layout helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Pipeline steps visual */
.pipeline-steps {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pipeline-step {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
}

.pipeline-arrow { color: var(--text-muted); font-size: 14px; }

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loading { animation: pulse 1.5s infinite; }

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

.toast {
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  animation: slideIn 0.3s ease;
}

.toast-success { border-color: var(--accent); }
.toast-error { border-color: var(--red); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Tags */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  line-height: 1.4;
  white-space: nowrap;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-height: 36px;
}

.tag-input-wrap .tag {
  cursor: default;
}

.tag-input-wrap .tag .tag-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 12px;
  line-height: 1;
  margin-left: 2px;
}

.tag-input-wrap .tag .tag-remove:hover {
  opacity: 1;
}

.tag-add-area {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tag-add-area input {
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  outline: none;
  width: 100px;
}

.tag-add-area input::placeholder {
  color: var(--text-muted);
}

.tag-color-picker {
  display: flex;
  gap: 3px;
  align-items: center;
}

.tag-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.1s;
}

.tag-color-dot:hover,
.tag-color-dot.selected {
  border-color: var(--text);
}

/* Tag filter bar */
.tag-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 16px;
}

.tag-filter-bar .tag {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.tag-filter-bar .tag:hover,
.tag-filter-bar .tag.active {
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
