* {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  box-sizing: border-box;
}

body {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  min-height: 100dvh; /* 动态视口高度 */
  height: 100vh;
  height: 100dvh; /* 动态视口高度 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.chat-container {
  width: 100%;
  height: 100vh;
  height: 100dvh; /* 动态视口高度 */
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  overflow: hidden;
  border: none;
  position: relative;
}

.chat-header {
  padding: 16px 20px 12px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-container {
  flex-shrink: 0;
  position: relative;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: #6366f1;
  filter: drop-shadow(0 2px 4px rgba(99, 102, 241, 0.2));
}

.online-indicator {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #10b981;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.title-container {
  flex: 1;
  text-align: left;
}

.chat-title {
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-title img {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
      background: linear-gradient(
      135deg,
      rgba(193, 193, 193, 0.85) 0%,
      rgba(255, 255, 255, 0.85) 100%
    ),
    url("bg.jpg");
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  min-height: 0; /* 重要：允许flex子项收缩 */
}

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

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

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

.bot-message-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 85%;
  margin: 12px 0;
}

.bot-message-gif {
  max-width: 200px;
  max-height: 150px;
  width: auto;
  height: auto;
  border-radius: 12px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  animation: fadeInUp 0.3s ease-out;
  object-fit: cover;
}

.bot-message,
.user-message {
  padding: 16px 20px;
  margin: 0; /* Remove margin since container handles spacing */
  border-radius: 20px;
  line-height: 1.6;
  font-size: 15px;
  font-weight: 400;
  animation: fadeInUp 0.3s ease-out;
  word-wrap: break-word;
  max-width: 100%; /* Use full container width */
}

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

.bot-message {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  align-self: flex-start;
  border-bottom-left-radius: 8px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.user-message {
  background: #0084ff;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 8px;
  border: none;
  width: auto;
  max-width: 85%;
  display: inline-block;
}

.options-container {
  padding: 16px 20px 20px;
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  display: none; /* Hide the bottom options container */
}

.bottom-action-container {
  padding: 16px 20px;
  padding-bottom: max(env(safe-area-inset-bottom), 20px);
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.apply-now-button {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, #25d366 0%, #25d366 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.apply-now-button:hover {
  background: linear-gradient(135deg, #128c7e 0%, #075e54 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
}

.apply-now-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.whatsapp-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

.inline-options-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  padding: 0;
  align-self: flex-start;
  max-width: 85%;
}

.inline-option-button {
  padding: 10px 16px;
  background: transparent;
  color: #0084ff;
  border: 1px solid #0084ff;
  border-radius: 18px;
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: fit-content;
  box-shadow: none;
  line-height: 1.3;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.inline-option-button:hover {
  background: rgba(0, 132, 255, 0.1);
  color: #0084ff;
  transform: none;
  box-shadow: none;
}

.inline-option-button:active {
  background: rgba(0, 132, 255, 0.2);
  transform: scale(0.98);
}

.whatsapp-option-button {
  background: transparent;
  color: #0084ff;
  border: 1px solid #0084ff;
  font-weight: 600;
  box-shadow: none;
}

.whatsapp-option-button:hover {
  background: rgba(0, 132, 255, 0.1);
  color: #0084ff;
  transform: none;
  box-shadow: none;
}

.whatsapp-option-button:active {
  background: rgba(0, 132, 255, 0.2);
  transform: scale(0.98);
}

.landing-page-option-button {
  background: transparent;
  color: #10b981;
  border: 1px solid #10b981;
  font-weight: 600;
  box-shadow: none;
}

.landing-page-option-button:hover {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  transform: none;
  box-shadow: none;
}

.landing-page-option-button:active {
  background: rgba(16, 185, 129, 0.2);
  transform: scale(0.98);
}

.typing-indicator {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  margin: 12px 0;
  max-width: 85%;
  background: #f1f5f9;
  border-radius: 20px;
  border-bottom-left-radius: 8px;
  align-self: flex-start;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}
.typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing {
  0%,
  80%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 桌面端样式 */
@media (min-width: 769px) {
  body {
    padding: 20px;
  }

  .chat-container {
    width: 100%;
    max-width: 420px;
    height: 85vh;
    height: 85dvh;
    max-height: 700px;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
  }

  .chat-header {
    padding: 20px 24px 16px;
  }

  .chat-messages {
    padding: 24px;
  }

  .options-container {
    padding: 20px 24px 24px;
  }
}

/* 移动端样式 */
@media (max-width: 768px) {
  body {
    padding: 0;
    overflow: hidden;
  }

  .chat-container {
    height: 100vh;
    height: 100dvh; /* 动态视口高度 */
    border-radius: 0;
    box-shadow: none;
    border: none;
  }

  .chat-header {
    padding: env(safe-area-inset-top, 16px) 16px 12px;
    padding-top: max(env(safe-area-inset-top), 16px);
  }

  .logo-icon {
    width: 28px;
    height: 28px;
  }

  .online-indicator {
    width: 10px;
    height: 10px;
    bottom: -1px;
    right: -1px;
    border-width: 1.5px;
  }

  .chat-title {
    font-size: 16px;
  }

  .chat-messages {
    padding: 16px;
    flex: 1;
    min-height: 0;
  }

  .options-container {
    display: none; /* Keep hidden on mobile */
  }

  .bottom-action-container {
    padding: 12px 16px;
    padding-bottom: max(env(safe-area-inset-bottom), 16px);
  }

  .apply-now-button {
    padding: 14px 20px;
    font-size: 15px;
    border-radius: 10px;
    gap: 8px;
  }

  .whatsapp-icon {
    width: 18px;
    height: 18px;
  }

  .inline-options-container {
    gap: 6px;
    margin: 10px 0;
  }

  .inline-option-button {
    padding: 8px 14px;
    font-size: 12px;
    border-radius: 16px;
  }

  .bot-message,
  .user-message {
    padding: 12px 16px;
    margin: 8px 0;
    font-size: 13px;
  }

  .bot-message-container {
    margin: 8px 0;
  }

  .bot-message-gif {
    max-width: 140px;
    max-height: 100px;
    border-radius: 8px;
    margin-bottom: 4px;
  }
}

/* 针对iOS Safari的特殊处理 */
@supports (-webkit-touch-callout: none) {
  .chat-container {
    height: -webkit-fill-available;
  }
}

/* 针对非常小的屏幕 */
@media (max-height: 600px) {
  .chat-header {
    padding: 12px 16px 8px;
  }

  .logo-icon {
    width: 24px;
    height: 24px;
  }

  .online-indicator {
    width: 8px;
    height: 8px;
    bottom: 0;
    right: 0;
    border-width: 1px;
  }

  .chat-title {
    font-size: 14px;
  }

  .chat-messages {
    padding: 12px 16px;
  }

  .options-container {
    display: none; /* Keep hidden on small screens */
  }

  .bottom-action-container {
    padding: 8px 16px;
    padding-bottom: max(env(safe-area-inset-bottom), 12px);
  }

  .apply-now-button {
    padding: 12px 18px;
    font-size: 14px;
    border-radius: 8px;
    gap: 6px;
  }

  .whatsapp-icon {
    width: 16px;
    height: 16px;
  }

  .inline-options-container {
    gap: 4px;
    margin: 8px 0;
  }

  .inline-option-button {
    padding: 6px 12px;
    font-size: 11px;
    border-radius: 14px;
  }

  .bot-message,
  .user-message {
    padding: 12px 16px;
    margin: 8px 0;
    font-size: 13px;
  }
}
