/* css/chatbot.css - PHIÊN BẢN FIX STYLE CẢNH BÁO */

/* Nút mở Chatbot */
.chatbot-toggler {
  position: fixed;
  bottom: 30px;
  right: 35px;
  outline: none;
  border: none;
  height: 55px;
  width: 55px;
  display: flex;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    var(--neon-primary),
    var(--neon-secondary)
  );
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 9999;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.6);
}
.chatbot-toggler:hover {
  transform: scale(1.1) rotate(10deg);
}
body.show-chatbot .chatbot-toggler {
  transform: rotate(90deg);
}
.chatbot-toggler span {
  color: #fff;
  position: absolute;
  font-size: 1.4rem;
}
.chatbot-toggler span:last-child,
body.show-chatbot .chatbot-toggler span:first-child {
  opacity: 0;
}
body.show-chatbot .chatbot-toggler span:last-child {
  opacity: 1;
}

/* Khung Chatbot */
.chatbot {
  position: fixed;
  right: 35px;
  bottom: 100px;
  width: 340px; /* Kích thước nhỏ gọn */
  height: 480px;
  background: var(--chat-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.5) translateY(20px);
  transform-origin: bottom right;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3), 0 0 15px rgba(0, 229, 255, 0.1);
  z-index: 9998;
  display: flex;
  flex-direction: column;
}

body.show-chatbot .chatbot {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}

/* Header Gradient */
.chatbot header {
  padding: 15px 0;
  text-align: center;
  position: relative;
  background: linear-gradient(
    135deg,
    rgba(0, 229, 255, 0.1),
    rgba(187, 134, 252, 0.1)
  );
  border-bottom: 1px solid var(--chat-border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.chatbot header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(
    to right,
    var(--neon-primary),
    var(--neon-secondary)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
  letter-spacing: 0.5px;
}

.chatbot header span {
  position: absolute;
  right: 20px;
  top: 50%;
  color: var(--chat-text);
  transform: translateY(-50%);
  cursor: pointer;
  display: none;
  font-size: 1.2rem;
  transition: 0.2s;
}
.chatbot header span:hover {
  color: #ff6b6b;
}

/* Chatbox Area */
.chatbot .chatbox {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.chatbot :where(.chatbox, textarea)::-webkit-scrollbar {
  width: 4px;
}
.chatbot :where(.chatbox, textarea)::-webkit-scrollbar-track {
  background: transparent;
}
.chatbot :where(.chatbox, textarea)::-webkit-scrollbar-thumb {
  background: var(--neon-primary);
  border-radius: 10px;
}

.chatbox .chat {
  display: flex;
  list-style: none;
}

/* Avatar Bot */
.chatbox .incoming .bot-avatar {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  margin: 0 10px 5px 0;
  object-fit: cover;
  align-self: flex-end;
  border: 2px solid var(--neon-primary);
  background: #fff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

/* Tin nhắn */
.chatbox .chat p {
  white-space: pre-wrap;
  padding: 12px 16px;
  border-radius: 15px 15px 0 15px;
  max-width: 80%;
  font-size: 0.95rem;
  line-height: 1.5;
  background: linear-gradient(135deg, var(--neon-primary), #00b4d8);
  color: #fff;
  box-shadow: 0 4px 10px rgba(0, 229, 255, 0.2);
}

.chatbox .incoming p {
  border-radius: 15px 15px 15px 0;
  background: var(--chat-incoming-bg);
  color: var(--chat-text);
  border: 1px solid var(--chat-border);
  box-shadow: none;
}
.chatbox .outgoing {
  justify-content: flex-end;
}

/* --- HIỆU ỨNG TYPING --- */
.chatbox .incoming.typing p {
  display: flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  background: var(--chat-incoming-bg);
  border: 1px solid var(--chat-border);
}
.chatbox .incoming.typing p span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--chat-text);
  animation: bounce 0.8s infinite ease-in-out;
}
.chatbox .incoming.typing p span:nth-child(1) {
  animation-delay: 0s;
}
.chatbox .incoming.typing p span:nth-child(2) {
  animation-delay: 0.2s;
}
.chatbox .incoming.typing p span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* --- STYLE CHO DÒNG CẢNH BÁO (ĐÃ SỬA) --- */
.simple-warning {
  color: #ff0000; /* Màu đỏ thuần như yêu cầu */
  font-weight: 600;
  font-size: 0.9rem;
  font-family: Arial, sans-serif;
  display: block;
  margin-top: 8px;

  /* Bỏ nền và viền */
  background: none;
  border: none;
  padding: 0;
  text-shadow: none;
}

/* Chỉnh lại font chữ chung trong bong bóng chat cho thoáng hơn */
.chatbox .chat p {
  line-height: 1.6;
  letter-spacing: 0.3px;
}

/* FAQ Chips */
.chatbox .faq-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 5px;
  padding-left: 45px;
  animation: fadeIn 0.5s ease;
}
.suggestion-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--neon-primary);
  color: var(--neon-primary);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.suggestion-chip:hover {
  background: var(--neon-primary);
  color: #000;
  box-shadow: 0 0 10px var(--neon-primary);
  transform: translateY(-2px);
}

/* Input Area */
.chatbot .chat-input {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 10px 15px;
  border-top: 1px solid var(--chat-border);
  background: rgba(0, 0, 0, 0.2);
  align-items: center;
}
.chat-input textarea {
  height: 45px;
  width: 100%;
  border: 1px solid var(--chat-border);
  border-radius: 25px;
  background: var(--chat-input-bg);
  color: var(--chat-text);
  padding: 12px 15px;
  font-size: 0.95rem;
  resize: none;
  outline: none;
  transition: 0.3s;
}
.chat-input textarea:focus {
  border-color: var(--neon-primary);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.1);
}

