/* ================================================================
   VektorIQ Draftsman — Clean UX Overhaul
   Progressive disclosure, reduced visual noise, clear flow
   ================================================================ */

/* --- Variables --- */
:root {
  --bg:          #0a0e14;
  --bg-card:     #111827;
  --bg-input:    #0d1117;
  --bg-hover:    #1a2234;
  --accent:      #00d4c8;
  --accent-dim:  rgba(0, 212, 200, 0.12);
  --accent-mid:  rgba(0, 212, 200, 0.25);
  --text:        #e6edf3;
  --text2:       #8b949e;
  --text3:       #484f58;
  --error:       #ff6b6b;
  --error-dim:   rgba(255, 107, 107, 0.15);
  --success:     #00ff88;
  --success-dim: rgba(0, 255, 136, 0.15);
  --warning:     #ffd93d;
  --border:      #21262d;
  --border2:     #30363d;
  --mono:        'JetBrains Mono', 'Fira Code', monospace;
  --sans:        'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius:      8px;
  --radius-lg:   12px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* --- App Shell --- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 24px 48px;
}

/* --- Top Bar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 1.5px;
}
.logo-name { text-transform: uppercase; }
.topbar-divider {
  width: 1px;
  height: 16px;
  background: var(--border2);
}
.topbar-subtitle {
  font-size: 0.8rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--mono);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text3);
}
.topbar-status .dot {
  width: 6px; height: 6px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.5; } }

.topbar-context {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--accent-dim);
  border: 1px solid rgba(0,212,200,0.2);
  border-radius: 6px;
}
.context-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  font-family: var(--mono);
}
.context-value {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Step Navigation --- */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 150ms ease;
}
.step .step-num {
  width: 26px; height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--border);
  color: var(--text3);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 150ms ease;
}
.step .step-label {
  font-size: 0.8rem;
  color: var(--text3);
  font-weight: 500;
  transition: all 150ms ease;
}
.step.active .step-num {
  background: var(--accent);
  color: var(--bg);
}
.step.active .step-label {
  color: var(--text);
}
.step.done .step-num {
  background: var(--success-dim);
  color: var(--success);
}
.step.done .step-label {
  color: var(--success);
}
.step-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
}
.step-line.done { background: var(--success); }

/* --- Panel --- */
.panel {
  width: 100%;
  max-width: 720px;
  animation: fadeIn 300ms ease;
}
.panel.hidden { display: none; }
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

.panel-inner {
  padding-top: 32px;
}
.panel-header {
  margin-bottom: 24px;
}
.panel-header h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.panel-header p {
  color: var(--text2);
  font-size: 0.9rem;
}
.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* --- Card --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

/* --- Form Fields --- */
.field-group {
  margin-bottom: 20px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.field-row.three-col {
  grid-template-columns: 1fr 1fr 1fr;
}
.label {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
  margin-bottom: 6px;
}
.req { color: var(--error); }
.input {
  display: block;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.input::placeholder { color: var(--text3); }
.input-readonly {
  background: var(--bg-card);
  color: var(--accent);
  border-color: var(--border);
  cursor: default;
}
.textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}
.hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text3);
  margin-top: 4px;
}
select.input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b949e' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Validation */
.field-group.error .input { border-color: var(--error); box-shadow: 0 0 0 3px var(--error-dim); }
.field-group.error .label { color: var(--error); }
.field-error {
  font-size: 0.75rem;
  color: var(--error);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --- Variant Selector --- */
.variant-selector {
  display: flex;
  gap: 8px;
  align-items: center;
}
.variant-opt {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text2);
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 150ms ease;
}
.variant-opt:hover { border-color: var(--border2); color: var(--text); }
.variant-opt.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.variant-custom {
  width: 70px;
  text-align: center;
  padding: 8px;
}
.variant-custom-btn {
  font-size: 0.7rem;
  padding: 8px 12px;
}

/* --- Pipeline Preview --- */
.pipeline-preview {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-top: 8px;
}
.pipeline-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
}
.pipeline-stages {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.stage-chip {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid rgba(0,212,200,0.15);
}
.stage-arrow {
  color: var(--text3);
  font-size: 0.75rem;
}

/* --- Timeline --- */
.timeline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 20px 0;
  margin-bottom: 16px;
}
.tl-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.tl-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--border2);
  border: 2px solid var(--border2);
  transition: all 250ms ease;
}
.tl-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text3);
  letter-spacing: 0.5px;
  transition: color 250ms ease;
}
.tl-connector {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
  margin-bottom: 20px;
  transition: background 250ms ease;
}

/* Timeline states */
.tl-stage.active .tl-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-mid);
}
.tl-stage.active .tl-label { color: var(--accent); }
.tl-stage.done .tl-dot {
  background: var(--success);
  border-color: var(--success);
}
.tl-stage.done .tl-label { color: var(--success); }
.tl-stage.failed .tl-dot {
  background: var(--error);
  border-color: var(--error);
}
.tl-stage.failed .tl-label { color: var(--error); }
.tl-connector.done { background: var(--success); }

