/* ============================================================
   견적 챗봇/계산기 — 고객용 스타일 (원본 frontend/src/styles.css)
   전부 .estimate-app 스코프. 마케팅 전역 CSS(bootstrap/base/style)와 공존하도록
   격리 + 전역 리셋 역간섭 차단. (관리자 CMS 스타일은 Phase 3에서 이식)
   ============================================================ */

/* 스코프 루트: CSS 변수 + 폰트 + 레이아웃. 마케팅 고정헤더(9rem) 아래 한 화면 높이로 고정. */
.estimate-app {
  --accent: #3d6df6;
  --accent-soft: #eef2fe;
  --ink: #1b2138;
  --text: #3a4156;
  --muted: #9aa0b4;
  --line: #e7e9f2;
  --logo: #6c5ce7;

  font-family: "Inter", "Noto Sans KR", system-ui, sans-serif;
  color: var(--text);
  letter-spacing: normal; /* 마케팅 body{letter-spacing:-0.5px} 상속 차단 */

  margin-top: 9rem;                  /* 고정 헤더(position:fixed; height:9rem) 비켜주기 */
  height: calc(100vh - 9rem);        /* 한 화면 높이 — 내부 패널이 자체 스크롤 */
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse 88% 36% at 28% 0%, rgba(108, 92, 231, 0.07), transparent 55%), #f4f6fb;
}
/* 모두의창업 프로모 배너가 떠 있으면 헤더가 그만큼 내려가므로 보정 */
body.has-promo .estimate-app {
  margin-top: calc(9rem + var(--promo-h, 0px));
  height: calc(100vh - 9rem - var(--promo-h, 0px));
}

/* 전역 리셋 역간섭 차단 (base.css/default.css) */
.estimate-app *,
.estimate-app *::before,
.estimate-app *::after { box-sizing: border-box; }
.estimate-app ::selection { background: rgba(61, 109, 246, 0.18); }
/* 마케팅 h1~h6{font-family:Pretendard} 재상속 → 견적 폰트 스택 사용 */
.estimate-app h1, .estimate-app h2, .estimate-app h3,
.estimate-app h4, .estimate-app h5, .estimate-app h6 { font-family: inherit; }

/* 방식 선택 탭 (원본 topbar nav 대체 — 마케팅 SiteHeader/Footer가 chrome 담당) */
.estimate-app .eapp-tabs {
  flex: none; display: flex; align-items: center; gap: 6px;
  padding: 12px 28px; border-bottom: 1px solid var(--line); background: #fff;
}
.estimate-app .eapp-tab {
  padding: 8px 16px; border-radius: 9999px; font-size: 14px; font-weight: 500;
  color: var(--text); background: none; border: 1px solid transparent; cursor: pointer;
  font-family: inherit; transition: background 0.15s, color 0.15s;
}
.estimate-app .eapp-tab:hover { background: var(--accent-soft); color: var(--accent); }
.estimate-app .eapp-tab.on { background: var(--accent); color: #fff; }

/* layout */
.estimate-app .main { flex: 1; min-height: 0; display: flex; }

/* 예상 견적 계산 페이지 */
.estimate-app .calc { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.estimate-app .calc-scroll { flex: 1; overflow-y: auto; padding: 30px 32px; }
.estimate-app .calc-inner { max-width: 760px; margin: 0 auto; }
.estimate-app .calc-state { padding: 40px 4px; text-align: center; color: var(--muted); font-size: 14px; }

.estimate-app .calc-cat { margin-bottom: 30px; }
.estimate-app .calc-cat-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 13px; }
.estimate-app .calc-cat-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink); }
.estimate-app .calc-cat-type {
  font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  padding: 2px 8px; border-radius: 9999px;
}

