/* ================================
   플로팅 챗봇 CSS (최종본)
   - 도킹형 모달 기준
   - 기본 여백 10px 유지
   ================================ */

:root {
  --brand: #0B3D91;
  /* FullCount 네이비 */
  --ink: #222;
  --line: #e6e6e6;
  --bg: #fff;
  --bot: #f3f6fc;
  --user: #d7e2ff;
  --radius: 16px;
}

/* ========== FAB 플로팅 버튼 ========== */
.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  padding: 0;
  border: 2px solid var(--brand);
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
  overflow: hidden;
  cursor: pointer;
  z-index: 12000;
  /* 메뉴/배너보다 위 */
}

.fab img {
  width: 95%;
  height: 95%;
  object-fit: contain;
  display: block;
  margin: auto;
}

/* ========== 모달 공통(중앙형 기본) ========== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: block;
}

.modal[hidden] {
  display: none !important;
}

/* hidden 토글 보정 */
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .36);
}

.modal__dialog {
  position: relative;
  z-index: 1;
  width: min(640px, 92vw);
  margin: 8vh auto 0;
  background: #fff;
  color: var(--ink);
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  overflow: hidden;
}

.modal__header,
.modal__footer {
  padding: 14px 16px;
  background: #fafafa;
  border-bottom: 1px solid var(--line);
}

.modal__footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal__body {
  padding: 18px 16px;
  max-height: 64vh;
  overflow: auto;
}

/* ========== 도킹형(우하단 패널) ========== */
.modal.dock {
  pointer-events: none;
  z-index: 11000;
  display: block;
}

.modal.dock .modal__backdrop {
  display: none;
}

.modal.dock .modal__dialog {
  pointer-events: auto;
  position: fixed;
  right: 24px;
  bottom: 100px;
  /* FAB 위로 */
  width: min(420px, 92vw);
  max-height: 60vh;
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  transform: translateY(8px);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
  z-index: 11001;
}

.modal.dock.show .modal__dialog {
  transform: translateY(0);
  opacity: 1;
}

/* ========== 채팅 로그/입력 영역 ========== */
.chat-log {
  background: #f7f7f7;
  border: 1px solid var(--line);
  border-radius: 12px;
  /* 채팅창 크기 여기 조절  */
  height: 400px;
  overflow: auto;
  padding: 10px;
  /* 기본 10px */
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* 기본 10px */
  scroll-behavior: smooth;
  /* 채팅 스크롤이 끝나면 페이지로 체이닝 허용 + iOS 부드러운 스크롤 */
  overscroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
}

.chat-input-wrap {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  /* 기본 10px */
}

#chatInput {
  flex: 1;
  height: 40px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
}

#chatInput:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(11, 61, 145, .08);
}

.modal__btn,
#chatSend {
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  cursor: pointer;
}

#chatSend {
  min-width: 50px;
  height: 42px;
  border-radius: 10px;
  /* 둥근 사각형 */
  border: none;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  transition: .2s;
}

#chatSend:hover {
  background: #093076;
}

/* ========== 메시지 (모달 위젯 DOM: .message만 쓰는 구조) ========== */
.message {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  line-height: 1.5;
  word-break: break-word;
  background: #eaeaea;
  color: #111;
  display: inline-block;
}

.message.user {
  margin-left: auto;
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.message.bot {
  margin-right: auto;
  background: #eaeaea;
  color: #111;
  border-bottom-left-radius: 6px;
}

/* ========== (선택) 봇 아바타/버블을 쓰는 메인 DOM과 호환 ========== */
/* 메인 챗이 .fc-row/.fc-bubble/.fc-avatar 구조일 때도 자연스럽게 보이도록 */
.fc-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.fc-row.user {
  justify-content: flex-end;
}

.fc-row.bot {
  justify-content: flex-start;
}

.fc-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: url('/assets/img/Baseball_speech_bubble_icon.png') center/100% no-repeat #fff;
  /* 이미지 중심 정렬 + 크기 60% + 흰색 배경 */
  box-shadow: 0 1px 4px rgba(0, 0, 0, .1);
  flex-shrink: 0;
}

.fc-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bot);
  color: #111;
  border-bottom-left-radius: 6px;
}

.fc-row.user .fc-bubble {
  background: var(--user);
  border-bottom-right-radius: 6px;
}

