/*
 * 콘솔 스타일.
 *
 * 프레임워크를 쓰지 않는다. 화면 20여 개에 필요한 것은 레이아웃·표·배지·폼뿐이고,
 * 그 정도에 수백 KB 를 받아오는 것은 폐쇄망 설치를 어렵게 만들 뿐이다 (문서 14 §7.4).
 *
 * 인라인 style 속성을 쓰지 않는다. CSP 가 style-src 'self' 이므로 인라인 스타일은
 * 브라우저가 거부한다 — 템플릿에서 style="" 를 쓰면 조용히 적용되지 않는다.
 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #1f2328;
  --muted: #656d76;
  --accent: #0969da;
  --ok: #1a7f37;
  --warn: #9a6700;
  --danger: #cf222e;
  --progress: #8250df;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── 레이아웃 ───────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  font-weight: 600;
  color: var(--text);
}

.topbar nav {
  display: flex;
  gap: 16px;
  flex: 1;
}

.topbar .who {
  color: var(--muted);
  font-size: 13px;
}

.shell {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  max-width: 1280px;
  margin: 20px auto;
  padding: 0 20px;
}

.sidebar {
  width: 200px;
  flex: 0 0 200px;
}

.sidebar h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 16px 0 6px;
}

.sidebar a {
  display: block;
  padding: 5px 8px;
  border-radius: 5px;
  color: var(--text);
}

.sidebar a:hover {
  background: #eceff2;
  text-decoration: none;
}

.sidebar a.current {
  background: #ddf4ff;
  color: var(--accent);
  font-weight: 600;
}

main {
  flex: 1;
  min-width: 0;
}

h1 {
  font-size: 20px;
  margin: 0 0 16px;
}

/* ── 카드·표 ────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.card > h2 {
  font-size: 14px;
  margin: 0 0 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

.empty {
  color: var(--muted);
  padding: 20px 0;
  text-align: center;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

/* ── 배지 ───────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-ok {
  background: #dafbe1;
  color: var(--ok);
}

.badge-warn {
  background: #fff8c5;
  color: var(--warn);
}

.badge-danger {
  background: #ffebe9;
  color: var(--danger);
}

.badge-progress {
  background: #fbefff;
  color: var(--progress);
}

.badge-idle {
  background: #eceff2;
  color: var(--muted);
}

/* ── 폼·버튼 ────────────────────────────────────────────────────── */

label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--surface);
}

textarea {
  min-height: 72px;
  resize: vertical;
}

.field {
  margin-bottom: 12px;
}

.field-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
}

button,
.btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font: inherit;
  cursor: pointer;
}

button:hover,
.btn:hover {
  background: #f3f4f6;
  text-decoration: none;
}

.btn-small {
  padding: 2px 8px;
  font-size: 12px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #0860ca;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b81c27;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── 배너·알림 ──────────────────────────────────────────────────── */

#app-banner {
  padding: 10px 20px;
  background: #ffebe9;
  color: var(--danger);
  border-bottom: 1px solid #ffcecb;
}

.notice {
  padding: 10px 12px;
  border-radius: 6px;
  background: #ddf4ff;
  border: 1px solid #b6e3ff;
  margin-bottom: 16px;
}

.notice-warn {
  background: #fff8c5;
  border-color: #f0e08a;
}

.notice-danger {
  background: #ffebe9;
  border-color: #ffcecb;
}

/* ── 로그인 ─────────────────────────────────────────────────────── */

.login-page {
  display: flex;
  justify-content: center;
  padding-top: 12vh;
}

.login-card {
  width: 340px;
}

/* ── 상태 타임라인 ──────────────────────────────────────────────── */
/*
 * 16개 상태를 6단계로 접어 보여준다 (문서 14 §2.3). 색만으로 상태를 구분하지 않고
 * 기호(● ◐ ✕ ○)를 함께 쓴다 — 색각 이상이 있어도 읽을 수 있어야 한다 (문서 14 §8.4).
 */

.timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

.timeline-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  background: #eceff2;
  color: var(--muted);
}

.timeline-step .timeline-dot {
  font-size: 11px;
}

.timeline-step.step-done {
  background: #dafbe1;
  color: var(--ok);
}

.timeline-step.step-active {
  background: #fbefff;
  color: var(--progress);
  font-weight: 600;
}

.timeline-step.step-failed {
  background: #ffebe9;
  color: var(--danger);
  font-weight: 600;
}

.timeline-step.step-pending {
  background: #eceff2;
  color: var(--muted);
}

/* 실패 뒤의 단계는 더 흐리게 — '곧 진행될 것'으로 읽히면 안 된다. */
.timeline-step.step-skipped {
  background: #f6f7f9;
  color: #a0a6ad;
}

/* ── HTMX 인디케이터 ────────────────────────────────────────────── */
/*
 * htmx 가 주입하는 <style> 블록을 껐으므로(layout.html 의 htmx-config) 여기에 직접 둔다.
 * CSP style-src 'self' 아래에서는 주입된 인라인 스타일이 적용되지 않는다.
 */

.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* ── 로그 출력 ──────────────────────────────────────────────────── */

.log-output {
  background: #0d1117;
  color: #e6edf3;
  padding: 12px;
  border-radius: 6px;
  max-height: 60vh;
  overflow: auto;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}
