/* Chat Widget - Customer Floating Chat */
.chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.chat-toggle:hover { transform: scale(1.08); }
.chat-toggle svg { width: 26px; height: 26px; fill: #fff; }
.chat-toggle .chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e53935;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}
.chat-toggle .chat-badge.show { display: flex; }

/* 말풍선 툴팁 */
.chat-bubble {
  position: fixed;
  bottom: 92px;
  right: 28px;
  background: #fff;
  color: #111;
  padding: 12px 18px;
  border-radius: 12px;
  border-bottom-right-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Outfit', -apple-system, sans-serif;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  z-index: 10000;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
  cursor: pointer;
}
.chat-bubble.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  animation: bubbleBounce 2s ease-in-out infinite;
}
@keyframes bubbleBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.02); }
}
.chat-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 2px 2px 4px rgba(0,0,0,0.05);
}

/* 버튼 펄스 애니메이션 */
@keyframes chatPulse {
  0% { box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 0 0 rgba(17,17,17,0.4); }
  70% { box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 0 12px rgba(17,17,17,0); }
  100% { box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 0 0 0 rgba(17,17,17,0); }
}
.chat-toggle.pulse {
  animation: chatPulse 2s ease-in-out infinite;
}

/* Chat Window */
.chat-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 720px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Outfit', -apple-system, sans-serif;
}
.chat-window.open { display: flex; }

/* Header */
.chat-header {
  background: #111;
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-header-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-header-title .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
}
.chat-header-title .dot.offline {
  background: #e53935;
}
.chat-header-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  padding: 0;
  line-height: 1;
  opacity: 0.7;
}
.chat-header-close:hover { opacity: 1; }

/* Intro (before chat starts) */
.chat-intro {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 32px 24px;
  text-align: center;
  overflow-y: auto;
}
.chat-intro h3 {
  font-size: 22px;
  font-weight: 700;
  color: #111;
  margin-bottom: 10px;
}
.chat-intro p {
  font-size: 15px;
  color: #888;
  margin-bottom: 28px;
  line-height: 1.6;
}
.chat-intro input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 15px;
  margin-bottom: 14px;
  outline: none;
  font-family: inherit;
}
.chat-intro input:focus { border-color: #111; }
.chat-intro button {
  width: 100%;
  padding: 14px;
  background: #111;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.chat-intro button:hover { background: #333; }
.chat-hours {
  background: #f5f5f5;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  width: 100%;
  text-align: left;
}
.chat-hours-title {
  font-size: 14px;
  font-weight: 700;
  color: #111;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-hours-status {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.chat-hours-status.online { background: #4caf50; }
.chat-hours-status.offline { background: #ccc; }
.chat-hours-line {
  font-size: 14px;
  color: #888;
  line-height: 1.7;
}
.chat-hours-now {
  font-size: 14px;
  font-weight: 600;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  text-align: center;
}
.chat-hours-now.online { background: #e8f5e9; color: #2e7d32; }
.chat-hours-now.offline { background: #fce4ec; color: #c62828; }

/* 운영시간 외 Contact 유도 */
.chat-offline-guide {
  width: 100%;
  text-align: center;
  margin-bottom: 16px;
}
.chat-offline-guide p {
  font-size: 14px;
  color: #888;
  line-height: 1.6;
  margin-bottom: 14px;
}
.chat-contact-btn {
  width: 100%;
  padding: 13px;
  background: #fff;
  color: #111;
  border: 2px solid #111;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
}
.chat-contact-btn:hover {
  background: #111;
  color: #fff;
}
.chat-offline-divider {
  display: flex;
  align-items: center;
  margin-top: 16px;
  margin-bottom: 4px;
}
.chat-offline-divider::before,
.chat-offline-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #ddd;
}
.chat-offline-divider span {
  padding: 0 10px;
  font-size: 11px;
  color: #aaa;
  white-space: nowrap;
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: none;
  flex-direction: column;
  gap: 8px;
  background: #f9f9f9;
}
.chat-messages.active { display: flex; }
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-msg.admin {
  align-self: flex-start;
  background: #fff;
  color: #111;
  border: 1px solid #eee;
  border-bottom-left-radius: 4px;
}
.chat-msg.visitor {
  align-self: flex-end;
  background: #111;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-time {
  font-size: 10px;
  color: #aaa;
  margin-top: 2px;
}
.chat-msg.visitor .chat-msg-time { text-align: right; color: rgba(255,255,255,0.5); }

.chat-date-sep {
  text-align: center;
  font-size: 11px;
  color: #aaa;
  padding: 8px 0;
}

/* Input Area */
.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  display: none;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
  flex-shrink: 0;
}
.chat-input-area.active { display: flex; }
.chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 80px;
  min-height: 38px;
  line-height: 1.4;
}
.chat-input:focus { border-color: #111; }
.chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #111;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-send:hover { background: #333; }
.chat-send svg { width: 18px; height: 18px; fill: #fff; }
.chat-send:disabled { background: #ccc; cursor: default; }

.chat-closed-notice {
  text-align: center;
  padding: 16px;
  font-size: 13px;
  color: #888;
  display: none;
}

/* Mobile */
@media (max-width: 480px) {
  .chat-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .chat-toggle { bottom: 16px; right: 16px; }
  .chat-bubble { bottom: 80px; right: 16px; }
}
