/* ── Terminal panel ──────────────────────────────────────── */
#terminal-panel {
  flex-shrink: 0;
  height: var(--terminal-h, 15vh);
  min-height: 70px;   /* header 32px + input-row ~32px + border 1px = 65px, add buffer */
  max-height: 45vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border-top: 1px solid var(--border, #e2e8f0);
}

/* ── Resize handle ───────────────────────────────────────── */
.terminal-resize-handle {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  cursor: ns-resize;
  z-index: 30;
  transition: background 0.15s;
}
.terminal-resize-handle:hover,
.terminal-resize-handle.dragging {
  background: rgba(87, 171, 90, 0.22);
}

/* ── Header — compact, matches app design language ────────── */
.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 0 10px;
  height: 32px;
  flex-shrink: 0;
  background: var(--surface, #ffffff);
  border-bottom: 1px solid var(--border, #e2e8f0);
  user-select: none;
}

.terminal-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #94a3b8);
}

/* ── Status dot ──────────────────────────────────────────── */
.terminal-status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #cbd5e1;
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.terminal-status-dot.running {
  background: #e3b341;
  box-shadow: 0 0 5px rgba(227, 179, 65, 0.6);
}
.terminal-status-dot.waiting {
  background: var(--term-prompt, #57ab5a);
  box-shadow: 0 0 6px rgba(87, 171, 90, 0.8);
  animation: term-dot-pulse 1s ease-in-out infinite;
}

@keyframes term-dot-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Header buttons ──────────────────────────────────────── */
.terminal-header .sc-toolbar { gap: 1px; }
.terminal-header .sc-btn {
  width: 22px;
  height: 22px;
  color: var(--text-muted, #94a3b8);
}
.terminal-header .sc-btn:hover {
  background: rgba(0,0,0,0.06);
  color: var(--text, #102040);
}

/* ── Body — flat, theme-aware ────────────────────────────── */
.terminal-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--code-bg, #f8fafc);
  font-family: "JetBrains Mono", "Menlo", "Courier New", monospace;
  font-size: 0.78rem;
}

/* ── Output area ─────────────────────────────────────────── */
.terminal-output {
  flex: 1;
  min-height: 0;          /* allows shrinking to 0 when panel is tiny */
  overflow-y: auto;
  padding: 8px 12px 4px;
  line-height: 1.6;
  color: var(--text, #102040);
  scrollbar-width: thin;
  scrollbar-color: var(--border, #e2e8f0) transparent;
}

.term-line {
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 1.2em;
}

.term-echo { opacity: 0.65; }

.term-prompt-inline {
  color: var(--term-prompt, #57ab5a);
  user-select: none;
}

/* ANSI colour spans */
.term-red     { color: #dc2626; }
.term-green   { color: var(--term-accent, #16a34a); }
.term-yellow  { color: #d97706; }
.term-blue    { color: #2563eb; }
.term-magenta { color: #9333ea; }
.term-cyan    { color: #0891b2; }
.term-dim     { opacity: 0.5; }
.term-bold    { font-weight: 700; }

/* ── Input row — always visible, never collapses ─────────── */
.terminal-input-row {
  flex-shrink: 0;         /* NEVER squish — always rendered even when panel is minimal */
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 6px;
  border-top: 1px solid var(--border, #e2e8f0);
}

.terminal-prompt {
  color: var(--term-prompt, #57ab5a);
  user-select: none;
  font-weight: 600;
  flex-shrink: 0;
  line-height: 1;
}

.terminal-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text, #102040);
  font-family: inherit;
  font-size: inherit;
  line-height: 1.4;
  caret-color: var(--term-prompt, #57ab5a);
  padding: 0;
}

.terminal-input::placeholder {
  color: var(--text-muted, #94a3b8);
  opacity: 0.5;
}

/* ── Terminal toggle button (page-header) ────────────────── */
.dp-terminal-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.dp-terminal-btn:hover  { background: rgba(0,0,0,0.06); color: var(--text, #102040); }
.dp-terminal-btn.active { background: rgba(87,171,90,0.12); color: #57ab5a; }

/* Theme overrides live in theme_controller.css */
