/* 탁송비 견적 계산 서비스 스타일 */

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background: linear-gradient(135deg, #f0f4ff 0%, #fafafa 100%);
}

/* 채팅 컨테이너 */
#chat-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 680px;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 40px rgba(0,0,0,0.08);
}

/* 헤더 */
#chat-header {
  background: linear-gradient(135deg, #1a56db 0%, #1e40af 100%);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#chat-header .logo-icon {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
#chat-header h1 { font-size: 16px; font-weight: 700; margin: 0; }
#chat-header p { font-size: 12px; margin: 0; opacity: 0.8; }

/* API 설정 배너 */
#api-notice {
  background: #fef9c3;
  border-bottom: 1px solid #fde047;
  padding: 8px 16px;
  font-size: 12px;
  color: #854d0e;
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
#api-notice.hidden { display: none; }

/* 메시지 영역 */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* 메시지 버블 */
.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 85%;
}
.msg.bot { align-self: flex-start; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a56db, #1e40af);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px;
  flex-shrink: 0;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-break: keep-all;
}
.msg.bot .msg-bubble {
  background: #f1f5ff;
  border-bottom-left-radius: 4px;
  color: #1e293b;
}
.msg.user .msg-bubble {
  background: #1a56db;
  border-bottom-right-radius: 4px;
  color: #fff;
}

/* 후보 주소 카드 */
.candidate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.candidate-btn {
  background: #fff;
  border: 1.5px solid #c7d2fe;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  font-size: 13px;
}
.candidate-btn:hover {
  border-color: #1a56db;
  background: #f0f4ff;
  transform: translateX(2px);
}
.candidate-btn .place-name {
  font-weight: 600;
  color: #1e40af;
  font-size: 14px;
  display: block;
  margin-bottom: 2px;
}
.candidate-btn .address {
  color: #64748b;
  font-size: 12px;
  display: block;
}

