/* Phase 8.4 — terminal page + embedded panel inside dashboard.
   Inherits palette from styles.css. */

/* Embedded terminal panel inside the main dashboard. */
.panel--terminal {
  margin: 0 24px 24px;
  padding: 16px;
  border: 1px solid var(--rule);
  background: var(--surface);
  scroll-margin-top: 60px;  /* anchor jump leaves room for sticky header */
}
.panel--terminal .panel__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.panel--terminal .panel__title {
  margin: 0;
  font-family: 'IBM Plex Sans Condensed', sans-serif;
  font-size: 14px;
  letter-spacing: 0.18em;
}
.panel--terminal .panel__sub {
  color: var(--muted);
  font-size: 11px;
}
.term-embed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.term-embed .term-screen {
  /* Cap the screen so the input row + button stay above the fold.
     Viewport-aware so it adapts on small laptops (e.g. 13" 768px). */
  height: clamp(180px, 32vh, 360px);
  min-height: 180px;
  max-height: 360px;
}
/* Anchor jump lands just above the section so the screen + input row both
   sit in the viewport on standard 1080p / 13" laptops. */
.panel--terminal {
  scroll-margin-top: 60px;
}


.terminal-page {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 184, 78, 0.04), transparent 60%),
    var(--paper);
  color: var(--ink-0);
  font-family: 'IBM Plex Mono', monospace;
  display: flex;
  flex-direction: column;
}

.term-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.term-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.term-bracket {
  color: var(--amber);
  font-weight: 300;
  font-size: 22px;
}

.term-title {
  font-family: 'Major Mono Display', monospace;
  font-size: 22px;
  text-decoration: none;
  color: var(--ink-0);
  letter-spacing: 0.06em;
}

.term-section {
  margin-left: 10px;
  padding: 2px 8px;
  border: 1px solid var(--amber);
  color: var(--amber);
  font-size: 11px;
  letter-spacing: 0.15em;
}

.term-nav {
  display: flex;
  gap: 18px;
}

.term-link {
  color: var(--ink-0);
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.12em;
  border-bottom: 1px dashed transparent;
  transition: color 100ms, border-color 100ms;
}

.term-link:hover {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

.term-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 24px 24px;
  gap: 12px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.term-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.term-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.term-control-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.18em;
}

.term-select {
  /* Tell the browser the widget lives on a dark theme so the dropdown
     popup and the focus ring use a matching palette instead of Chromium's
     default white-on-blue. */
  color-scheme: dark;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  background-color: var(--bg-1);
  /* Custom dropdown caret drawn with an inline SVG so we get an
     amber-tinted chevron consistent with the rest of the UI. */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%23ffb454' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;

  color: var(--ink-0);
  border: 1px solid var(--border-1);
  border-radius: 0;
  padding: 6px 30px 6px 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 120ms, box-shadow 120ms;
}

.term-select:hover {
  border-color: var(--border-2);
}

.term-select:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 1px var(--amber-glow);
}

/* Style the dropdown items themselves. Some browsers honour this
   (Firefox), some fall back to system styling (Chromium on Windows). */
.term-select option {
  background-color: var(--bg-1);
  color: var(--ink-0);
  font-family: 'IBM Plex Mono', monospace;
}

.term-select option:checked {
  background-color: var(--bg-3);
  color: var(--amber);
}

.term-banner {
  margin: 0;
  padding: 8px 12px;
  border-left: 3px solid var(--amber);
  background: rgba(255, 184, 78, 0.04);
  font-size: 11px;
  color: var(--muted);
}

.term-screen {
  flex: 1;
  min-height: 320px;
  max-height: calc(100vh - 280px);
  overflow-y: auto;
  padding: 12px 14px;
  background: #0a0d10;
  border: 1px solid var(--rule);
  font-size: 13px;
  line-height: 1.45;
  /* IMPORTANT: do NOT set white-space: pre-wrap on the screen container.
     Alpine renders each line as ``<div class="line">`` with multiple
     ``<template x-if>`` siblings + whitespace text nodes between them
     (the indentation in index.html). With pre-wrap, those text nodes
     each render as visible blank lines and a single command output
     ends up 100+ pixels tall. Keep pre-wrap on ``pre.line-stdout/stderr``
     only (where it IS needed to render multi-line command output). */
  white-space: normal;
}

.line {
  margin: 0;
  padding: 0;
  line-height: 1.4;
}

/* The <template x-if> wrappers themselves take no space; the inner element
   carries the styling. Reset default <pre> margins so empty/trailing
   newlines don't leave huge gaps in the screen. */
.line > pre,
.line-stdout,
.line-stderr {
  margin: 0;
  padding: 0;
}

.line-prompt {
  color: var(--ink-0);
  margin: 2px 0 0;
}

.prompt-user { color: var(--green, #7af07a); }
.prompt-host { color: var(--cyan, #7af0ff); }
.prompt-cmd  { color: var(--ink-0); }
.prompt-at   { color: var(--muted); }
.prompt-tail { color: var(--muted); }

pre.line-stdout {
  color: var(--ink-0);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.4;
}

pre.line-stderr {
  color: var(--red, #f35a5a);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.4;
}

.line-meta {
  font-size: 10px;
  letter-spacing: 0.1em;
  opacity: 0.7;
  margin: 1px 0 6px;
  display: block;
}
.line-meta-ok   { color: var(--green, #7af07a); }
.line-meta-fail { color: var(--red, #f35a5a); }

.term-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 8px 12px;
}

.term-prompt {
  font-size: 13px;
  white-space: nowrap;
}

.term-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink-0);
  font-family: inherit;
  font-size: 14px;
}

.term-exec {
  background: transparent;
  border: 1px solid var(--amber);
  color: var(--amber);
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.1em;
  font-weight: 600;
  cursor: pointer;
}

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

.term-exec:hover:not(:disabled) {
  background: var(--amber);
  color: var(--paper);
}

.term-audit {
  position: fixed;
  right: 0;
  top: 60px;
  width: min(720px, 96vw);
  height: calc(100vh - 80px);
  background: var(--surface);
  border-left: 1px solid var(--rule);
  padding: 16px;
  overflow: auto;
  z-index: 50;
  box-shadow: -8px 0 24px rgba(0,0,0,0.4);
}

.term-audit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.term-audit-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.15em;
}

.term-audit-close {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-0);
  font-family: inherit;
  cursor: pointer;
  padding: 2px 8px;
}

.term-audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.term-audit-table th,
.term-audit-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.term-audit-table th {
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.12em;
}

.term-audit-table td.ok   { color: var(--green, #7af07a); }
.term-audit-table td.fail { color: var(--red, #f35a5a); }

.term-audit-table code {
  color: var(--ink-0);
  font-size: 10.5px;
}