/* --- Agent Section --- */
.agents-section {
  margin-bottom: 16px;
}
.agents-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 150ms ease;
}
.agents-toggle:hover { border-color: var(--border2); color: var(--text); }
.toggle-icon { transition: transform 150ms ease; }
.agents-toggle.open .toggle-icon { transform: rotate(180deg); }

.agent-grid {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 10px 0 0;
}
.agent-grid.open { display: grid; }

/* Agent Card (minimal) */
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.agent-name {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.agent-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text3);
  transition: all 250ms ease;
}
.agent-dot.idle { background: var(--text3); }
.agent-dot.pending { background: var(--warning); animation: pulse 1.5s infinite; }
.agent-dot.running { background: var(--accent); animation: pulse 1s infinite; box-shadow: 0 0 6px var(--accent); }
.agent-dot.success { background: var(--success); box-shadow: 0 0 6px var(--success); }
.agent-dot.failed { background: var(--error); box-shadow: 0 0 6px var(--error); }
.agent-dot.canceled { background: var(--text3); }

.agent-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.agent-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}
.agent-card.success .agent-fill { background: var(--success); width: 100% !important; }
.agent-card.failed .agent-fill  { background: var(--error); width: 100% !important; }

.agent-msg {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Log Section --- */
.log-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
}
.log-badge {
  padding: 2px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.6rem;
  color: var(--text3);
  transition: all 250ms ease;
}
.log-badge.running { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.log-badge.success { color: var(--success); border-color: var(--success); background: var(--success-dim); }
.log-badge.failed  { color: var(--error); border-color: var(--error); background: var(--error-dim); }

.log-body {
  padding: 12px 16px;
  max-height: 200px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.7;
}
.log-line {
  color: var(--text2);
}
.log-line .ts {
  color: var(--text3);
  margin-right: 6px;
}
.log-line.info   { color: var(--text2); }
.log-line.success { color: var(--success); }
.log-line.error  { color: var(--error); }
.log-line.idle   { color: var(--text3); }

/* --- Results --- */
.results-summary {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.8;
}
.results-summary .result-line {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.results-summary .result-line:last-child { border-bottom: none; }
.result-key { color: var(--text2); }
.result-val { color: var(--text); }
.result-val.success { color: var(--success); }
.result-val.error   { color: var(--error); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 150ms ease;
  text-decoration: none;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: transparent;
  color: var(--accent);
  box-shadow: 0 0 20px var(--accent-mid);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--border2); color: var(--text); }
.btn .spinner {
  width: 14px; height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* --- Project List (Home) --- */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.project-list-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text2);
}

.empty-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
}

.project-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  transition: border-color 0.2s, background 0.2s;
}

.project-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

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

.pc-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-meta {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text2);
}

.pc-land {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pc-land.land-res { background: rgba(0,149,255,0.15); color: #0095ff; }
.pc-land.land-com { background: rgba(255,149,0,0.15); color: #ff9500; }
.pc-land.land-ind { background: rgba(0,212,200,0.15); color: var(--accent); }
.pc-land.land-agr { background: rgba(0,255,136,0.15); color: var(--success); }
.pc-land.land-mix { background: rgba(255,217,61,0.15); color: var(--warning); }

.pc-detail {
  color: var(--text3);
}

.pc-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.pc-status {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}

.pc-status.status-created { background: var(--accent-dim); color: var(--accent); }
.pc-status.status-running { background: rgba(255,217,61,0.15); color: var(--warning); animation: pulse 2s infinite; }
.pc-status.status-success { background: var(--success-dim); color: var(--success); }
.pc-status.status-failed { background: var(--error-dim); color: var(--error); }

.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}

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

/* --- Footer --- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text3);
}
.footer-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}
.footer-meta code {
  font-family: var(--mono);
  font-size: 0.65rem;
  padding: 2px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
}

/* --- Land type colours (used on chips) --- */
.land-res .stage-chip { color: #00f2ff; background: rgba(0,242,255,0.1); border-color: rgba(0,242,255,0.15); }
.land-com .stage-chip { color: #9400d3; background: rgba(148,0,211,0.1); border-color: rgba(148,0,211,0.15); }
.land-ind .stage-chip { color: #ff6b6b; background: rgba(255,107,107,0.1); border-color: rgba(255,107,107,0.15); }
.land-agr .stage-chip { color: #00ff88; background: rgba(0,255,136,0.1); border-color: rgba(0,255,136,0.15); }
.land-mix .stage-chip { color: #ffd700; background: rgba(255,215,0,0.1); border-color: rgba(255,215,0,0.15); }

/* --- Responsive --- */
@media (max-width: 768px) {
  .main { padding: 0 12px 32px; }
  .panel { max-width: 100%; }
  .field-row, .field-row.three-col { grid-template-columns: 1fr; }
  .steps { gap: 0; padding: 12px 12px; }
  .step .step-label { display: none; }
  .step-line { width: 24px; }
  .agent-grid { grid-template-columns: 1fr 1fr; }
  .variant-selector { flex-wrap: wrap; }
  .timeline { overflow-x: auto; }
}
