/* frontend/css/qbank.css — 문제은행 화면 공용 스타일 (LEET · PSAT)
 *
 * ★규칙 1(UI 일관성) — 목록 카드·제시문 상자·선지·결과 패널·해설·관리자 편집기는
 * 시험이 달라도 같은 모양이어야 하므로 한 곳에서 정한다. 페이지에는 *그 시험에만 있는 것*만 남긴다.
 *   - leet.html : 논술형(.es-*·답안 작성)  ← LEET 에만 있다
 *   - psat.html : 없음
 *
 * ⚠️ 클래스 이름은 `.qb-*` 가 정본이고 `.leet-*` 는 **먼저 쓰이던 이름**이라 함께 적어 둔다.
 *    LEET 화면(leet.js·leet-essay.js)이 아직 `.leet-*` 를 뿜으므로 지우면 그 화면이 깨진다.
 *    새로 만드는 화면은 `.qb-*` 를 쓴다.
 *
 * 사이드바 콤보박스(.qbank-controls/.qbank-select)는 사례형·기록형과도 공용이라 css/header.css 에 있다.
 */

/* ── 본문 폭 ───────────────────────────────────────────
   제시문이 긴 산문이라 사이드바를 뺀 폭(약 940px)을 그대로 쓰면 한 줄이 너무 길다. */
#list-view, #detail-view { max-width: 880px; }

