/* ── Terminal Panel (right-side) ────────────────────────────── */

.terminal-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  border-left: 1px solid var(--border-default);
  width: 340px;
  min-width: 38px;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.terminal-panel.collapsed {
  width: 38px;
  min-width: 38px;
  max-width: 38px;
}

/* Resize handle (left edge) */
.terminal-resize {
  width: 4px;
  height: 100%;
  cursor: ew-resize;
  background: transparent;
  position: absolute;
  left: 0;
  top: 0;
  flex-shrink: 0;
  z-index: 2;
}

.terminal-resize::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 32px;
  border-radius: 1px;
  background: var(--border-subtle);
  opacity: 0;
  transition: opacity 0.15s;
}

.terminal-resize:hover::after,
.terminal-resize:active::after {
  opacity: 1;
  background: var(--accent);
}

/* Header bar */
.terminal-header {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}

.terminal-header__label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.terminal-header__label::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
  opacity: 0.7;
  vertical-align: middle;
}

.terminal-header__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.terminal-header__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 2px;
  font-size: 14px;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}

.terminal-header__btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Chevron rotates when collapsed (points left when open, right when collapsed) */
.terminal-header__chevron {
  transition: transform 0.2s ease;
  font-size: 10px;
}

.terminal-panel.collapsed .terminal-header__chevron {
  transform: rotate(180deg);
}

/* When collapsed, hide everything except header */
.terminal-panel.collapsed .terminal-resize {
  display: none;
}

/* Collapsed: rotate header to vertical */
.terminal-panel.collapsed .terminal-header {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  height: 100%;
  width: 38px;
  padding: 12px 0;
  justify-content: flex-start;
  border-bottom: none;
  border-right: none;
}

.terminal-panel.collapsed .terminal-header__actions {
  margin-left: 0;
  margin-top: auto;
  flex-direction: column;
}

.terminal-panel.collapsed .terminal-header__label {
  letter-spacing: 0.12em;
}

/* Terminal body */
.terminal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.terminal-panel.collapsed .terminal-body {
  display: none;
}

/* Output scroll area */
.terminal-output {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-primary);
}

.terminal-output::-webkit-scrollbar { width: 5px; }
.terminal-output::-webkit-scrollbar-track { background: transparent; }
.terminal-output::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 2px;
}

/* Input line */
.terminal-input-line {
  display: flex;
  align-items: center;
  padding: 8px 16px 12px;
  flex-shrink: 0;
}

.terminal-prompt {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  margin-right: 8px;
}

.terminal-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 12px;
  caret-color: var(--accent);
  line-height: 1.65;
}

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

/* ── Output Blocks ─────────────────────────────────────────── */

.term-block {
  margin-bottom: 12px;
}

/* Command echo */
.term-cmd {
  color: var(--text-muted);
  margin-bottom: 4px;
}

.term-cmd .term-prompt-echo {
  color: var(--accent);
  font-weight: 600;
}

/* Plain text output */
.term-text {
  color: var(--text-primary);
}

.term-text--dim {
  color: var(--text-muted);
}

.term-text--bright {
  color: var(--text-bright);
}

.term-text--accent {
  color: var(--accent);
}

.term-text--success {
  color: #6e9468;
}

.term-text--error {
  color: #c45b54;
}

.term-text--warning {
  color: #c4a43e;
}

/* Table-style output */
.term-table {
  margin: 4px 0;
}

.term-row {
  display: flex;
  gap: 4px;
  line-height: 1.8;
}

.term-col {
  white-space: nowrap;
}

.term-col--cmd {
  color: var(--accent);
  min-width: 100px;
}

.term-col--desc {
  color: var(--text-secondary);
}

/* Health check items */
.term-check {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 2;
}

.term-check__icon {
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.term-check__icon--pass {
  color: #6e9468;
}

.term-check__icon--fail {
  color: #c45b54;
}

.term-check__icon--spin {
  color: var(--text-muted);
  animation: term-spin 0.6s linear infinite;
}

@keyframes term-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.term-check__label {
  color: var(--text-primary);
}

.term-check__detail {
  color: var(--text-muted);
  margin-left: auto;
}

/* Diff output */
.term-diff-add {
  color: #6e9468;
}

.term-diff-add::before {
  content: '+ ';
}

.term-diff-del {
  color: #c45b54;
}

.term-diff-del::before {
  content: '- ';
}

.term-diff-ctx {
  color: var(--text-muted);
}

.term-diff-ctx::before {
  content: '  ';
}

.term-diff-hdr {
  color: var(--accent);
  font-weight: 500;
}

/* Progress bar */
.term-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
}

