/* web/chatbot-widget.css */
#msw-chatbot-widget {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: calc(24px + env(safe-area-inset-right));
  z-index: 9999;
  max-width: calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right));
  font-family: 'Pretendard', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#msw-chat-window {
  display: none;
  width: 400px;
  height: 640px;
  max-height: 80vh;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.1);
  margin-bottom: 16px;
  transform-origin: bottom right;
  opacity: 0;
  transform: scale(0.9) translateY(20px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#msw-chat-window.is-open {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.msw-chat-header {
  background: linear-gradient(135deg, var(--primary, #2563EB), #3B82F6);
  color: #fff;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.msw-chat-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.msw-chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msw-chat-reset {
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  white-space: nowrap;
}

.msw-chat-reset:hover {
  background: rgba(255, 255, 255, 0.28);
}

.msw-chat-logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.msw-chat-title {
  font-weight: 900;
  font-size: 15px;
  letter-spacing: -0.2px;
}

.msw-chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.9;
}

.msw-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22C55E;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}

.msw-chat-close {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msw-chat-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.msw-chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #F8FAFC;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msw-message-wrapper {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: msw-fade-up 0.3s ease forwards;
}

.msw-message-wrapper.bot {
  align-self: flex-start;
}

.msw-message-wrapper.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msw-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.msw-chat-bubble {
  max-width: 100%;
  font-size: 14px;
  line-height: 1.5;
  padding: 12px 16px;
  border-radius: 16px;
  white-space: pre-line;
}

.msw-chat-bubble.bot {
  background: #fff;
  color: #334155;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  border-radius: 2px 16px 16px 16px;
}

.msw-chat-bubble.user {
  background: var(--primary, #2563EB);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
  border-radius: 16px 16px 2px 16px;
}

.msw-chat-bubble.error {
  align-self: flex-start;
  background: #FEF2F2;
  color: #B91C1C;
}

.msw-chat-bubble.loading {
  align-self: flex-start;
  background: #fff;
  color: #94A3B8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  border-radius: 2px 16px 16px 16px;
  padding: 14px 18px; /* 조금 더 여유롭게 */
  display: flex;
  align-items: center;
}

.msw-chat-divider {
  text-align: center;
  font-size: 11px;
  color: #94A3B8;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.msw-faq-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.msw-faq-btn {
  border: 1px solid #E2E8F0;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.msw-faq-btn:hover {
  border-color: var(--primary, #2563EB);
  color: var(--primary, #2563EB);
}

.msw-faq-btn i {
  font-size: 12px;
  color: currentColor;
}

.msw-chat-input-wrap {
  background: #fff;
  border-top: 1px solid #E2E8F0;
  padding-bottom: env(safe-area-inset-bottom);
}

.msw-chat-input-row {
  padding: 16px 16px 6px 16px;
  display: flex;
  gap: 8px;
}

.msw-chat-input {
  flex: 1;
  border: 1px solid #E2E8F0;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.msw-chat-input:focus {
  border-color: var(--primary, #2563EB);
}

.msw-send-btn {
  width: 40px;
  height: 40px;
  background: var(--primary, #2563EB);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.msw-send-btn:hover {
  transform: translateY(-1px);
}

.msw-chat-footnote {
  text-align: center;
  padding-bottom: 14px;
  font-size: 11px;
  color: #94A3B8;
  font-weight: 700;
  letter-spacing: -0.2px;
}

#msw-chat-btn {
  width: 60px;
  height: 60px;
  background: var(--primary, #2563EB);
  border-radius: 30px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 28px;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#msw-chat-btn:hover {
  transform: translateY(-2px);
}

@keyframes msw-fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  #msw-chat-window {
    width: 92vw;
    height: 70vh;
  }
}

@media (max-width: 480px), (pointer: coarse) {
  #msw-chat-window {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100svh;
    max-height: 100svh;
    border-radius: 0;
    margin-bottom: 0;
  }

  #msw-chatbot-widget {
    right: calc(16px + env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* Typing Indicator Animation */
.msw-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 2px;
}

.msw-typing-dot {
  width: 6px;
  height: 6px;
  background-color: #3B82F6; /* 파란색으로 변경 */
  border-radius: 50%;
  animation: msw-typing-bounce 1.4s infinite ease-in-out both;
}

.msw-typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.msw-typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes msw-typing-bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}


/* Prevent fixed widget from contributing to horizontal scroll */
#msw-chatbot-widget, #msw-chat-window { max-width: 100vw; }