/* ── 과목·회차(연도) 헤더 ──────────────────────────── */
.qb-head, .leet-head { margin-bottom: 1rem; }
.qb-head h1, .leet-head h1 { font-family: var(--font-serif); font-size: 1.5rem; font-weight: 700; }
.qb-head .qb-sub, .leet-head .leet-sub { color: #888; font-size: 0.85rem; margin-top: 0.25rem; }
.result-info { font-size: 0.85rem; color: #888; }

/* ── 사이드바 미니맵 — 사례형 case-minimap 과 같은 모양 ── */
.qb-minimap, .leet-minimap { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.qb-mm-title, .leet-mm-title { font-family: var(--font-serif); font-size: 0.85rem; color: var(--gold-dark); margin-bottom: 0.5rem; }
.qb-mm-item, .leet-mm-item {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.45rem; border-radius: 5px; cursor: pointer;
  font-size: 0.82rem; color: #555; border-left: 2px solid transparent;
}
.qb-mm-item:hover,  .leet-mm-item:hover  { background: var(--parchment); color: var(--ink); }
.qb-mm-item.active, .leet-mm-item.active { background: #fef3c7; color: var(--ink); border-left-color: var(--gold); font-weight: 600; }
.qb-mm-note, .leet-mm-note { margin-left: auto; font-size: 0.7rem; color: #aaa; }
.qb-mm-empty, .leet-mm-empty { font-size: 0.8rem; color: #aaa; padding: 0.4rem; }

/* ── 목록 카드 ─────────────────────────────────────── */
.q-list { display: flex; flex-direction: column; gap: 0.875rem; }
.q-card {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.4rem; cursor: pointer; transition: all 0.15s;
}
.q-card:hover { border-color: var(--gold); box-shadow: 0 4px 16px var(--shadow); }
.q-card-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.q-num { font-family: var(--font-serif); font-weight: 700; font-size: 0.95rem; color: var(--gold); }
.q-badge-set { font-size: 0.7rem; font-weight: 700; padding: 0.12rem 0.5rem; border-radius: 4px; background: #e0e7ff; color: #4338ca; }
.q-preview { font-size: 0.875rem; color: var(--ink); line-height: 1.6; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ── 상세 (지문 묶음) ──────────────────────────────── */
.q-detail { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.75rem 2rem; }
.q-detail-nav { display: flex; align-items: center; margin-bottom: 1.25rem; gap: 1rem; }
.q-detail-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-left: auto; }
.q-edit-btn { font-size: 0.78rem; padding: 0.25rem 0.6rem; border: 1px solid var(--border); border-radius: 5px; background: white; cursor: pointer; }

/* 제시문 박스 — 레이아웃 A: 지문을 위에 한 번, 아래에 관련 문항 세로 */
.qb-passage, .leet-passage {
  background: #fbf9f3; border: 1px solid var(--border); border-left: 4px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 1.25rem 1.5rem; margin-bottom: 1.75rem;
}
.qb-passage-label, .leet-passage-label { font-family: var(--font-serif); font-weight: 700; font-size: 0.85rem; color: var(--gold-dark, #9a7b0a); margin-bottom: 0.6rem; }
.qb-passage-body,  .leet-passage-body  { font-size: 0.92rem; line-height: 1.9; word-break: keep-all; text-align: justify; }
/* 제시문/보기 안의 인용 블록(사료·견해 인용 등)은 '판례·법령 원문 인용'을 뜻하는
   전역 .md-body blockquote(금색 좌측 보더)를 물려받지 않도록 중립 인용 스타일로 덮는다. */
.qb-passage-body.md-body blockquote,
.leet-passage-body.md-body blockquote,
.q-subtext.md-body blockquote,
.q-body.md-body blockquote {
  border-left: 2px solid #d8d2c2; background: transparent; color: inherit;
  padding: 0.15rem 0 0.15rem 1rem; margin: 0.7rem 0 0.7rem 0.4rem;
}

/* 문항 블록 */
.qb-qblock, .leet-qblock { padding-top: 1.5rem; margin-top: 1.5rem; border-top: 1px dashed var(--border); }
.qb-qblock:first-of-type, .leet-qblock:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.qb-qno, .leet-qno { font-family: var(--font-serif); font-weight: 700; font-size: 1rem; color: var(--ink); margin-bottom: 0.6rem; display: flex; align-items: center; gap: 0.5rem; }
.qb-qno .badge, .leet-qno .badge { font-size: 0.72rem; }
.q-body { font-size: 0.95rem; line-height: 1.85; margin-bottom: 1rem; word-break: keep-all; }

/* 보기/사례 박스 — mc.html .q-subtext 양피지 박스와 같은 형태 */
.q-subtext { background: var(--parchment); border-left: 3px solid var(--gold); padding: 0.9rem 1.15rem; margin-bottom: 1.1rem; font-size: 0.9rem; line-height: 1.85; word-break: keep-all; border-radius: 0 var(--radius) var(--radius) 0; text-align: justify; }

/* 마크다운 표 (기록형처럼) */
.md-body table { width: 100%; border-collapse: collapse; margin: 0.6rem 0; font-size: 0.86rem; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; vertical-align: top; }
.md-body thead th { background: var(--parchment); }
.md-body img { max-width: 100%; height: auto; }
.md-table-wrap { overflow-x: auto; }
/* 원문 밑줄(++...++ → <ins>) 재현 — 발문·제시문·보기·선지 어디서든 밑줄로 보이게 */
.q-detail ins { text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }

/* ── 선택지 ─────────────────────────────────────── */
.choices { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.25rem; }
.choice { display: flex; align-items: flex-start; gap: 0.85rem; padding: 0.8rem 1rem; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all 0.15s; font-size: 0.9rem; line-height: 1.65; }
.choice:hover:not(.revealed) { border-color: var(--gold); background: #fffdf5; }
.choice.selected { border-color: var(--blue); background: #eff6ff; }
.choice.correct { border-color: var(--green); background: #f0fdf4; }
.choice.wrong { border-color: var(--red); background: #fff5f5; }
.choice.revealed { cursor: default; }
.choice-num { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 700; flex-shrink: 0; color: #777; }
.choice.selected .choice-num { border-color: var(--blue); color: var(--blue); background: #dbeafe; }
.choice.correct .choice-num { border-color: var(--green); color: var(--green); background: #d1fae5; }
.choice.wrong .choice-num { border-color: var(--red); color: var(--red); background: #fee2e2; }
.choice-text { flex: 1; }
.choice-mark { font-weight: 700; flex-shrink: 0; font-size: 0.82rem; }

.action-bar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.result-panel { padding: 1rem 1.3rem; border-radius: var(--radius); margin: 1rem 0; }
.result-panel.correct { background: #f0fdf4; border: 1px solid #6ee7b7; }
.result-panel.wrong { background: #fff5f5; border: 1px solid #fca5a5; }
.result-panel.peek { background: #fef9e7; border: 1px solid #f5d76e; }
.result-panel h4 { font-weight: 700; margin-bottom: 0.3rem; font-size: 0.98rem; }
.result-panel.correct h4 { color: var(--green); }
.result-panel.wrong h4 { color: var(--red); }
.result-panel.peek h4 { color: #b7860b; }
.result-panel p { font-size: 0.88rem; color: #555; margin-top: 0.35rem; line-height: 1.6; }
.result-panel .peek-hint { font-size: 0.82rem; color: #7c6a1a; font-style: italic; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 0.75rem; }
.stat-card { background: var(--parchment); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem; text-align: center; }
.stat-card .big { font-family: var(--font-serif); font-size: 1.6rem; font-weight: 700; display: block; }
.stat-card .sub { font-size: 0.74rem; color: #888; margin-top: 0.2rem; display: block; }

/* ── AI 해설 ─────────────────────────────────────── */
.ai-explanation { margin-top: 1rem; padding: 1.25rem 1.5rem; background: linear-gradient(135deg,#fef9e7 0%,#fef3c7 100%); border: 1px solid #f5d76e; border-radius: var(--radius); }
.ai-explanation h3 { font-family: var(--font-serif); font-size: 1rem; font-weight: 700; margin-bottom: 0.6rem; }
.ai-explanation .exp-body { font-size: 0.9rem; line-height: 1.8; color: #333; word-break: keep-all; text-align: justify; }
.ai-explanation .exp-body strong { color: var(--red); font-weight: 700; }
.ai-explanation .exp-body blockquote { border-left: 3px solid var(--gold); background: #fffdf3; padding: 0.5rem 1rem; margin: 0.6rem 0; }
.ai-explanation .exp-body a { color: var(--blue); text-decoration: underline; word-break: break-all; }
.ai-explanation .ai-disclaimer { margin-top: 0.9rem; padding-top: 0.7rem; border-top: 1px dashed #d4ac0d; font-size: 0.74rem; color: #888; font-style: italic; }
.ai-login-notice { margin-top: 1rem; padding: 1.25rem; text-align: center; background: var(--parchment); border: 1.5px dashed var(--border); border-radius: var(--radius); }
.ai-login-notice .icon { font-size: 1.8rem; display: block; margin-bottom: 0.5rem; }
.ai-login-notice p { color: #666; font-size: 0.9rem; margin-bottom: 0.7rem; }

.q-nav-btns { display: flex; gap: 0.75rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.q-nav-btns .btn { flex: 1; justify-content: center; }

/* 관리자 편집 */
.q-edit-form { background: var(--parchment); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }
.q-edit-form label { font-size: 0.8rem; font-weight: 600; color: #555; display: block; margin-bottom: 0.25rem; }
.q-edit-form textarea, .q-edit-form input { width: 100%; font-family: var(--font-sans); font-size: 0.88rem; padding: 0.5rem 0.65rem; border: 1px solid var(--border); border-radius: 5px; }
.q-edit-form textarea { min-height: 70px; resize: vertical; line-height: 1.6; }
.q-edit-choice-row { display: flex; gap: 0.5rem; align-items: flex-start; }
.q-edit-choice-num { width: 26px; height: 26px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #777; }
.q-edit-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ── 모바일 (사례형·기록형과 동일 규칙) ───────────── */
@media (max-width: 900px) {
  /* 사이드바를 상단 가로 바로 전환(전역 header.css 의 display:none 을 덮어씀) */
  .sidebar {
    display: block !important; position: static; height: auto;
    border-right: none; border-bottom: 1px solid var(--border); overflow: visible; padding: 1rem;
  }
  .qb-minimap, .leet-minimap { display: none; }   /* 미니맵은 데스크톱에서만 */
}
@media (max-width: 600px) {
  .q-detail        { padding: 1.1rem 0.9rem; }
  .ai-explanation  { padding: 1.1rem 0.9rem; }
  .qb-passage, .leet-passage { padding: 1rem 0.9rem; }
}
