:root {
  --lj-ink: #17233b; /* 헤더/제목 텍스트 - 딥 네이비 */
  --lj-ink-soft: #5b6577; /* 보조 텍스트 */
  --lj-accent: #2f6f8f; /* 브랜드 포인트 - 차분한 틸 블루 */
  --lj-accent-dark: #24576f;
  --lj-porcelain: #f7f5f1; /* 채팅 배경 - 웜 포슬린 */
  --lj-line: #e6e1d8; /* 헤어라인 */
  --lj-bot-bg: #ffffff;
  --lj-online: #35c58b;
}

.chat-toggle-btn,
.chat-container,
.chat-container * {
  font-family:
    "Pretendard",
    -apple-system,
    BlinkMacSystemFont,
    "Malgun Gothic",
    sans-serif;
}

/* ===== 플로팅 버튼 ===== */
.chat-toggle-btn {
  position: fixed;
  left: 24px;
  right: auto;
  bottom: 24px;
  width: 58px;
  height: 58px;
  background: var(--lj-ink);
  color: white;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(23, 35, 59, 0.28);
  z-index: 999999 !important;
  display: flex !important;
  justify-content: center;
  align-items: center;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.chat-toggle-btn::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--lj-online);
  border: 2px solid #fff;
}
.chat-toggle-btn::before {
  content: "성형·피부 실시간 상담";
  position: absolute;
  left: 72px;
  right: auto;
  top: 50%;
  transform: translateY(-50%);
  background: var(--lj-ink);
  color: #fff;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(23, 35, 59, 0.22);
  pointer-events: none;
  animation: fadeInOut 3.2s ease-in-out infinite;
}
@keyframes fadeInOut {
  0%,
  100% {
    opacity: 0;
    transform: translateY(-50%) translateX(-6px);
  }
  15%,
  85% {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
}
.chat-toggle-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(23, 35, 59, 0.32);
}

/* ===== 컨테이너 ===== */
.chat-container {
  position: fixed;
  left: 24px;
  right: auto;
  bottom: 94px;
  width: 380px;
  height: 600px;
  max-height: 75vh;
  background: var(--lj-porcelain);
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(23, 35, 59, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.6);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  animation: slideUp 0.3s ease-out;
}

/* ===== 헤더 ===== */
.chat-header {
  background: var(--lj-ink);
  color: #fff;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  position: relative;
}
.chat-header .header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.chat-header .header-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.3;
}
.chat-header .header-title {
  font-weight: 600;
  font-size: 15px;
}
.status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
}
.status::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--lj-online);
  border-radius: 50%;
  margin-right: 6px;
}
.chat-header .header-close {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.chat-header .header-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* ===== 채팅 영역 ===== */
.chat-body {
  flex: 1;
  padding: 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  background: var(--lj-porcelain);
}

/* ===== 말풍선 공통 ===== */
.message-row {
  display: flex;
  align-items: flex-end;
  margin-bottom: 12px;
  animation: fadeIn 0.25s ease-in-out;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--lj-ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 8px;
  flex-shrink: 0;
}

.bubble {
  max-width: 76%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  letter-spacing: -0.01em;
}

.bot-bubble {
  background: var(--lj-bot-bg);
  color: var(--lj-ink);
  border: 1px solid var(--lj-line);
  border-top-left-radius: 4px;
}

.user-row {
  justify-content: flex-end;
}

.user-bubble {
  background: var(--lj-accent);
  color: #fff;
  border-top-right-radius: 4px;
}

/* ===== 타이핑 인디케이터 ===== */
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 2px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lj-ink-soft);
  opacity: 0.5;
  animation: typingBlink 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes typingBlink {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* ===== 입력창 ===== */
.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--lj-line);
  background: #fff;
}

.chat-input input {
  flex: 1;
  border: 1px solid var(--lj-line);
  background: var(--lj-porcelain);
  padding: 11px 16px;
  font-size: 14px;
  border-radius: 22px;
  outline: none;
  color: var(--lj-ink);
  transition: 0.2s;
}
.chat-input input::placeholder {
  color: #9aa3b2;
}

.chat-input input:focus {
  border-color: var(--lj-accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(47, 111, 143, 0.12);
}

.chat-input button {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--lj-accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.chat-input button:hover {
  background: var(--lj-accent-dark);
}
.chat-input button svg {
  width: 17px;
  height: 17px;
  transform: translateX(-1px);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== 등장 애니메이션 ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 챗봇 컨테이너 (모바일 대응) */
@media (max-width: 480px) {
  .chat-container {
    left: 0 !important;
    right: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100dvh !important; /* 모바일 전체 화면 */
    border-radius: 0 !important;
    z-index: 1000000 !important;
  }

  /* 모바일에서 버튼 위치를 살짝 더 올리고 싶다면 여기서 조정 */
  .chat-toggle-btn {
    bottom: 24px;
    left: 15px;
    right: auto;
  }
}
