/* ============================================================
   MS HEAL - AI Chat Widget Styles
   ============================================================ */

/* --- Chat Toggle Button --- */
.chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 96px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF6B54 0%, #ff8a70 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255, 107, 84, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.2s, box-shadow 0.2s;
}

.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(255, 107, 84, 0.5);
}

.chat-toggle svg {
  width: 28px;
  height: 28px;
  color: #fff;
  transition: transform 0.3s;
}

.chat-toggle.active svg.icon-chat { display: none; }
.chat-toggle:not(.active) svg.icon-close { display: none; }
.chat-toggle.active svg.icon-close { display: block; }

/* Unread badge */
.chat-toggle .unread-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  opacity: 0;
  transform: scale(0);
  transition: all 0.2s;
}

.chat-toggle .unread-badge.show {
  opacity: 1;
  transform: scale(1);
}

/* --- Chat Window --- */
.chat-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* --- Expanded Mode --- */
.chat-window.expanded {
  width: 680px;
  height: 80vh;
  max-height: 80vh;
  bottom: 10vh;
  right: calc(50% - 340px);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.chat-window.expanded .chat-msg-bubble {
  font-size: 15px;
}

.chat-window.expanded .chat-input {
  font-size: 15px;
  padding: 12px 18px;
}

.chat-window.expanded .chat-messages {
  padding: 20px 24px;
}

/* --- Chat Header --- */
.chat-header {
  background: linear-gradient(135deg, #FF6B54 0%, #ff8a70 100%);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-name {
  font-weight: 700;
  font-size: 14px;
}

.chat-header-status {
  font-size: 11px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}

/* --- Header Buttons (expand, close) --- */
.chat-header-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-header-btn:hover {
  background: rgba(255,255,255,0.2);
}

.chat-header-btn svg {
  width: 18px;
  height: 18px;
}

/* --- Language Selector --- */
.chat-lang-selector {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  margin-right: 4px;
}

.chat-lang-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.15);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.chat-lang-btn:hover {
  background: rgba(255,255,255,0.3);
}

.chat-lang-btn.active {
  border-color: #fff;
  background: rgba(255,255,255,0.3);
}

/* --- Chat Messages --- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fa;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

/* Message bubbles */
.chat-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: msgIn 0.3s ease-out;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg.bot {
  align-self: flex-start;
}

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

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF6B54, #ff8a70);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-msg.user .chat-msg-avatar {
  background: #e5e7eb;
  color: #6b7280;
}

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-msg.bot .chat-msg-bubble {
  background: #fff;
  color: #1f2937;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.chat-msg.user .chat-msg-bubble {
  background: linear-gradient(135deg, #FF6B54, #ff8a70);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 8px;
  align-self: flex-start;
  max-width: 85%;
}

.chat-typing .chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF6B54, #ff8a70);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.typing-dots {
  background: #fff;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* --- Quick Actions --- */
.chat-quick-actions {
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #f8f9fa;
  border-top: 1px solid #f1f3f5;
}

.chat-quick-btn {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.chat-quick-btn:hover {
  border-color: #FF6B54;
  color: #FF6B54;
  background: #fff5f3;
}

/* --- Chat Input --- */
.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  min-height: 40px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: #FF6B54;
}

.chat-input::placeholder {
  color: #9ca3af;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF6B54, #ff8a70);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, opacity 0.2s;
}

.chat-send-btn:hover {
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chat-send-btn svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

/* --- Language Switch Notice --- */
.chat-lang-notice {
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  padding: 6px 0;
  font-weight: 600;
}

/* --- End Chat Button --- */
.chat-end-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.chat-end-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

.chat-end-btn svg {
  width: 16px;
  height: 16px;
  color: #6b7280;
}

.chat-end-btn:hover svg {
  color: #ef4444;
}

/* --- End Chat Card --- */
.chat-end-card {
  background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.chat-end-card h4 {
  color: #374151;
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 8px 0;
}

.chat-end-card p {
  color: #6b7280;
  font-size: 13px;
  margin: 0 0 12px 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat-new-btn {
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid #FF6B54;
  background: #fff;
  color: #FF6B54;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-new-btn:hover {
  background: #FF6B54;
  color: #fff;
}

/* --- Booking Confirm Card (예/아니오) --- */
.chat-booking-confirm {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #93c5fd;
  border-radius: 12px;
  padding: 16px;
}

.chat-booking-confirm h4 {
  color: #1e40af;
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px 0;
}

.booking-confirm-details {
  background: rgba(255,255,255,0.6);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.booking-confirm-details p {
  color: #1e3a5f;
  font-size: 13px;
  margin: 3px 0;
  line-height: 1.5;
}

.booking-confirm-actions {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.booking-yes-btn, .booking-no-btn {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
}

.booking-yes-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}

.booking-yes-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.booking-no-btn {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

.booking-no-btn:hover:not(:disabled) {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
}

/* --- Booking Complete Card (예약번호 + PIN) --- */
.chat-booking-complete {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 16px;
}

.chat-booking-complete h4 {
  color: #065f46;
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px 0;
}

.booking-credential {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.booking-credential-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.credential-label {
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
}

.credential-value {
  color: #065f46;
  font-size: 16px;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
}

.booking-copy-btn {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #a7f3d0;
  background: #f0fdf4;
  color: #065f46;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}

.booking-copy-btn:hover {
  background: #dcfce7;
  border-color: #86efac;
}

.booking-copy-btn.copied {
  background: #065f46;
  color: #fff;
  border-color: #065f46;
}

.booking-save-notice {
  color: #b45309;
  font-size: 12px;
  margin: 0 0 10px 0;
  font-weight: 600;
}

.booking-check-btn {
  display: block;
  text-align: center;
  padding: 10px 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, #FF6B54, #ff8a70);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s;
}

.booking-check-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 107, 84, 0.4);
}

/* --- Powered By --- */
.chat-powered {
  text-align: center;
  padding: 6px;
  font-size: 11px;
  color: #9ca3af;
  background: #fff;
  border-top: 1px solid #f3f4f6;
  flex-shrink: 0;
}

/* --- Mobile Responsive --- */
@media (max-width: 480px) {
  .chat-window {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .chat-window.expanded {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  .chat-toggle {
    bottom: 20px;
    right: 76px;
    width: 52px;
    height: 52px;
  }

  .chat-toggle svg {
    width: 24px;
    height: 24px;
  }

  .chat-lang-btn {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
}
