/* styles.css — QA PRD → TC
   깔끔하고 한눈에 들어오는 레이아웃 (명확한 위계 / 넉넉한 여백 / 카드 구조) */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --header-bg: rgba(255, 255, 255, 0.85);
  --th-bg: #f0f3fa;
  --border: #e3e8f0;
  --text: #1f2733;
  --text-soft: #5b6675;
  --primary: #3b5bdb;
  --primary-dark: #2f49b0;
  --primary-soft: #edf1ff;
  --normal: #2f9e44;
  --exception: #e8590c;
  --boundary: #9c36b5;
  --high: #e03131;
  --mid: #f08c00;
  --low: #868e96;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  --header-h: 62px;
}

/* 다크 모드 */
[data-theme="dark"] {
  --bg: #0e131b;
  --surface: #161d28;
  --surface-2: #1b2330;
  --header-bg: rgba(14, 19, 27, 0.85);
  --th-bg: #1d2735;
  --border: #2a3645;
  --text: #e7ecf3;
  --text-soft: #9aa7b8;
  --primary: #6b8cff;
  --primary-dark: #5878f0;
  --primary-soft: #1c2740;
  --normal: #51cf66;
  --exception: #ff922b;
  --boundary: #cc5de8;
  --high: #ff6b6b;
  --mid: #ffa94d;
  --low: #7e8a9a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

h1, h2, h3 { line-height: 1.3; margin: 0; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 헤더 ───────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-logo svg { width: 100%; height: 100%; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 17px; letter-spacing: -0.2px; }
.brand-sub { font-size: 12px; color: var(--text-soft); }
.site-nav { display: flex; gap: 22px; font-size: 14px; }
.site-nav a { color: var(--text-soft); font-weight: 500; }
.site-nav a:hover { color: var(--primary); text-decoration: none; }

/* ── 히어로 ─────────────────────────── */
.hero {
  background: linear-gradient(180deg, var(--primary-soft) 0%, var(--bg) 100%);
  padding: 56px 0 40px;
  text-align: center;
}
.hero h1 { font-size: 34px; letter-spacing: -0.6px; }
.hero .accent { color: var(--primary); }
.hero-desc {
  max-width: 720px;
  margin: 18px auto 0;
  color: var(--text-soft);
  font-size: 16px;
}
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 22px;
}
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text-soft);
  box-shadow: var(--shadow);
}