/* ========== 퀵버튼/링크(메인/모달 공용) ========== */
.fc-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 2px 0;
}

.fc-quick__btn {
  border: 1px solid var(--brand);
  background: #fff;
  color: var(--brand);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: .2s;
}

.fc-quick__btn:hover {
  background: var(--brand);
  color: #fff;
}

.fc-links {
  display: flex;
  flex-direction: column;
  margin: 2px 0 0 0;
}

.fc-link {
  color: var(--brand);
  text-decoration: none;
  font-size: 14px;
  padding: 2px 0;
}

.fc-link:hover {
  text-decoration: underline;
}

/* ========== 모바일 반응형 ========== */
@media (max-width: 768px) {

  /* FAB 버튼 모바일 최적화 */
  .fab {
    right: 16px;
    bottom: 16px;
    width: 60px;
    height: 60px;
  }

  /*1115*/
  /* 도킹형 모달 모바일 최적화 */
  .modal.dock .modal__dialog {
    right: 8px;
    bottom: 80px;
    width: calc(100vw - 16px);
    max-width: none;
    max-height: 65vh;
  }

  /* 중앙형 모달 모바일 최적화 */
  .modal__dialog {
    width: calc(100vw - 16px);
    margin: 4vh auto 0;
  }

  /* 채팅 로그 높이 조정 */



  /* 채팅 입력창 조정 */
  .chat-input-wrap {
    gap: 8px;
    margin-top: 8px;
  }

  #chatInput {
    height: 36px;
    padding: 6px 8px;
    font-size: 16px;
    /* iOS 자동 줌 방지 */
    border-radius: 8px;
  }

  #chatSend {
    min-width: 45px;
    height: 38px;
    padding: 8px 12px;
    border-radius: 8px;
  }

  /* 메시지 조정 */
  .message {
    max-width: 85%;
    padding: 6px 10px;
    font-size: 14px;
    border-radius: 10px;
  }

  /* 봇 아바타 조정 */
  .fc-avatar {
    width: 28px;
    height: 28px;
  }

  .fc-bubble {
    max-width: 80%;
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 14px;
  }

  /* 퀵버튼 조정 */
  .fc-quick__btn {
    padding: 5px 12px;
    font-size: 12px;
  }

  /* 모달 헤더/푸터 조정 */
  .modal__header,
  .modal__footer {
    padding: 12px 14px;
  }

  /*1115*/
  .modal__body {
    padding: 14px;
    /* height: 80vh;  ← 이 줄 삭제 */

    /* 헤더 + 푸터 만큼 빼고 최대 높이만 제한 */
    max-height: calc(65vh - 120px);
    /* 숫자 120px은 헤더+푸터 합친 대략 높이, 필요하면 100~140 사이로 조정 */

    overflow-y: auto;
    /* 내용이 넘치면 안에서 스크롤 */
  }

  .chat-log {
    height: calc(45vh - 70px) !important;

    padding: 8px;
    gap: 8px;
  }

  /* 도킹형에서 배경 블러 */
  .modal.dock .modal__backdrop {
    display: block;
    /* 숨기지 말고 보여주기 */
    background: rgba(0, 0, 0, 0.15);
    /* 살짝 어두운 얇은 레이어 */
    backdrop-filter: blur(4px);
    /* 배경 블러 */
    -webkit-backdrop-filter: blur(4px);
    /* iOS/Safari용 */
  }

  /* 버튼 조정 */
  .modal__btn {
    padding: 8px 14px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {

  /* 작은 모바일 화면 추가 최적화 */
  .fab {
    right: 12px;
    bottom: 12px;
    width: 56px;
    height: 56px;
  }

  .modal.dock .modal__dialog {
    right: 4px;
    bottom: 72px;
    width: calc(100vw - 8px);
    max-height: 45vh;
  }

  .chat-log {
    height: 240px;
    padding: 6px;
    gap: 6px;
  }

  .message {
    max-width: 90%;
    padding: 5px 8px;
    font-size: 13px;
  }

  .fc-bubble {
    max-width: 85%;
    padding: 7px 10px;
    font-size: 13px;
  }

  .fc-quick__btn {
    padding: 4px 10px;
    font-size: 11px;
  }
}