.confirmed-location {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.confirmed-location > div { display: grid; gap: 3px; }
.confirmed-location strong { font-size: 12px; color: #334155; }
.confirmed-label { font-size: 11px; color: #64748b; }
.btn-edit-origin {
  flex-shrink: 0;
  border: 1px solid #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.btn-edit-origin:hover { background: #dbeafe; }
.btn-edit-origin:disabled { opacity: .5; cursor: default; }

/* 결과 카드 */
.result-card {
  background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
  border: 2px solid #c7d2fe;
  border-radius: 16px;
  padding: 18px;
  margin-top: 8px;
}
.result-fare {
  font-size: 28px;
  font-weight: 800;
  color: #1e40af;
  text-align: center;
  margin: 12px 0;
}
.result-label {
  font-size: 12px;
  color: #64748b;
  text-align: center;
  margin-bottom: 4px;
}
.result-route {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin: 8px 0;
  padding: 8px 0;
  border-top: 1px solid #c7d2fe;
  border-bottom: 1px solid #c7d2fe;
}
.result-address {
  font-size: 12px;
  color: #475569;
  margin: 6px 0;
}
.result-address strong { color: #1e40af; }
.result-notice {
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
  margin-top: 10px;
  line-height: 1.4;
}
.result-mock-notice {
  font-size: 11px;
  color: #d97706;
  background: #fef3c7;
  padding: 6px 10px;
  border-radius: 8px;
  margin-top: 8px;
  text-align: center;
}

/* 계산 상세 토글 */
.calc-detail {
  margin-top: 8px;
  border-top: 1px solid #c7d2fe;
  padding-top: 8px;
}
.calc-detail summary {
  font-size: 12px;
  color: #6366f1;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.calc-step {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #64748b;
  padding: 2px 0;
}
.calc-step .step-value { color: #1e40af; font-weight: 500; }

/* 다시 계산 버튼 */
.btn-restart {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  background: #1a56db;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-restart:hover { background: #1e40af; }

/* 타이핑 인디케이터 */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: #f1f5ff;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-dot {
  width: 8px; height: 8px;
  background: #93c5fd;
  border-radius: 50%;
  animation: typing 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* 입력 영역 */
#input-area {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}
#input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
#user-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #c7d2fe;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.15s;
  font-family: inherit;
}
#user-input:focus { border-color: #1a56db; }
#user-input:disabled {
  background: #f8fafc;
  color: #94a3b8;
}
#send-btn {
  width: 42px; height: 42px;
  background: #1a56db;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
#send-btn:hover:not(:disabled) { background: #1e40af; transform: scale(1.05); }
#send-btn:disabled { background: #cbd5e1; cursor: not-allowed; }

/* 진행 표시 */
.progress-steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  flex-shrink: 0;
}
.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #e2e8f0;
  transition: all 0.3s;
}
.step-dot.active { background: #1a56db; transform: scale(1.3); }
.step-dot.done { background: #34d399; }

.waypoint-option-actions { display:flex; gap:8px; margin-top:10px; }
.waypoint-option-actions .candidate-btn { flex:1; text-align:center; }
.primary-choice { background:#1a56db !important; color:#fff !important; }
.waypoint-list, .waypoint-summary { margin:10px 0; padding:10px; border-radius:10px; background:#fff7ed; font-size:12px; }
.waypoint-row { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:7px 0; border-bottom:1px solid #fed7aa; }
.waypoint-row:last-child { border-bottom:0; }
.waypoint-row span { flex:1; overflow-wrap:anywhere; }
.waypoint-row button { border:1px solid #cbd5e1; border-radius:6px; background:white; padding:3px 6px; margin-left:3px; cursor:pointer; }
.waypoint-row button:disabled { opacity:.35; cursor:not-allowed; }
.fare-breakdown { display:flex; flex-direction:column; gap:4px; margin:10px 0; padding:10px; background:#f8fafc; border-radius:8px; font-size:12px; color:#475569; }
.result-actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:12px; }
.result-actions .btn-restart { margin-top:0; }
.btn-request { border:0; border-radius:10px; padding:11px 14px; color:#fff; background:#059669; font-weight:700; cursor:pointer; }
.btn-request:disabled { opacity:.5; cursor:not-allowed; }
.request-modal { position:fixed; inset:0; z-index:100; display:flex; justify-content:center; align-items:flex-start; padding:20px; background:rgba(15,23,42,.55); overflow:auto; }
.request-dialog { width:min(680px,100%); background:#fff; border-radius:16px; padding:20px; box-shadow:0 20px 50px rgba(15,23,42,.25); }
.request-header { display:flex; justify-content:space-between; align-items:center; }
.request-header h2 { margin:0; font-size:20px; }
.request-header button { border:0; background:none; font-size:28px; cursor:pointer; }
.muted-copy,.request-address { color:#64748b; font-size:13px; }
.request-dialog fieldset { border:1px solid #e2e8f0; border-radius:10px; margin:14px 0; padding:14px; }
.request-dialog legend { padding:0 6px; font-weight:700; color:#334155; }
.request-dialog label { display:flex; flex-direction:column; gap:5px; margin:9px 0; color:#475569; font-size:13px; }
.request-dialog input,.request-dialog select,.request-dialog textarea { width:100%; border:1px solid #cbd5e1; border-radius:8px; padding:10px; font:inherit; box-sizing:border-box; }
.request-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.request-dialog .check-row { flex-direction:row; align-items:center; }
.request-dialog .check-row input { width:auto; }
.request-footer { display:flex; justify-content:flex-end; gap:8px; margin-top:16px; }
.secondary-request { border:1px solid #cbd5e1; background:#fff; border-radius:10px; padding:10px 14px; cursor:pointer; }
.request-error { color:#dc2626; font-size:13px; min-height:18px; }
.request-confirm>div { padding:12px 0; border-bottom:1px solid #e2e8f0; font-size:13px; line-height:1.6; }
.request-success { text-align:center; }
.request-success>i { font-size:44px; color:#059669; }
.request-success pre { white-space:pre-wrap; text-align:left; background:#f8fafc; border-radius:10px; padding:14px; font-family:inherit; font-size:12px; }
.request-success button { margin:4px; }

/* 모바일 */
@media (max-width: 680px) {
  #chat-container { box-shadow: none; }
  .msg { max-width: 92%; }
  .request-grid,.result-actions { grid-template-columns:1fr; }
}
