/* ================================================================
 * 수잘공 상담 챗봇 위젯 스타일 ('성민쌤')
 * sungmin-korean 위젯 재사용 — 테마 색은 chat-config.js 에서 주입
 * 모든 클래스는 suzal-chat- 접두어 사용 (사이트 CSS 충돌 방지)
 * ================================================================ */

.suzal-chat-container,
.suzal-chat-container * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Malgun Gothic', 'Apple SD Gothic Neo', 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.suzal-chat-container {
  position: static;
  color: #1a1a1a;
}

/* 플로팅 버튼 */
.suzal-chat-button {
  position: fixed;
  bottom: 32px;
  right: 32px;
  left: auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--suzal-primary, #2a4d8f);
  color: white;
  border: none;
  box-shadow: 0 4px 16px rgba(42, 77, 143, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  z-index: 9999;
}
.suzal-chat-button:hover {
  background: var(--suzal-primary-hover, #1d3a70);
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(42, 77, 143, 0.45);
}
.suzal-chat-button:active { transform: scale(0.98); }
.suzal-chat-button.is-open { background: #6c6c6c; }

.suzal-chat-button__badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  background: #ef4444;
  border: 2px solid white;
  border-radius: 50%;
  animation: suzal-chat-pulse 1.5s ease-in-out infinite;
}
@keyframes suzal-chat-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
}

.suzal-chat-button__label {
  position: absolute;
  right: 72px;
  top: 50%;
  transform: translateY(-50%);
  background: white;
  color: #333;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.suzal-chat-button:hover .suzal-chat-button__label { opacity: 1; }

@media (max-width: 640px) {
  .suzal-chat-button__label { display: none; }
  .suzal-chat-button { bottom: 16px; right: 16px; }
}

/* 채팅 창 */
.suzal-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  animation: suzal-chat-slide-up 0.3s ease-out;
}
@keyframes suzal-chat-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@media (max-width: 640px) {
  .suzal-chat-window {
    top: auto;
    bottom: 84px;
    left: 10px;
    right: 10px;
    width: auto;
    height: 64vh;
    max-height: calc(100vh - 150px);
    border-radius: 16px;
  }
}

/* 헤더 */
.suzal-chat-window__header {
  background: var(--suzal-primary, #2a4d8f);
  color: white;
  padding: 16px 16px 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.suzal-chat-window__title-area { display: flex; align-items: center; gap: 12px; }
.suzal-chat-window__avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex; align-items: center; justify-content: center;
  color: white; flex-shrink: 0;
}
.suzal-chat-window__title { font-size: 16px; font-weight: 600; margin: 0; color: white; }
.suzal-chat-window__subtitle { font-size: 12px; margin: 0; color: rgba(255, 255, 255, 0.85); }
.suzal-chat-window__header-actions { display: flex; gap: 4px; position: relative; }
.suzal-chat-window__icon-button {
  width: 32px; height: 32px; border: none; background: transparent; color: white;
  border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background-color 0.2s ease;
}
.suzal-chat-window__icon-button:hover { background: rgba(255, 255, 255, 0.15); }

/* 메시지 리스트 */
.suzal-chat-messages {
  flex: 1; overflow-y: auto; padding: 16px; background: #fafafa;
  display: flex; flex-direction: column; gap: 12px;
}
.suzal-chat-messages::-webkit-scrollbar { width: 6px; }
.suzal-chat-messages::-webkit-scrollbar-track { background: transparent; }
.suzal-chat-messages::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 3px; }
.suzal-chat-messages::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }

/* 메시지 버블 */
.suzal-chat-message { display: flex; gap: 8px; align-items: flex-start; max-width: 100%; }
.suzal-chat-message--user { flex-direction: row-reverse; }
.suzal-chat-message__avatar {
  width: 32px; height: 32px; border-radius: 50%; background: white; border: 1px solid #eee;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: var(--suzal-primary, #2a4d8f);
}
.suzal-chat-message__content { display: flex; flex-direction: column; max-width: calc(100% - 48px); gap: 4px; }
.suzal-chat-message--user .suzal-chat-message__content { align-items: flex-end; }
.suzal-chat-message__sender { font-size: 11px; font-weight: 500; color: #6b6b6b; padding: 0 4px; }
.suzal-chat-message__bubble {
  padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.6;
  word-wrap: break-word; overflow-wrap: break-word; white-space: normal;
}
.suzal-chat-message__bubble--bot { background: white; color: #1a1a1a; border: 1px solid #e8e8e8; border-top-left-radius: 4px; }
.suzal-chat-message__bubble--user { background: var(--suzal-primary, #2a4d8f); color: white; border-top-right-radius: 4px; }
.suzal-chat-message__bubble--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.suzal-chat-message__bubble strong { font-weight: 600; }
.suzal-chat-message__handoff-badge {
  font-size: 12px; color: #059669; background: #ecfdf5; padding: 6px 10px; border-radius: 10px;
  font-weight: 500; margin-top: 4px; display: inline-block;
}
.suzal-chat-link { color: var(--suzal-primary, #2a4d8f); text-decoration: underline; word-break: break-all; }
.suzal-chat-message__bubble--user .suzal-chat-link { color: #fff; }

/* 타이핑 */
.suzal-chat-typing { display: flex; gap: 4px; padding: 4px 0; }
.suzal-chat-typing__dot { width: 8px; height: 8px; background: #a0a0a0; border-radius: 50%; animation: suzal-chat-typing 1.4s ease-in-out infinite; }
.suzal-chat-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.suzal-chat-typing__dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes suzal-chat-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* 빠른 질문 */
.suzal-chat-window__quick-prompts { padding: 12px 16px 0; background: #fafafa; flex-shrink: 0; }
.suzal-chat-window__quick-prompts-label { font-size: 11px; color: #6b6b6b; font-weight: 500; margin-bottom: 8px; }
.suzal-chat-window__quick-prompts-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.suzal-chat-window__quick-prompt {
  background: white; border: 1px solid #c9d6ee; color: var(--suzal-primary, #2a4d8f);
  padding: 6px 12px; border-radius: 16px; font-size: 12px; cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.suzal-chat-window__quick-prompt:hover { background: #eef3fb; border-color: var(--suzal-accent, #e0a33a); }

/* 입력 영역 */
.suzal-chat-input-area { padding: 12px 16px 16px; background: white; border-top: 1px solid #eee; flex-shrink: 0; }
.suzal-chat-input-wrapper {
  display: flex; align-items: flex-end; gap: 8px; background: #f5f5f5; border: 1px solid #e8e8e8;
  border-radius: 20px; padding: 6px 6px 6px 14px; transition: border-color 0.2s ease;
}
.suzal-chat-input-wrapper:focus-within { border-color: var(--suzal-primary, #2a4d8f); background: white; }
.suzal-chat-input {
  flex: 1; border: none; background: transparent; resize: none; font-size: 14px; line-height: 1.5;
  outline: none; padding: 6px 0; min-height: 20px; max-height: 120px; font-family: inherit; color: #1a1a1a;
}
.suzal-chat-input:disabled { color: #999; cursor: not-allowed; }
.suzal-chat-input::placeholder { color: #999; }
.suzal-chat-send-button {
  width: 32px; height: 32px; border-radius: 50%; background: var(--suzal-primary, #2a4d8f); color: white;
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background-color 0.2s ease, transform 0.1s ease;
}
.suzal-chat-send-button:hover:not(:disabled) { background: var(--suzal-primary-hover, #1d3a70); }
.suzal-chat-send-button:active:not(:disabled) { transform: scale(0.95); }
.suzal-chat-send-button:disabled { background: #d0d0d0; cursor: not-allowed; }
.suzal-chat-input-footer { font-size: 10px; color: #aaa; text-align: center; margin-top: 8px; }
