/* Страница агента. Цвета — в тон редактору ParserScratch (тёмная тема). */
:root {
  --bg: #1e252f;
  --bar: #253342;
  --panel: #2c3e50;
  --line: #34495e;
  --text: #ecf0f1;
  --muted: #95a5b5;
  --run: #4caf50;
  --run-hover: #43a047;
  --danger: #e57373;
  --warn: #ffb74d;
  --radius: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 Arial, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button { font: inherit; color: inherit; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- верхняя панель ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bar);
  border-bottom: 2px solid var(--line);
  flex-shrink: 0;
}

.brand { font-weight: 700; letter-spacing: 0.02em; margin-right: 4px; }
.spacer { flex: 1; }
.scripts { display: flex; align-items: center; gap: 4px; min-width: 0; }

select {
  min-width: 0;
  max-width: 220px;
  height: 32px;
  padding: 0 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
}

.icon-btn, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
}
.icon-btn { width: 32px; padding: 0; }
.btn { padding: 0 12px; }
.icon-btn:hover, .btn:hover:not(:disabled) { border-color: var(--muted); }
.icon-btn[aria-pressed="true"] { background: var(--line); }
.btn:disabled { opacity: 0.45; cursor: default; }

.run-group { position: relative; display: flex; }
.btn--run { background: var(--run); border-color: var(--run); color: #fff; }
.btn--run:hover:not(:disabled) { background: var(--run-hover); border-color: var(--run-hover); }
.btn--run svg { fill: currentColor; stroke: none; }
.btn--run:not(.btn--menu) { border-radius: var(--radius) 0 0 var(--radius); }
.btn--menu { padding: 0 6px; border-radius: 0 var(--radius) var(--radius) 0; border-left-color: rgba(0, 0, 0, 0.2); }
.btn--menu svg { fill: none; stroke: currentColor; }
#stop-btn svg { fill: currentColor; stroke: none; width: 12px; height: 12px; }

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 10;
  min-width: 200px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.menu__item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
.menu__item:hover { background: var(--line); }
.menu__empty { padding: 8px 10px; color: var(--muted); max-width: 260px; }

/* ---------- редактор и панель ---------- */
.main { flex: 1; display: flex; min-height: 0; }
#editor { flex: 1; border: 0; min-width: 0; background: var(--bg); }

.panel {
  width: 300px;
  flex-shrink: 0;
  padding: 16px;
  overflow-y: auto;
  background: var(--bar);
  border-left: 2px solid var(--line);
}
.panel h2 { font-size: 16px; margin: 0 0 8px; }
.panel h3 { font-size: 13px; margin: 20px 0 6px; color: var(--muted); font-weight: 600; }
.hint, .muted { color: var(--muted); }
.hint { margin: 0 0 12px; }
.code {
  font: 700 34px/1 ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.12em;
  padding: 12px 0;
}
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: 4px 0; display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; }
.link-btn { background: none; border: 0; padding: 0; color: #64b5f6; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------- журнал ---------- */
.log {
  height: 32vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #161c24;
  border-top: 2px solid var(--line);
}
.log[hidden] { display: none; }
.log__head { display: flex; align-items: center; gap: 8px; padding: 6px 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.log__body { flex: 1; overflow-y: auto; padding: 6px 12px; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; }
.log__line { white-space: pre-wrap; word-break: break-word; }
.log__line--info { color: var(--muted); }
.log__line--err { color: var(--warn); }
.log__line--error { color: var(--danger); }
.log__line--message { color: #b39ddb; font-weight: 700; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-dot[data-status="running"] { background: var(--warn); }
.status-dot[data-status="done"] { background: var(--run); }
.status-dot[data-status="error"] { background: var(--danger); }

/* ---------- телефон ---------- */
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; padding: 6px 8px; gap: 6px; }
  .brand { display: none; }
  .scripts { flex: 1 1 100%; }
  select { flex: 1; max-width: none; }
  .btn span { display: none; }
  .panel { position: absolute; inset: 0; width: auto; z-index: 5; }
  .main { position: relative; }
}

/* ---------- вход (login.html) ---------- */
.login {
  margin: auto;
  width: min(360px, calc(100% - 32px));
  padding: 24px;
  background: var(--bar);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.login h1 { font-size: 20px; margin: 0 0 8px; }
.login input {
  width: 100%;
  height: 44px;
  margin: 12px 0;
  padding: 0 12px;
  font: 700 22px ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.2em;
  text-align: center;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.login .btn { width: 100%; height: 40px; }
.login .error { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; }
