/* ── CMS Builder Control Panel ── */
/* Monochromatic dark CLI theme — mirrors web-rebuilder */

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

:root {
  --bg-0: #0a0a0a;
  --bg-1: #111111;
  --bg-2: #1a1a1a;
  --bg-3: #222222;
  --border: #2a2a2a;
  --border-light: #333333;
  --border-focus: #555555;
  --text-0: #e0e0e0;
  --text-1: #999999;
  --text-2: #666666;
  --text-3: #444444;
  --accent: #00ff88;
  --accent-dim: #00cc6a;
  --accent-bg: #00ff8810;
  --error: #ff4444;
  --error-bg: #ff444410;
  --warning: #ffaa00;
  --warning-bg: #ffaa0010;
  --info: #4488ff;
  --info-bg: #4488ff10;
  --font: 'JetBrains Mono', monospace;
  --radius: 2px;
}

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

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent);
  color: var(--bg-0);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-2); }

/* ── Login ── */

.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-box {
  width: 400px;
  padding: 40px;
}

.login-box .prompt-line {
  color: var(--text-2);
  margin-bottom: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.login-box h1 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-0);
  margin-bottom: 32px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.login-box h1 span { color: var(--accent); }

.login-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.login-input-row .cursor {
  color: var(--accent);
  font-weight: 700;
}

.login-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-0);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 0;
  outline: none;
}

.login-input-row input:focus { border-bottom-color: var(--accent); }

.login-error {
  color: var(--error);
  font-size: 11px;
  margin-top: 8px;
  min-height: 16px;
}

.login-hint {
  color: var(--text-2);
  font-size: 11px;
  margin-top: 24px;
}

/* ── Layout ── */

.app-shell {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header .logo {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.sidebar-header .sub {
  font-size: 10px;
  color: var(--text-2);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--text-1);
  text-decoration: none;
  font-size: 12px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 0.1s;
}

.nav-item:hover {
  color: var(--text-0);
  background: var(--bg-2);
}

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

.nav-item .icon {
  width: 16px;
  text-align: center;
  font-size: 11px;
}

.nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-3);
  padding: 16px 16px 4px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-footer .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

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

.sidebar-footer button {
  background: none;
  border: none;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 10px;
  cursor: pointer;
}
.sidebar-footer button:hover { color: var(--text-0); }

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-width: 0;
}

/* ── Page Header ── */

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

.page-header h2 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-0);
}

/* ── Cards ── */

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-1);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

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

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

.stat-card .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-2);
  margin-bottom: 4px;
}

.stat-card .value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-0);
}

.stat-card .value.accent { color: var(--accent); }

/* ── Tables ── */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead th {
  text-align: left;
  padding: 8px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
  vertical-align: middle;
}

tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

tbody tr:hover { background: var(--bg-2); }
tbody tr:hover td { color: var(--text-0); }

/* ── Badges ── */

.badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge.completed, .badge.deployed, .badge.ready { color: var(--accent); background: var(--accent-bg); }
.badge.failed { color: var(--error); background: var(--error-bg); }
.badge.generating, .badge.building, .badge.deploying, .badge.auditing, .badge.verifying {
  color: var(--warning);
  background: var(--warning-bg);
  animation: pulse 2s ease-in-out infinite;
}
.badge.queued, .badge.none { color: var(--text-2); background: var(--bg-3); }
.badge.cancelled { color: var(--warning); background: var(--warning-bg); }

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

/* ── Buttons ── */

.btn {
  font-family: var(--font);
  font-size: 11px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text-0);
  cursor: pointer;
  transition: all 0.1s;
  white-space: nowrap;
}

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

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

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

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

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

/* ── Search ── */

.search-input {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-0);
  font-family: var(--font);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  min-width: 250px;
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-3); }

/* ── Pipeline ── */

.pipeline-steps {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
}

.pipeline-step {
  flex: 1;
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
}