/* ── 메인 레이아웃 ───────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  gap: 22px;
  padding-top: 28px;
  padding-bottom: 32px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0; /* 그리드 칸이 내부 표(min-width)에 밀려 넓어지는 것 방지 */
}
.input-panel { position: sticky; top: calc(var(--header-h) + 18px); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.panel-head h2 { font-size: 18px; }

/* 드래그앤드롭 영역 */
.dropzone {
  border: 2px dashed #c4cdde;
  border-radius: 12px;
  background: var(--surface-2);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  margin-bottom: 14px;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: scale(1.01);
}
.dropzone-icon { font-size: 28px; display: block; margin-bottom: 6px; }
.dropzone-title { margin: 0; font-weight: 700; font-size: 15px; color: var(--text); }
.dropzone-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--text-soft); }
.file-status {
  margin-top: 12px;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #eef2fb;
  color: var(--text-soft);
}
.file-status.loading { background: #fff7e6; color: var(--mid); }
.file-status.done { background: #ebfbee; color: var(--normal); }
.file-status.warn { background: #fff0f0; color: var(--high); }

/* 성공(엑셀) 버튼 */
.btn-success { background: var(--normal); color: #fff; border-color: transparent; }
.btn-success:hover:not(:disabled) { background: #2b8a3e; }

/* 예시 칩 */
.samples { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.samples-label { font-size: 13px; color: var(--text-soft); }

/* 입력 영역 */
.prd-input {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-family: "D2Coding", "Consolas", "Menlo", monospace;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  background: var(--surface-2);
}
.prd-input:focus { outline: 2px solid var(--primary); border-color: var(--primary); background: var(--surface); }

.options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin: 14px 0;
  font-size: 14px;
  color: var(--text-soft);
}
.opt { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.opt-prefix input {
  width: 64px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
}

.hint { font-size: 12px; color: var(--low); margin: 10px 0 0; text-align: center; }

/* ── AI 모드 ─────────────────────────── */
.ai-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.ai-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.ai-toggle-label { font-size: 14px; font-weight: 600; color: var(--text); }
.ai-toggle-label small { font-weight: 400; color: var(--text-soft); }
.ai-panel { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.ai-key-row { display: flex; gap: 6px; }
.ai-key-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: "Consolas", monospace;
}
.ai-key-input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.ai-remember { margin-top: 10px; font-size: 13px; }
.ai-note { margin: 8px 0 0; font-size: 12px; color: var(--text-soft); line-height: 1.5; }

/* ── 버튼 ───────────────────────────── */
.btn {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-lg { width: 100%; padding: 14px; font-size: 16px; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-chip {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: transparent;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 600;
}
.btn-chip:hover { background: #e0e7ff; }

/* ── 결과 ───────────────────────────── */
.result-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.result-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-soft);
}
.meta-item strong { color: var(--text); }
.meta-item { display: inline-flex; align-items: center; gap: 6px; }
.meta-item::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--low); display: inline-block; }
.dot-normal::before { background: var(--normal); }
.dot-exception::before { background: var(--exception); }
.dot-boundary::before { background: var(--boundary); }

.table-wrap { overflow-x: auto; width: 100%; max-width: 100%; border: 1px solid var(--border); border-radius: 10px; }
.tc-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 880px; }
.tc-table thead th {
  position: sticky;
  top: var(--header-h);
  z-index: 1;
  background: var(--th-bg);
  color: var(--text-soft);
  font-weight: 700;
  text-align: left;
  padding: 11px 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.tc-table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.tc-table tbody tr:nth-child(even) { background: var(--surface-2); }
.tc-table tbody tr:hover { background: var(--primary-soft); }
.c-id { font-family: "Consolas", monospace; font-weight: 700; white-space: nowrap; color: var(--primary-dark); }
.c-scenario { min-width: 180px; font-weight: 600; }
.steps { margin: 0; padding-left: 18px; }
.steps li { margin-bottom: 2px; }
.empty-row { text-align: center; color: var(--text-soft); padding: 48px 16px !important; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-normal { background: #ebfbee; color: var(--normal); }
.badge-exception { background: #fff4e6; color: var(--exception); }
.badge-boundary { background: #f8f0fc; color: var(--boundary); }

.pri { font-weight: 700; white-space: nowrap; }
.pri-high { color: var(--high); }
.pri-mid { color: var(--mid); }
.pri-low { color: var(--low); }

/* ── 사용법 ─────────────────────────── */
.how { padding: 36px 20px 48px; }
.how h2 { font-size: 24px; text-align: center; margin-bottom: 26px; }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.how-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.how-num {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  margin-bottom: 12px;
}
.how-card h3 { font-size: 17px; margin-bottom: 8px; }
.how-card p { margin: 0; color: var(--text-soft); font-size: 14px; }
.how-note { text-align: center; margin-top: 22px; color: var(--text-soft); font-size: 14px; }

/* ── 푸터 ───────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 22px 0;
  text-align: center;
}
.site-footer p { margin: 0; color: var(--text-soft); font-size: 13px; }

/* ── 토스트 ─────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #1f2733;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 반응형 ─────────────────────────── */
@media (max-width: 920px) {
  .main-grid { grid-template-columns: 1fr; }
  .input-panel { position: static; }
  .how-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 27px; }
  .site-nav { gap: 14px; }
}

/* ── 헤더 인터랙션 / 테마 토글 (Phase 2 디자인) ── */
.brand { cursor: pointer; user-select: none; border-radius: 8px; transition: opacity 0.15s; }
.brand:hover { opacity: 0.8; }
.brand:active { transform: translateY(1px); }
.brand:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.header-actions { display: flex; align-items: center; gap: 16px; }
.theme-toggle {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.theme-toggle:hover { border-color: var(--primary); background: var(--primary-soft); }
.theme-toggle:active { transform: translateY(1px) scale(0.96); }

/* 네비: 클릭 시 해당 섹션으로 + 활성 밑줄 */
.site-nav a { position: relative; padding: 4px 2px; transition: color 0.15s; }
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--primary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}
.site-nav a:hover::after,
.site-nav a.active::after { transform: scaleX(1); }
.site-nav a.active { color: var(--primary); }

/* 버튼 클릭(눌림) 피드백 */
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:active:not(:disabled) { background: var(--primary-dark); }
.panel, .how-card, .chip { transition: background 0.25s ease, border-color 0.25s ease; }

/* 다크 모드 미세 보정 */
[data-theme="dark"] .prd-input:focus { background: var(--surface); }
[data-theme="dark"] .dropzone { border-color: var(--border); }
[data-theme="dark"] .file-status { background: var(--surface-2); }
[data-theme="dark"] .file-status.loading { background: rgba(255, 169, 77, 0.14); }
[data-theme="dark"] .file-status.done { background: rgba(81, 207, 102, 0.14); }
[data-theme="dark"] .file-status.warn { background: rgba(255, 107, 107, 0.14); }
[data-theme="dark"] .badge-normal { background: rgba(81, 207, 102, 0.18); }
[data-theme="dark"] .badge-exception { background: rgba(255, 146, 43, 0.18); }
[data-theme="dark"] .badge-boundary { background: rgba(204, 93, 232, 0.18); }
[data-theme="dark"] .btn-chip { background: var(--primary-soft); color: var(--text); }
[data-theme="dark"] .btn-chip:hover { background: #243150; }
[data-theme="dark"] .btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

/* 모션 최소화 선호 사용자 배려 */
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* ── 모바일 보정 (Phase 2) ── */
@media (max-width: 560px) {
  :root { --header-h: 56px; }
  .brand-sub { display: none; }
  .site-nav { gap: 13px; font-size: 13px; }
  .header-actions { gap: 10px; }
  .theme-toggle { width: 34px; height: 34px; font-size: 15px; }
  .hero { padding: 40px 0 28px; }
  .hero h1 { font-size: 23px; }
  .hero-desc { font-size: 15px; }
  .result-actions { width: 100%; }
  .result-actions .btn { flex: 1 1 auto; }
  .how { padding: 28px 16px 36px; }
}
