/* ──────────────────────────────────────────────────────────────────────────
   vLLM OCR 워밍업 콘솔 — 인터랙티브 클라이언트
   브라우저에서 직접 /v1/chat/completions 를 호출하는 정적 페이지
   ────────────────────────────────────────────────────────────────────────── */

:root {
  /* 테마 무관 토큰 (폰트 · 모서리) */
  --mono: "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code",
          "Menlo", "Consolas", ui-monospace, monospace;
  --sans: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI",
          "Noto Sans KR", system-ui, sans-serif;
  --radius: 14px;

  /* ── 라이트 테마 (기본) · 모던 cool-gray ───────────────────────────────
     data-theme 속성이 없거나 "light"면 이 팔레트가 적용된다.
     옅은 cool-gray 페이지를 캔버스로 깔고, 카드는 순백(#fff)으로 한 단계
     띄워 그림자로 elevation을 만든다(이전의 뒤집힌 위계 — 페이지가 카드보다
     밝던 구조 — 를 바로잡았다).
     대비는 직접 측정해 본문·보조·라벨 모두 WCAG AA(4.5:1)를 충족한다. */
  --bg:        #f4f5f7;  /* 페이지 (옅은 캔버스, 가장 낮음) */
  --bg-soft:   #eef1f5;  /* 입력칸·드롭존 등 카드 안 눌린 면 */
  --panel:     #ffffff;  /* 카드 (순백, elevation 최상) */
  --panel-2:   #f7f8fa;  /* 카드 헤더·태그 */
  --border:    #e7e9ee;
  --border-2:  #d6dae1;

  --text:      #1b1e24;  /* 본문 16.7:1 */
  --text-dim:  #4a5059;  /* 보조 8.1:1 */
  --muted:     #656c78;  /* 라벨·푸터 5.3:1 (페이지 위 4.85:1) */

  --accent:    #0e97a8;  /* send 버튼·focus — 흰 배경 border 가시성까지 확보 */
  --accent-2:  #10a594;  /* primary 버튼·배지 */
  --green:     #15803d;
  --yellow:    #b45309;
  --red:       #dc2626;
  --blue:      #2563eb;
  --purple:    #7c3aed;

  --topbar-bg: rgba(255, 255, 255, 0.85);  /* 흰 반투명 — 회색 페이지와 분리 */
  --shadow:    0 1px 2px rgba(16, 24, 40, 0.05), 0 14px 32px -18px rgba(16, 24, 40, 0.16);
  color-scheme: light;
}

/* ── 다크 테마 ──────────────────────────────────────────────────────────
   html[data-theme="dark"] 일 때만 매칭되어 라이트 값을 덮어쓴다.
   컴포넌트 규칙은 모두 var(--*)만 참조하므로 여기 변수만 바꾸면 된다. */
:root[data-theme="dark"] {
  --bg:        #0a0e14;
  --bg-soft:   #0e131c;
  --panel:     #11161f;
  --panel-2:   #141b26;
  --border:    #1f2733;
  --border-2:  #2a3441;

  --text:      #c9d4e3;
  --text-dim:  #8a98ad;
  --muted:     #5c6b80;

  --accent:    #56d4dd;
  --accent-2:  #2dd4bf;
  --green:     #4ade80;
  --yellow:    #fbbf24;
  --red:       #f87171;
  --blue:      #60a5fa;
  --purple:    #c792ea;

  --topbar-bg: rgba(10, 14, 20, 0.74);
  --shadow:    0 12px 40px -14px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* hidden 속성은 author의 display 규칙(예: .dz-preview{display:flex})에 의해
   무력화될 수 있다. 이 리셋으로 hidden 이 항상 우선하도록 보장한다. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(86, 212, 221, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 5%, rgba(199, 146, 234, 0.06), transparent 55%),
    var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}
code { font-family: var(--mono); font-size: 0.88em; }

/* 테마 전환 시 주요 표면도 함께 페이드 (snappy hover가 있는 버튼·입력·드롭존은
   각자의 transition을 유지하려고 여기서 제외한다). */