.pipeline-step.done { background: var(--accent); }
.pipeline-step.active { background: var(--warning); animation: pulse 2s ease-in-out infinite; }
.pipeline-step.error { background: var(--error); }

/* ── Detail Views ── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-rows {
  padding: 8px 0;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-2); }

/* ── Pipeline Detail ── */

.pipeline-detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
}

.pipeline-detail-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-2);
}

.pipeline-detail-step .step-num {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.pipeline-detail-step.done {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.pipeline-detail-step.done .step-num {
  border-color: var(--accent);
  color: var(--accent);
}

.pipeline-detail-step.active {
  border-color: var(--warning);
  color: var(--warning);
  background: var(--warning-bg);
}

.pipeline-detail-step.active .step-num {
  border-color: var(--warning);
  color: var(--warning);
}

.pipeline-detail-step.error {
  border-color: var(--error);
  color: var(--error);
}

.pipeline-detail-step.error .step-num {
  border-color: var(--error);
  color: var(--error);
}

/* ── Console ── */

.console-output {
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.6;
  color: #b5b5b5;
  min-height: 300px;
  max-height: 600px;
  overflow-y: auto;
}

.console-output pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: var(--font);
  font-size: 11px;
}

/* ── Builder Card ── */

.builder-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  cursor: pointer;
  transition: all 0.1s;
}

.builder-card:hover {
  border-color: var(--border-light);
  background: var(--bg-2);
}

.builder-card .builder-info { flex: 1; min-width: 0; }

.builder-card .builder-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-0);
  margin-bottom: 2px;
}

.builder-card .builder-desc {
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 8px;
}

/* ── Agent Grid ── */

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}

.agent-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: all 0.1s;
}

.agent-card:hover {
  border-color: var(--border-light);
  background: var(--bg-2);
}

.agent-card .agent-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.agent-card .agent-emoji { font-size: 16px; }

.agent-card .agent-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-0);
}

.agent-card .agent-desc {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-card .agent-category {
  font-size: 10px;
  color: var(--text-2);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Filters ── */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-chip {
  font-size: 10px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-1);
  color: var(--text-1);
  cursor: pointer;
  transition: all 0.1s;
  font-family: var(--font);
}

.filter-chip:hover {
  border-color: var(--border-light);
  color: var(--text-0);
}

.filter-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* ── Modal ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
}

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

.modal-header h3 {
  font-size: 14px;
  font-weight: 500;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 18px;
  cursor: pointer;
  font-family: var(--font);
}

.modal-close:hover { color: var(--text-0); }

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

/* ── Tabs ── */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.1s;
  font-family: var(--font);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

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

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Log / Code Viewer ── */

.log-viewer {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-1);
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.code-editor {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-0);
  width: 100%;
  min-height: 300px;
  resize: vertical;
  outline: none;
}

.code-editor:focus { border-color: var(--accent); }

/* ── Detail Grid (key/val) ── */

.detail-grid .key {
  color: var(--text-2);
}

.detail-grid .val {
  color: var(--text-0);
  word-break: break-all;
}

.detail-grid .val a {
  color: var(--accent);
  text-decoration: none;
}

.detail-grid .val a:hover { text-decoration: underline; }

.page-header h2 .dim {
  color: var(--text-2);
  font-weight: 400;
}

/* ── Empty State ── */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-2);
}

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

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

/* ── Toast ── */

.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 11px;
  color: var(--text-0);
  animation: slideIn 0.2s ease;
  max-width: 360px;
}

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

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

/* ── Responsive ── */

@media (max-width: 768px) {
  .sidebar { width: 48px; min-width: 48px; }
  .nav-item span { display: none; }
  .nav-item .icon { font-size: 14px; }
  .sidebar-header .logo { font-size: 10px; letter-spacing: 0; }
  .sidebar-header .sub { display: none; }
  .sidebar-footer { padding: 8px; justify-content: center; }
  .sidebar-footer button { display: none; }
  .main-content { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