.term-progress__bar {
  flex: 1;
  height: 6px;
  background: var(--border-subtle);
  border-radius: 1px;
  overflow: hidden;
  max-width: 200px;
}

.term-progress__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  width: 0%;
  transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.term-progress__label {
  color: var(--text-muted);
  font-size: 11px;
  min-width: 36px;
}

/* Stat rows (cost, usage) */
.term-stat {
  display: flex;
  justify-content: space-between;
  line-height: 1.9;
  max-width: 340px;
}

.term-stat__key {
  color: var(--text-muted);
}

.term-stat__val {
  color: var(--text-bright);
  font-weight: 500;
}

.term-stat__val--accent {
  color: var(--accent);
}

/* Section heading */
.term-heading {
  color: var(--text-bright);
  font-weight: 600;
  margin: 8px 0 4px;
  font-size: 12px;
}

/* Divider */
.term-hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 8px 0;
}

/* Welcome / boot message */
.term-welcome {
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.7;
}

.term-welcome .term-text--accent {
  font-weight: 600;
}

/* ── Welcome Banner ───────────────────────────────────────────── */

.term-welcome-banner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 12px;
}

/* Brand block */
.term-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 8px 0;
}

.term-brand__rule {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, var(--accent) 0%, transparent 100%);
  opacity: 0.3;
}

.term-brand__ascii {
  font-family: var(--font-mono);
  font-size: 17px;
  line-height: 1.1;
  margin: 12px 0 4px;
  user-select: none;
}

.term-brand__char-bright {
  color: var(--text-bright);
}

.term-brand__char-accent {
  color: var(--accent);
  opacity: 0.8;
}

.term-brand__char-dim {
  color: var(--accent);
  opacity: 0.45;
}

.term-brand__ascii--sub {
  font-size: 11px;
  margin: 4px 0 0 2px;
}

/* Tagline */
.term-banner-tagline {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-secondary);
  padding: 0 2px;
}

/* Sections */
.term-banner-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 2px;
}

.term-banner-section__title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* Command rows in quick start */
.term-banner-cmd-row {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.9;
  padding-left: 4px;
}

/* Steps in how-to */
.term-banner-step {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.9;
  color: var(--text-secondary);
  padding-left: 4px;
}

.term-banner-step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  font-size: 9px;
  color: var(--accent);
  flex-shrink: 0;
  line-height: 1;
}

/* Info rows (version, model, project) */
.term-banner-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 2px;
}

.term-banner-row {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.8;
}

.term-banner-key {
  color: var(--text-muted);
  min-width: 64px;
  font-size: 11px;
}

.term-banner-key::before {
  content: '\203A';
  margin-right: 6px;
  color: var(--border-default);
}

.term-banner-val {
  color: var(--text-secondary);
  font-size: 11px;
}

.term-banner-divider {
  border-top: 1px solid var(--border-subtle);
  margin: 4px 0;
  opacity: 0.4;
}

/* Model selection cards */
.term-model {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  line-height: 1.8;
}

.term-model__indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.term-model__indicator--active {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(196, 122, 80, 0.4);
}

.term-model__indicator--inactive {
  background: var(--border-default);
}

.term-model__name {
  color: var(--text-bright);
  min-width: 120px;
}

.term-model__name--active {
  color: var(--accent);
  font-weight: 600;
}

.term-model__desc {
  color: var(--text-muted);
}

/* Typewriter cursor for animated output */
.term-cursor {
  display: inline-block;
  width: 6px;
  height: 13px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: term-blink 0.8s step-end infinite;
  margin-left: 1px;
}

@keyframes term-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Responsive: stack terminal below content on small screens ── */
@media (max-width: 768px) {
  .terminal-panel {
    width: 100%;
    min-width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-default);
    max-height: 40vh;
  }

  .terminal-panel.collapsed {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    max-height: 38px;
  }

  .terminal-resize {
    width: 100%;
    height: 4px;
    cursor: ns-resize;
    position: relative;
    left: auto;
    top: auto;
  }

  .terminal-resize::after {
    width: 32px;
    height: 2px;
  }
}
