/* ═══════════════════════════════════════
   강남교회 예약 챗봇
═══════════════════════════════════════ */

.chatbot-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, sans-serif;
}

/* ─── 플로팅 버튼 ─── */
.chatbot-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(160deg, #6b66ff 0%, #5e5cff 55%, #5248e8 100%);
  border: none;
  cursor: pointer;
  box-shadow:
    0 6px 22px rgba(94, 92, 255, 0.38),
    0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chatbot-btn:hover {
  transform: scale(1.05);
  box-shadow:
    0 8px 28px rgba(94, 92, 255, 0.45),
    0 3px 10px rgba(0, 0, 0, 0.1);
}
.chatbot-btn:active { transform: scale(0.96); }

/* ─── 음파 ripple ─── */
.cb-ripple {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border-radius: 50%;
  background: rgba(94, 92, 255, 0.32);
  animation: cb-ripple-anim 2.6s ease-out infinite;
  pointer-events: none;
  z-index: 0;
}
.cb-ripple-2 { animation-delay: 1.3s; }

@keyframes cb-ripple-anim {
  0%   { transform: scale(1);    opacity: 0.55; }
  70%  { transform: scale(2.05); opacity: 0;    }
  100% { transform: scale(2.05); opacity: 0;    }
}

/* 채팅창 열린 동안 ripple 정지 */
.chatbot-btn.open .cb-ripple { animation-play-state: paused; opacity: 0; }

.chatbot-btn .cb-fab-icon {
  width: 28px;
  height: 28px;
  position: relative;
  z-index: 1;
  display: block;
  pointer-events: none;
  flex-shrink: 0;
}

/* ─── 채팅창 ─── */
.chatbot-window {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 360px;
  height: 540px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.82) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.34,1.5,0.64,1), opacity 0.2s ease;
}
.chatbot-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ─── 헤더 ─── */
.chatbot-header {
  background: linear-gradient(135deg, #1a3a6b 0%, #2d5a9e 100%);
  cursor: move;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.cb-hd-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  overflow: hidden;
  padding: 2px;
}
.cb-hd-info  { flex: 1; overflow: hidden; }
.cb-hd-title { font-size: 13.5px; font-weight: 700; color: #fff; }
.cb-hd-sub   { font-size: 11px; color: rgba(255,255,255,0.62); margin-top: 1px; }
.cb-hd-dot   {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74,222,128,0.25);
  flex-shrink: 0;
}
.chatbot-close {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,0.12); border: none;
  color: rgba(255,255,255,0.85); font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; flex-shrink: 0; line-height: 1;
}
.chatbot-close:hover { background: rgba(255,255,255,0.22); }

/* ─── 메시지 영역 ─── */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.chatbot-messages::-webkit-scrollbar { width: 3px; }
.chatbot-messages::-webkit-scrollbar-thumb { background: #dde3ee; border-radius: 4px; }

/* ─── 메시지 버블 ─── */
.cb-msg {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  max-width: 87%;
  animation: cbMsgIn 0.2s ease-out;
}
@keyframes cbMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}
.cb-msg.bot  { align-self: flex-start; }
.cb-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.cb-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff;
  border: 1.5px solid #e0e7f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
  overflow: hidden;
  padding: 1px;
}

.cb-bubble {
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.65;
  word-break: break-word;
}
.cb-msg.bot  .cb-bubble { background: #f0f4fb; color: #1a1a1a; border-bottom-left-radius: 4px; }
.cb-msg.user .cb-bubble { background: linear-gradient(135deg, #1a3a6b, #2d5a9e); color: #fff; border-bottom-right-radius: 4px; }

.cb-bubble strong { font-weight: 700; }
.cb-bubble em     { font-style: normal; color: #c8a951; font-weight: 600; }
.cb-bubble code   { font-size: 11.5px; background: rgba(0,0,0,0.07); padding: 1px 5px; border-radius: 4px; font-family: monospace; }
.cb-bubble .cb-terms {
  margin-top: 8px;
  background: #fffbeb;
  border: 1px solid #f0d890;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  color: #5a4a00;
  white-space: pre-line;
  line-height: 1.7;
}

/* ─── 타이핑 인디케이터 ─── */
.cb-typing {
  display: flex; align-items: flex-end; gap: 7px;
  align-self: flex-start;
  animation: cbMsgIn 0.2s ease-out;
}
.cb-typing .cb-bubble {
  padding: 12px 16px; display: flex; gap: 5px; align-items: center;
  background: #f0f4fb; border-bottom-left-radius: 4px;
}
.cb-dot {
  width: 7px; height: 7px;
  background: #9aa4bc; border-radius: 50%;
  animation: cbDot 1.3s ease-in-out infinite;
}
.cb-dot:nth-child(2) { animation-delay: 0.18s; }
.cb-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes cbDot {
  0%,60%,100% { transform: translateY(0);    opacity: 0.55; }
  30%          { transform: translateY(-5px); opacity: 1;    }
}

/* ─── 퀵 리플라이 ─── */
.cb-quick-wrap {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-left: 35px; margin-top: -2px;
  animation: cbMsgIn 0.25s ease-out;
}
.cb-quick-btn {
  background: #fff;
  border: 1.5px solid #1a3a6b;
  color: #1a3a6b;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: all 0.15s; white-space: nowrap;
}
.cb-quick-btn:hover { background: #1a3a6b; color: #fff; }
.cb-quick-btn:disabled { opacity: 0.45; cursor: default; pointer-events: none; }

/* ─── 입력 영역 ─── */
.chatbot-footer {
  border-top: 1px solid #eaecf3;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
.chatbot-input {
  flex: 1;
  border: 1.5px solid #e2e6f0;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px; font-family: inherit;
  resize: none; outline: none;
  max-height: 80px; line-height: 1.45;
  color: #1a1a1a;
  background: #fafbfd;
  transition: border-color 0.15s;
}
.chatbot-input:focus   { border-color: #1a3a6b; background: #fff; }
.chatbot-input::placeholder { color: #b0b8cc; }

.chatbot-send {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #1a3a6b, #2d5a9e);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}
.chatbot-send:hover    { transform: scale(1.08); }
.chatbot-send:active   { transform: scale(0.93); }
.chatbot-send:disabled { opacity: 0.4; cursor: default; transform: none; }
.chatbot-send svg { width: 16px; height: 16px; fill: #fff; }

/* ─── 모바일 ─── */
@media (max-width: 500px) {
  .chatbot-wrapper { bottom: 16px; right: 16px; }
  .chatbot-window {
    width: calc(100vw - 24px);
    height: calc(100dvh - 100px);
    right: -8px;
    bottom: 74px;
  }
}