.estimate-app .calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.estimate-app .calc-card {
  position: relative; text-align: left; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; gap: 7px;
  padding: 15px 16px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.estimate-app .calc-card:hover { border-color: #c7cfeb; box-shadow: 0 4px 14px rgba(20, 30, 80, 0.06); }
.estimate-app .calc-card.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 4px 14px rgba(61, 109, 246, 0.14); }

.estimate-app .calc-check {
  position: absolute; top: 12px; right: 12px; width: 19px; height: 19px; border-radius: 6px;
  border: 1px solid #cfd5e6; background: #fff; display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.estimate-app .calc-card.on .calc-check { background: var(--accent); border-color: var(--accent); }

.estimate-app .calc-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-right: 26px; }
.estimate-app .calc-card-title { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.estimate-app .calc-card-price { font-size: 13.5px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.estimate-app .calc-card-desc { font-size: 12.5px; line-height: 1.55; color: var(--muted); white-space: pre-line; }

/* chat */
.estimate-app .chat { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.estimate-app .chat-scroll { flex: 1; overflow-y: auto; padding: 30px 32px; }
.estimate-app .chat-inner { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

.estimate-app .msg-row { display: flex; gap: 12px; align-items: flex-start; }
.estimate-app .msg-row.user { justify-content: flex-end; }
.estimate-app .avatar {
  flex: none; width: 34px; height: 34px; border-radius: 11px;
  border: 1px solid #e2e5f5; background: #eef0fe;
  display: flex; align-items: center; justify-content: center; color: var(--logo);
}
.estimate-app .bubble {
  max-width: 78%; padding: 13px 17px; font-size: 15px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}
.estimate-app .bubble.assistant {
  border-radius: 4px 18px 18px 18px; border: 1px solid var(--line);
  background: #fff; color: var(--text); box-shadow: 0 2px 10px rgba(20, 30, 80, 0.04);
}
.estimate-app .bubble.user {
  border-radius: 18px 4px 18px 18px; background: var(--accent); color: #fff;
  box-shadow: 0 4px 14px rgba(61, 109, 246, 0.22);
}

.estimate-app .typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.estimate-app .typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #c3c9dd;
  animation: eapp-blink 1.4s infinite both;
}
.estimate-app .typing span:nth-child(2) { animation-delay: 0.2s; }
.estimate-app .typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes eapp-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* input */
.estimate-app .input-wrap { flex: none; padding: 18px 32px 24px; border-top: 1px solid var(--line); background: #fff; }
.estimate-app .input-bar {
  max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 10px;
  border: 1px solid #dfe3ef; background: #f7f8fc; border-radius: 16px; padding: 7px 8px 7px 18px;
}
.estimate-app .input-bar input {
  flex: 1; min-width: 0; background: transparent; border: none; outline: none;
  color: var(--ink); font-size: 15px; font-family: inherit;
}
.estimate-app .send-btn {
  flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--accent);
  color: #fff; border: none; display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 12px rgba(61, 109, 246, 0.28);
}
.estimate-app .send-btn:disabled { opacity: 0.5; cursor: default; }
.estimate-app .input-hint { max-width: 720px; margin: 10px auto 0; font-size: 11px; color: var(--muted); text-align: center; }

/* 추천 카드 (채팅 내 상담식 추천) */
.estimate-app .rec-wrap { margin: 2px 0 2px 46px; }
.estimate-app .rec-label {
  display: inline-flex; align-items: center; gap: 5px; margin: 0 0 9px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: var(--accent);
}
.estimate-app .rec-list { display: flex; flex-direction: column; gap: 9px; }
.estimate-app .rec-card {
  text-align: left; font-family: inherit; cursor: pointer; position: relative;
  display: flex; flex-direction: column; gap: 5px;
  padding: 12px 15px 12px 40px; border: 1px solid #d9e1fb; border-radius: 13px;
  background: linear-gradient(180deg, #f7f9ff, #fff);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, transform 0.05s;
}
.estimate-app .rec-card:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(61, 109, 246, 0.14); }
.estimate-app .rec-card:active { transform: translateY(1px); }
.estimate-app .rec-card.on { border-color: var(--accent); background: var(--accent-soft); }
.estimate-app .rec-check {
  position: absolute; top: 13px; left: 13px; width: 18px; height: 18px; border-radius: 6px;
  border: 1px solid #c2cdf2; background: #fff; display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.estimate-app .rec-card.on .rec-check { background: var(--accent); border-color: var(--accent); }
.estimate-app .rec-card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.estimate-app .rec-card-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.estimate-app .rec-badge {
  display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 9999px;
  font-size: 10.5px; font-weight: 700; color: #b8860b; background: #fff5d6; border: 1px solid #f2e2a8;
}
.estimate-app .rec-card-cat { font-size: 11px; color: var(--muted); }
.estimate-app .rec-card-reason { font-size: 12.5px; line-height: 1.55; color: var(--text); }

.estimate-app .rec-submit {
  margin-top: 10px; width: 100%; font-family: inherit; cursor: pointer;
  padding: 11px; border-radius: 11px; border: none; font-size: 13.5px; font-weight: 600;
  background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(61, 109, 246, 0.24);
  transition: opacity 0.15s;
}
.estimate-app .rec-submit:disabled {
  background: #eef0f6; color: var(--muted); box-shadow: none; cursor: default;
}

/* sidebar */
.estimate-app .sidebar {
  width: 384px; flex: none; display: flex; flex-direction: column; min-height: 0;
  background: #fff; border-left: 1px solid var(--line);
}
.estimate-app .sidebar-head { flex: none; padding: 22px 24px 18px; border-bottom: 1px solid #eef0f6; }
.estimate-app .live-label {
  margin: 0 0 13px; font-size: 11px; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.estimate-app .steps { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.estimate-app .steps .step { display: inline-flex; align-items: center; gap: 5px; }
.estimate-app .steps .step.active, .estimate-app .steps .step.done { color: #15a266; }
.estimate-app .steps .step.pending { color: var(--muted); }
.estimate-app .steps .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.estimate-app .steps .step.active .dot { background: #1fb573; }
.estimate-app .steps .step.pending .dot { background: #cfd5e3; }
.estimate-app .steps .bar { flex: 1; height: 1px; background: var(--line); }

.estimate-app .items { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 24px; }
.estimate-app .empty { color: var(--muted); font-size: 13.5px; line-height: 1.6; padding: 24px 4px; text-align: center; }
.estimate-app .line-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid #eef0f6;
}
.estimate-app .line-item .label { font-size: 14px; color: var(--text); }
.estimate-app .line-item .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.estimate-app .line-item .amount {
  font-size: 14px; color: var(--ink); font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

.estimate-app .total-card { flex: none; padding: 18px 24px 22px; border-top: 1px solid #eef0f6; background: #fbfcfe; }
.estimate-app .badge {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 9999px; padding: 4px 11px;
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600;
  color: #15a266; background: #e4f7ee; margin-bottom: 12px;
}
.estimate-app .total-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.estimate-app .total-cap { margin: 0; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.estimate-app .total-sub { margin: 4px 0 0; font-size: 11.5px; color: #aab0c2; }
.estimate-app .total-amount {
  margin: 0; font-family: "Lora", "Noto Serif KR", serif; font-size: 27px; font-weight: 700;
  color: var(--ink); letter-spacing: -0.01em; font-variant-numeric: tabular-nums;
}
.estimate-app .meta-row {
  display: flex; justify-content: space-between; align-items: center; margin: 12px 0 16px;
  padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: #f4f6fb;
  font-size: 12.5px; color: #8a90a4;
}
.estimate-app .meta-row .v { font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }

/* 할인 표시(정가/할인 행) */
.estimate-app .meta-row.list { margin: 12px 0 0; }
.estimate-app .meta-row.list .v { color: var(--muted); text-decoration: line-through; }
.estimate-app .meta-row.discount { margin: 8px 0 0; border-color: #f3d6d8; background: #fdf4f4; color: #c0392b; }
.estimate-app .meta-row.discount .v { color: #d23f3f; font-weight: 700; }

.estimate-app .btn-primary {
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 9999px; padding: 13px; font: 600 14px/1 inherit; background: var(--accent);
  color: #fff; border: none; cursor: pointer; margin-bottom: 9px; box-shadow: 0 6px 16px rgba(61, 109, 246, 0.28);
}
.estimate-app .btn-primary:disabled { opacity: 0.45; cursor: default; box-shadow: none; }

/* assistant 말풍선 내 마크다운 렌더링 */
.estimate-app .bubble.md { white-space: normal; }
.estimate-app .bubble.md > :first-child { margin-top: 0; }
.estimate-app .bubble.md > :last-child { margin-bottom: 0; }
.estimate-app .bubble.md p { margin: 8px 0; }
.estimate-app .bubble.md h1, .estimate-app .bubble.md h2, .estimate-app .bubble.md h3 { font-size: 15px; font-weight: 600; color: var(--ink); margin: 12px 0 6px; }
.estimate-app .bubble.md ul, .estimate-app .bubble.md ol { margin: 6px 0; padding-left: 20px; }
/* base.css 의 ul{list-style:none} 역간섭 차단 — 마크다운 불릿/번호 복원 */
.estimate-app .bubble.md ul { list-style: disc; }
.estimate-app .bubble.md ol { list-style: decimal; }
.estimate-app .bubble.md li { margin: 3px 0; }
.estimate-app .bubble.md strong { color: var(--ink); }
.estimate-app .bubble.md hr { border: none; border-top: 1px solid #eef0f6; margin: 10px 0; }
.estimate-app .bubble.md code { background: #f0f2f8; padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.estimate-app .bubble.md table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13.5px; }
.estimate-app .bubble.md th, .estimate-app .bubble.md td { border: 1px solid #e3e6f0; padding: 6px 10px; text-align: left; }
.estimate-app .bubble.md th { background: #f4f6fb; font-weight: 600; color: var(--ink); }

/* 견적서 연락처 입력 모달(고객용) — z-index 는 마케팅 고정헤더(1000) 위로 */
.estimate-app .quote-modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(20, 28, 60, 0.42);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.estimate-app .quote-modal {
  width: 100%; max-width: 380px; background: #fff; border-radius: 16px;
  padding: 24px 22px; box-shadow: 0 18px 50px rgba(20, 30, 80, 0.22);
}
.estimate-app .quote-modal-title { margin: 0 0 4px; font-size: 18px; font-weight: 700; color: var(--ink); }
.estimate-app .quote-modal-sub { margin: 0 0 16px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.estimate-app .quote-modal-label { display: block; font-size: 12.5px; font-weight: 600; color: #5b6276; margin: 12px 0 6px; }
.estimate-app .quote-modal-input {
  width: 100%; border: 1px solid #dfe3ef; background: #f7f8fc; border-radius: 10px;
  padding: 11px 13px; font-size: 14.5px; color: var(--text); font-family: inherit; outline: none;
}
.estimate-app .quote-modal-input:focus { border-color: var(--accent); background: #fff; }
.estimate-app .quote-modal-hint { margin: 12px 0 0; font-size: 12px; color: #8a90a4; }
.estimate-app .quote-modal-error { margin: 8px 0 0; font-size: 12.5px; color: #d8533d; font-weight: 600; }
.estimate-app .quote-modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.estimate-app .quote-modal-cancel {
  flex: none; border-radius: 9999px; padding: 11px 18px; font: 600 13.5px/1 inherit;
  background: #fff; color: #5b6276; border: 1px solid #d7dbea; cursor: pointer;
}
.estimate-app .quote-modal-cancel:hover { background: #f4f6fb; }
.estimate-app .quote-modal-submit {
  flex: 1; border-radius: 9999px; padding: 11px 18px; font: 700 13.5px/1 inherit;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
}
.estimate-app .quote-modal-submit:hover { filter: brightness(1.05); }

/* 좁은 화면: 두 패널을 세로 적층 + 페이지 스크롤로 전환 */
@media (max-width: 860px) {
  .estimate-app { height: auto; min-height: calc(100vh - 9rem); }
  .estimate-app .main { flex-direction: column; }
  .estimate-app .chat, .estimate-app .calc { min-height: auto; }
  .estimate-app .chat-scroll, .estimate-app .calc-scroll { overflow: visible; }
  .estimate-app .items { overflow: visible; }
  .estimate-app .sidebar { width: auto; border-left: none; border-top: 1px solid var(--line); }
}
