/* 플로팅 채팅 위젯 - 오른쪽 하단 */
.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
}

.chat-widget-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2c5aa0 0%, #1e3a6b 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(44, 90, 160, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chat-widget-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(44, 90, 160, 0.5);
}
.chat-widget-btn svg {
  width: 26px;
  height: 26px;
}

.chat-widget-btn.has-unread::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  background: #e53e3e;
  border-radius: 50%;
  border: 2px solid #fff;
}

.chat-widget-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 480px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.chat-widget-panel.open {
  display: flex;
}

.chat-widget-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, #2c5aa0 0%, #1e3a6b 100%);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-widget-header .chat-widget-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-widget-header .chat-widget-close:hover {
  background: rgba(255,255,255,0.3);
}

.chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 200px;
  -webkit-overflow-scrolling: touch;
}

.chat-widget-msg {
  display: flex;
  margin-bottom: 12px;
  max-width: 85%;
}
.chat-widget-msg.self {
  justify-content: flex-end;
  margin-left: auto;
}
.chat-widget-msg.other {
  justify-content: flex-start;
  margin-right: auto;
}
.chat-widget-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
}
.chat-widget-msg.self .chat-widget-msg-bubble {
  background: #2c5aa0;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-widget-msg.other .chat-widget-msg-bubble {
  background: #e8e8e8;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}
.chat-widget-msg-time {
  font-size: 0.7rem;
  color: #9e9e9e;
  margin-top: 4px;
}
.chat-widget-msg.self .chat-widget-msg-time {
  text-align: right;
}

.chat-widget-input-wrap {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #eee;
}
.chat-widget-input-wrap .input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-widget-input-wrap textarea {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  font-size: 0.95rem;
  resize: none;
  min-height: 44px;
  max-height: 100px;
  font-family: inherit;
}
.chat-widget-input-wrap textarea:focus {
  outline: none;
  border-color: #2c5aa0;
}
.chat-widget-send-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #2c5aa0;
  color: #fff;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-widget-send-btn:hover {
  background: #1e3a6b;
}
.chat-widget-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.chat-widget-send-btn svg {
  width: 22px;
  height: 22px;
}
.chat-widget-char-count {
  font-size: 0.75rem;
  color: #9e9e9e;
  margin-top: 4px;
  text-align: right;
}

.chat-widget-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.chat-widget-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e0e0e0;
  border-top-color: #2c5aa0;
  border-radius: 50%;
  animation: chat-widget-spin 0.7s linear infinite;
}
@keyframes chat-widget-spin {
  to { transform: rotate(360deg); }
}

.chat-widget-empty {
  text-align: center;
  color: #999;
  padding: 40px 16px;
}
.chat-widget-empty p {
  margin: 0;
  font-size: 0.9rem;
}

/* delivery 전용: 빨간 테마 */
.chat-widget.delivery-theme .chat-widget-btn,
.chat-widget.delivery-theme .chat-widget-header {
  background: linear-gradient(135deg, #C62828 0%, #8B0000 100%);
}
.chat-widget.delivery-theme .chat-widget-btn {
  box-shadow: 0 4px 16px rgba(198, 40, 40, 0.4);
}
.chat-widget.delivery-theme .chat-widget-msg.self .chat-widget-msg-bubble,
.chat-widget.delivery-theme .chat-widget-send-btn {
  background: #C62828;
}
.chat-widget.delivery-theme .chat-widget-send-btn:hover {
  background: #8B0000;
}
.chat-widget.delivery-theme .chat-widget-loading .spinner {
  border-top-color: #C62828;
}
