/* ============================================================
   Netsystems 챗봇 위젯 스타일
   ============================================================ */

/* ── 진입 버튼 ── */
.chat-fab {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 9000;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c3bff 0%, #2563eb 60%, #06b6d4 100%);
  box-shadow: 0 8px 32px rgba(108,59,255,0.45);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1),
              box-shadow 0.3s ease,
              opacity 0.3s ease;
}
.chat-fab:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 14px 40px rgba(108,59,255,0.6);
}
.chat-fab.open { transform: rotate(45deg) scale(0.9); }

.chat-fab-icon {
  font-size: 1.5rem;
  transition: transform 0.3s ease;
  line-height: 1;
}
.chat-fab.open .chat-fab-icon { content: '✕'; font-size: 1.3rem; }

.chat-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid white;
  font-size: 0.6rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: badge-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chat-fab-badge.hidden { display: none; }

@keyframes badge-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ── 풍선 말풍선 (처음 방문자용) ── */
.chat-tooltip {
  position: fixed;
  bottom: 106px;
  right: 32px;
  z-index: 8999;
  background: white;
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 8px 30px rgba(10,14,46,0.15);
  max-width: 220px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #0f172a;
  font-weight: 500;
  animation: tooltip-in 0.4s cubic-bezier(0.4,0,0.2,1) both;
  cursor: pointer;
}
.chat-tooltip::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 24px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 9px solid white;
}
.chat-tooltip.hide {
  animation: tooltip-out 0.3s ease forwards;
}
.chat-tooltip-close {
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 0.75rem;
  color: #94a3b8;
  cursor: pointer;
  background: none;
  border: none;
  padding: 2px 4px;
}

@keyframes tooltip-in {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes tooltip-out {
  to { opacity: 0; transform: translateY(10px) scale(0.95); pointer-events: none; }
}

/* ── 챗봇 패널 ── */
.chat-panel {
  position: fixed;
  bottom: 110px;
  right: 32px;
  z-index: 8998;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 130px);
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 24px 80px rgba(10,14,46,0.2), 0 4px 20px rgba(108,59,255,0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1),
              opacity 0.35s ease;
}
.chat-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── 패널 헤더 ── */
.chat-header {
  background: linear-gradient(135deg, #0a0e2e 0%, #1a2160 100%);
  padding: 18px 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}

.chat-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c3bff, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  position: relative;
}
.chat-header-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #0a0e2e;
}

.chat-header-info { flex: 1; }
.chat-header-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}
.chat-header-status {
  font-size: 0.73rem;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}
.chat-header-status span {
  color: #22c55e;
  font-weight: 600;
}

.chat-header-actions { display: flex; gap: 4px; }
.chat-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.6);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.chat-header-btn:hover { background: rgba(255,255,255,0.16); color: white; }

/* ── 메시지 영역 ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f8faff;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 2px; }

/* ── 날짜 구분선 ── */
.chat-date-divider {
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
  position: relative;
}
.chat-date-divider::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 1px;
  background: #e2e8f0;
  z-index: 0;
}
.chat-date-divider span {
  background: #f8faff;
  position: relative;
  z-index: 1;
  padding: 0 10px;
}

/* ── 메시지 버블 ── */
.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msg-in 0.3s cubic-bezier(0.4,0,0.2,1) both;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c3bff, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.chat-msg.user .msg-avatar { background: linear-gradient(135deg, #e2e8f0, #cbd5e1); }

.msg-body { max-width: 78%; display: flex; flex-direction: column; gap: 4px; }
.chat-msg.user .msg-body { align-items: flex-end; }

.msg-bubble {
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 0.875rem;
  line-height: 1.65;
  word-break: break-word;
}

.chat-msg.bot .msg-bubble {
  background: white;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(10,14,46,0.06);
  border: 1px solid #f1f5f9;
}

.chat-msg.user .msg-bubble {
  background: linear-gradient(135deg, #6c3bff, #2563eb);
  color: white;
  border-bottom-right-radius: 4px;
}

.msg-time {
  font-size: 0.68rem;
  color: #94a3b8;
  padding: 0 4px;
}

/* ── 빠른 답변 버튼 ── */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 2px;
}
.quick-reply-btn {
  background: white;
  border: 1.5px solid #e2e8f0;
  border-radius: 50px;
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #6c3bff;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.quick-reply-btn:hover {
  background: #6c3bff;
  border-color: #6c3bff;
  color: white;
  transform: translateY(-1px);
}

/* ── 타이핑 인디케이터 ── */
.chat-typing {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.typing-bubble {
  background: white;
  border: 1px solid #f1f5f9;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 14px 18px;
  box-shadow: 0 2px 8px rgba(10,14,46,0.06);
  display: flex;
  gap: 5px;
  align-items: center;
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6c3bff;
  animation: typing 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── 상담 연결 카드 ── */
.chat-consult-card {
  background: linear-gradient(135deg, rgba(108,59,255,0.06), rgba(37,99,235,0.04));
  border: 1.5px solid rgba(108,59,255,0.15);
  border-radius: 14px;
  padding: 16px;
  margin-top: 4px;
}
.consult-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #6c3bff;
  margin-bottom: 10px;
}
.consult-card-btn {
  width: 100%;
  padding: 11px;
  background: linear-gradient(135deg, #6c3bff, #2563eb);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 6px;
}
.consult-card-btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* ── 입력창 ── */
.chat-input-area {
  padding: 14px 16px 16px;
  background: white;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: #f8faff;
  border: 1.5px solid #e8edf8;
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 0.875rem;
  font-family: inherit;
  color: #0f172a;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 44px;
  line-height: 1.5;
  transition: border-color 0.2s ease, background 0.2s ease;
  overflow-y: auto;
}
.chat-input:focus {
  border-color: #6c3bff;
  background: white;
}
.chat-input::placeholder { color: #94a3b8; }

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6c3bff, #2563eb);
  border: none;
  cursor: pointer;
  color: white;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(108,59,255,0.3);
}
.chat-send-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(108,59,255,0.45); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.chat-input-hint {
  font-size: 0.68rem;
  color: #94a3b8;
  text-align: center;
  margin-top: 8px;
}

/* ── 리셋 확인 모달 ── */
.chat-reset-confirm {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
  border-radius: 24px;
  padding: 32px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.chat-reset-confirm.show { opacity: 1; pointer-events: all; }
.reset-title { font-size: 1rem; font-weight: 700; color: #0f172a; }
.reset-desc { font-size: 0.85rem; color: #64748b; }
.reset-btns { display: flex; gap: 10px; }
.reset-cancel-btn {
  padding: 10px 24px;
  border-radius: 10px;
  background: #f1f5f9;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: #64748b;
}
.reset-ok-btn {
  padding: 10px 24px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6c3bff, #2563eb);
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: white;
}

/* ── 에러 메시지 ── */
.chat-error-msg .msg-bubble {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

/* ── 모바일 ── */
@media (max-width: 480px) {
  .chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
  .chat-fab { bottom: 20px; right: 20px; }
  .chat-tooltip { bottom: 94px; right: 20px; }
}