.chat-input span {
  color: var(--text-sub);
  cursor: pointer;
  font-size: 1.4rem;
  transition: 0.3s;
}
.chat-input textarea:valid ~ span {
  color: var(--neon-primary);
  text-shadow: 0 0 10px var(--neon-primary);
}

/* Responsive */
@media (max-width: 490px) {
  .chatbot {
    right: 0;
    bottom: 0;
    height: 100%;
    width: 100%;
    border-radius: 0;
  }
  .chatbot header span {
    display: block;
  }
}

/* =========================================
   LIGHT MODE OVERRIDES (NEON CYBERPUNK)
   ========================================= */

/* Nút mở chat: Glow Neon rực rỡ */
body.light-mode .chatbot-toggler {
  box-shadow: 0 0 20px rgba(0, 210, 255, 0.6);
  background: linear-gradient(135deg, #00d2ff, #9d4edd);
}

/* Khung Chat: Glassmorphism + Viền Neon */
body.light-mode .chatbot {
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 10px 40px rgba(0, 210, 255, 0.2);
  border: 1px solid rgba(0, 210, 255, 0.5);
}

/* Header: Gradient Neon nhẹ */
body.light-mode .chatbot header {
  background: linear-gradient(
    135deg,
    rgba(0, 210, 255, 0.1),
    rgba(157, 78, 221, 0.1)
  );
  border-bottom: 1px solid rgba(0, 210, 255, 0.2);
}
body.light-mode .chatbot header h2 {
  background: linear-gradient(to right, #00d2ff, #9d4edd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 10px rgba(0, 210, 255, 0.3);
}

/* Avatar Bot: Viền phát sáng */
body.light-mode .bot-avatar {
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.4);
  border: 2px solid #00d2ff;
  background: #fff;
}

/* Tin nhắn Bot: Gradient Neon */
body.light-mode .chatbox .chat p {
  background: linear-gradient(135deg, #00d2ff, #00b4d8);
  box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
  color: #fff;
}

/* Tin nhắn Khách: Viền Neon mờ */
body.light-mode .chatbox .incoming p {
  color: #1e293b;
  background: rgba(0, 210, 255, 0.05);
  border: 1px solid rgba(0, 210, 255, 0.3);
  box-shadow: none;
}

/* Typing Animation */
body.light-mode .chatbox .incoming.typing p span {
  background-color: #00d2ff;
}

/* Cảnh báo */
body.light-mode .simple-warning {
  color: #ff0055;
  background: rgba(255, 0, 85, 0.1);
  border: 1px solid rgba(255, 0, 85, 0.3);
  text-shadow: none;
  padding: 6px 12px;
  border-radius: 6px;
  width: fit-content;
}

/* Ô nhập liệu */
body.light-mode .chat-input {
  background: rgba(255, 255, 255, 0.9);
  border-top: 1px solid rgba(0, 210, 255, 0.2);
}
body.light-mode .chat-input textarea {
  background: rgba(0, 210, 255, 0.05);
  border: 1px solid rgba(0, 210, 255, 0.3);
  color: #1e293b;
}
body.light-mode .chat-input textarea:focus {
  background: #fff;
  border-color: #00d2ff;
  box-shadow: 0 0 15px rgba(0, 210, 255, 0.2);
}

/* Suggestion Chips */
body.light-mode .suggestion-chip {
  background: rgba(0, 210, 255, 0.05);
  border: 1px solid #00d2ff;
  color: #0096c7;
}
body.light-mode .suggestion-chip:hover {
  background: #00d2ff;
  color: #fff;
  box-shadow: 0 0 15px rgba(0, 210, 255, 0.4);
}

@media (max-width: 768px) {
  .chatbot {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh; /* Dùng 100dvh để full chiều cao chuẩn hơn trên iPhone */
    border-radius: 0;
    z-index: 10000; /* Đè lên tất cả mọi thứ */
  }

  body.show-chatbot .chatbot-toggler {
    display: none;
  }

  .chatbot .chat-input {
    padding: 15px;
    padding-bottom: 30px; /* Thêm khoảng trống đáy cho các dòng iPhone đời mới (có thanh vuốt home) */
  }

  .chatbot .chatbox {
    padding-bottom: 100px;
  }

  .chatbot header span {
    display: block;
    font-size: 1.5rem;
    padding: 10px;
  }
}

.chat-input textarea {
  max-height: 120px; /* Giới hạn chiều cao tối đa (khoảng 4-5 dòng) */
  overflow-y: hidden; /* Mặc định ẩn thanh cuộn */
}

/* Tùy chỉnh thanh cuộn cho đẹp (Nhỏ gọn, màu xám) */
.chatbot .chat-input textarea::-webkit-scrollbar {
  width: 4px;
  background: transparent;
}

.chatbot .chat-input textarea::-webkit-scrollbar-thumb {
  background-color: var(--neon-primary);
  border-radius: 10px;
}

.chatbot .chat-input textarea::-webkit-scrollbar-track {
  background: transparent;
}

/* Hỗ trợ Firefox */
.chat-input textarea {
  scrollbar-width: thin;
  scrollbar-color: var(--neon-primary) transparent;
}