.topbar, .config, .card, .card-head, .disclosure, .result, pre.json, .tag, footer {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.wrap { max-width: 920px; margin: 0 auto; padding: 0 22px 90px; }

/* ── 상단바 ────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border-2);
}
.topbar-inner {
  max-width: 920px; margin: 0 auto; padding: 13px 22px;
  display: flex; align-items: baseline; gap: 14px;
}
.brand {
  font-family: var(--mono); font-weight: 700; font-size: 0.96rem;
  display: flex; align-items: center; gap: 9px; white-space: nowrap;
}
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); transition: background 0.3s, box-shadow 0.3s;
}
.brand .dot.ok  { background: var(--green);  box-shadow: 0 0 10px var(--green); }
.brand .dot.bad { background: var(--red);    box-shadow: 0 0 10px var(--red); }
.brand-sub { font-size: 0.82rem; color: var(--muted); }

/* ── 테마 토글 ─────────────────────────────────────────────────────────── */
.theme-toggle {
  margin-left: auto; align-self: center;
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--sans); font-size: 0.8rem; font-weight: 600;
  color: var(--text-dim);
  background: var(--panel-2); border: 1px solid var(--border-2);
  border-radius: 999px; padding: 6px 13px; cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(86, 212, 221, 0.18);
}
.theme-toggle-icon { font-size: 0.95rem; line-height: 1; }

/* ── 설정 바 ──────────────────────────────────────────────────────────── */
.config {
  margin-top: 26px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.config-row { display: flex; gap: 14px; flex-wrap: wrap; }
.config-actions {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px; flex-wrap: wrap;
}
.config-actions .spacer { flex: 1 1 auto; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1 1 280px; }
.field-label {
  font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); font-family: var(--mono);
}
.hint-note {
  text-transform: none; letter-spacing: 0; color: var(--text-dim);
  font-weight: 400; margin-left: 6px;
}
input[type="text"], input[type="password"], textarea {
  font-family: var(--mono); font-size: 0.9rem; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--border-2);
  border-radius: 9px; padding: 10px 12px; width: 100%;
  resize: vertical; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(86, 212, 221, 0.12);
}

/* ── 버튼 ──────────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--sans); font-size: 0.88rem; font-weight: 600;
  border-radius: 9px; padding: 9px 16px; cursor: pointer;
  border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text);
  transition: all 0.15s; white-space: nowrap;
}
.btn:hover { border-color: var(--border-2); background: var(--border); }
.btn.primary {
  background: var(--accent-2); border-color: var(--accent-2); color: #06231f;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.send { background: var(--accent); border-color: var(--accent); color: #062327; }
.btn.send:hover { filter: brightness(1.08); }
.btn.tiny { padding: 4px 10px; font-size: 0.78rem; font-weight: 500; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 상태 pill ─────────────────────────────────────────────────────────── */
.pill {
  font-family: var(--mono); font-size: 0.76rem; font-weight: 600;
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--border-2);
}
.pill.idle    { color: var(--muted);  background: var(--panel); }
.pill.sending { color: var(--yellow); background: rgba(251,191,36,0.10); border-color: rgba(251,191,36,0.3); }
.pill.ok      { color: var(--green);  background: rgba(74,222,128,0.10); border-color: rgba(74,222,128,0.3); }
.pill.err     { color: var(--red);    background: rgba(248,113,113,0.10); border-color: rgba(248,113,113,0.3); }

/* ── 카드 ──────────────────────────────────────────────────────────────── */
.cards { display: grid; gap: 16px; margin-top: 18px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.badge {
  width: 28px; height: 28px; flex: none; border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 0.9rem;
  color: #06231f; background: var(--accent-2);
}
.card-titles { flex: 1 1 auto; min-width: 0; }
.card-titles h2 { margin: 0; font-size: 1.04rem; font-weight: 700; letter-spacing: -0.01em; }
.card-titles p { margin: 1px 0 0; font-size: 0.82rem; color: var(--text-dim); }

.card-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }

/* ── 드롭존 ────────────────────────────────────────────────────────────── */
.dropzone {
  border: 1.5px dashed var(--border-2); border-radius: 11px;
  background: var(--bg-soft); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); outline: none; }
.dropzone.dragover { border-color: var(--accent-2); background: rgba(45,212,191,0.06); }
.dz-empty { padding: 26px 18px; text-align: center; }
.dz-empty .dz-icon { font-size: 1.8rem; margin-bottom: 6px; }
.dz-empty p { margin: 2px 0; font-size: 0.9rem; }
.dz-empty .dz-hint { font-size: 0.78rem; color: var(--muted); }
.dz-preview { display: flex; gap: 14px; padding: 14px; align-items: center; }
.dz-preview img {
  width: 84px; height: 84px; object-fit: cover; border-radius: 9px;
  border: 1px solid var(--border-2); flex: none;
}
.dz-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dz-name { font-family: var(--mono); font-size: 0.86rem; word-break: break-all; }
.dz-info { font-size: 0.78rem; color: var(--text-dim); }
.dz-meta .btn { align-self: flex-start; margin-top: 4px; }

/* ── 펼침(disclosure) ─────────────────────────────────────────────────── */
.disclosure { border: 1px solid var(--border); border-radius: 10px; background: var(--bg-soft); }
.disclosure summary {
  cursor: pointer; list-style: none; padding: 9px 14px;
  font-size: 0.82rem; color: var(--text-dim); font-family: var(--mono);
}
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::before { content: "▸ "; color: var(--muted); }
.disclosure[open] summary::before { content: "▾ "; }
.disclosure summary:hover { color: var(--text); }

pre.json {
  margin: 0; padding: 12px 14px; border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.55;
  color: var(--text-dim); white-space: pre-wrap; word-break: break-word;
  max-height: 1280px; overflow: auto;
}

/* ── 결과 영역 ─────────────────────────────────────────────────────────── */
.result {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-soft); overflow: hidden;
}
.result.is-err { border-color: rgba(248,113,113,0.4); }
.result-meta {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.78rem;
}
.tag {
  padding: 3px 9px; border-radius: 7px;
  background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text-dim);
}
.tag b { color: var(--text); font-weight: 600; }
.tag.ok b   { color: var(--green); }
.tag.warn b { color: var(--yellow); }

.result-content {
  padding: 14px; font-family: var(--sans); font-size: 0.95rem;
  white-space: pre-wrap; word-break: break-word; line-height: 1.6;
}
.result-content.empty { color: var(--muted); font-style: italic; }
.result-error {
  padding: 14px; font-family: var(--mono); font-size: 0.85rem; color: var(--red);
  white-space: pre-wrap; word-break: break-word;
}
.result-error .hint {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
  color: var(--text-dim); font-family: var(--sans); font-size: 0.85rem;
}
.result-raw { border-top: 1px solid var(--border); }
.result-raw summary {
  cursor: pointer; list-style: none; padding: 9px 14px;
  font-size: 0.8rem; color: var(--text-dim); font-family: var(--mono);
}
.result-raw summary::-webkit-details-marker { display: none; }
.result-raw summary::before { content: "▸ "; }
.result-raw[open] summary::before { content: "▾ "; }
.result-raw pre {
  margin: 0; padding: 12px 14px; border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.78rem; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-word; max-height: 280px; overflow: auto;
}

/* ── 푸터 ──────────────────────────────────────────────────────────────── */
footer {
  margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--border);
  font-size: 0.82rem; color: var(--muted);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
footer code { color: var(--text-dim); }

/* ── 스크롤바 ──────────────────────────────────────────────────────────── */
pre::-webkit-scrollbar { width: 10px; height: 10px; }
pre::-webkit-scrollbar-thumb {
  background: var(--border-2); border-radius: 6px; border: 3px solid var(--bg-soft);
}
pre::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 620px) {
  .config-row { flex-direction: column; }
  .card-head { flex-wrap: wrap; }
  .card-head .btn.send { order: 5; flex: 1 1 100%; }
}
