/* === Terminal Pane === */
#term-pane {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 850;
  background: var(--bg);
  flex-direction: column;
}

#term-pane.open {
  display: flex;
}

/* === Header === */
#term-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#term-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan-glow);
  letter-spacing: 3px;
  margin-right: auto;
}

#term-status {
  font-size: 10px;
  color: var(--amber-dim);
  letter-spacing: 0.5px;
}

#term-close {
  background: none;
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  font-family: var(--font);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 8px;
  line-height: 1;
  transition: background 0.12s, border-color 0.12s;
  flex-shrink: 0;
}

#term-close:hover {
  background: rgba(0, 229, 255, 0.15);
  border-color: var(--cyan);
}

/* === Output === */
#term-output {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  font-size: 12px;
  line-height: 1.6;
}

/* === Output Lines === */
.term-line {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--amber);
}

.term-line-cmd {
  color: var(--amber);
  opacity: 0.6;
  margin-top: 4px;
}

.term-line-heading {
  color: var(--cyan);
  font-weight: 700;
}

.term-line-dim {
  color: var(--amber-dim);
}

.term-line-error {
  color: #ff4444;
}

.term-line-success {
  color: var(--cyan);
}

.term-line-link {
  color: var(--cyan-dim);
  cursor: pointer;
  transition: color 0.12s, text-shadow 0.12s;
}

.term-line-link:hover {
  color: var(--cyan);
  text-shadow: 0 0 6px var(--cyan-glow);
}

.term-line-yaml pre {
  margin: 0;
  white-space: pre;
  font-family: var(--font);
  font-size: 11px;
  line-height: 1.5;
  color: var(--amber);
}
#term-output .y-key     { color: var(--cyan); }
#term-output .y-colon   { color: var(--amber-dim); }
#term-output .y-str     { color: var(--amber); }
#term-output .y-num     { color: #f8a; }
#term-output .y-bool    { color: #f8a; }
#term-output .y-bullet  { color: var(--cyan-dim); }
#term-output .y-pipe    { color: var(--cyan-dim); }
#term-output .y-comment { color: var(--amber-dim); font-style: italic; }
#term-output .y-tag     { color: #c9a; }
#term-output .y-kw      { color: var(--cyan); font-weight: 700; }
#term-output .y-slit    { color: #a8e6a0; }
#term-output .y-cmt     { color: var(--amber-dim); font-style: italic; }

.term-line-separator {
  color: var(--border);
  opacity: 0.6;
}

/* === Table inside terminal === */
.term-table {
  border-collapse: collapse;
  font-size: 11px;
  margin: 4px 0;
}

.term-table th {
  color: var(--cyan);
  text-align: left;
  padding: 2px 12px 2px 0;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  white-space: nowrap;
}

.term-table td {
  color: var(--amber);
  padding: 2px 12px 2px 0;
  white-space: nowrap;
}

.term-table td.dim {
  color: var(--amber-dim);
}

/* === Input Line === */
#term-input-line {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.term-prompt {
  color: var(--cyan);
  font-weight: 700;
  font-size: 12px;
  margin-right: 8px;
  flex-shrink: 0;
}

#term-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--amber);
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  caret-color: var(--cyan);
  line-height: 1.4;
}

#term-input::placeholder {
  color: var(--amber-dim);
  opacity: 0.4;
}

/* === Tab Completion Dropdown === */
#term-completions {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  border: 1px solid var(--border);
  background: var(--bg);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
}

#term-completions.open {
  display: block;
}

.term-comp-item {
  padding: 3px 16px;
  font-size: 11px;
  color: var(--amber-dim);
  cursor: pointer;
  transition: background 0.08s;
}

.term-comp-item:hover {
  background: rgba(255, 176, 0, 0.06);
  color: var(--amber);
}

.term-comp-item.selected {
  background: rgba(0, 229, 255, 0.08);
  color: var(--cyan);
}

/* === Terminal Bubble Button === */
#term-bubble {
  background: var(--bg);
  border: 1px solid var(--amber-dim);
  color: var(--amber);
  font-family: var(--font);
  font-size: 12px;
  padding: 2px 10px;
  cursor: pointer;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

#term-bubble:hover {
  border-color: var(--amber);
  color: var(--fg);
}

/* Hide bubble when terminal is open */
#term-pane.open ~ #bottom-controls #term-bubble {
  display: none;
}

/* === AI Streaming === */
.term-ai-stream {
  border-left: 2px solid var(--cyan-dim);
  padding-left: 10px;
  margin: 4px 0;
}

.term-ai-stream p { margin: 0 0 6px; }
.term-ai-stream p:last-child { margin-bottom: 0; }
.term-ai-stream strong { color: var(--cyan); }
.term-ai-stream code {
  background: rgba(255, 176, 0, 0.08);
  border: 1px solid var(--border);
  padding: 0 4px;
  font-size: 11px;
}
.term-ai-stream pre {
  background: rgba(255, 176, 0, 0.04);
  border: 1px solid var(--border);
  padding: 8px;
  font-size: 11px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  margin: 4px 0;
  font-family: var(--font);
}
.term-ai-stream ul, .term-ai-stream ol {
  margin: 4px 0;
  padding-left: 20px;
}
.term-ai-stream li { margin: 2px 0; }
.term-ai-stream li::marker { color: var(--cyan); }

/* === DIME Instance Status === */
.term-status-running { color: var(--cyan); }
.term-status-stopped { color: var(--amber-dim); }
.term-status-faulted { color: #ff4444; }

.term-perf-watch {
  border-left: 2px solid var(--cyan-dim);
  padding-left: 10px;
  margin: 4px 0;
}

/* === Desktop Only === */
@media (max-width: 768px) {
  #term-bubble {
    display: none !important;
  }
  #term-pane {
    display: none !important;
  }
}
