/* css/chat.css */

/* --- 1. WIDGET NÚT TRÒN (Giữ nguyên) --- */
.contact-widget {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 15px;
}
.btn-toggle-contact {
  width: 60px;
  height: 60px;
  background: var(--primary-color);
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: 0.3s;
  position: relative;
  z-index: 2;
}
.btn-toggle-contact::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--primary-color);
  animation: pulse-ring 2s infinite;
}
@keyframes pulse-ring {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}
.btn-toggle-contact.active {
  background: #d0011b;
  transform: rotate(45deg);
}
.btn-toggle-contact.active::before {
  display: none;
}

.sub-btns {
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: 0.3s ease;
}
.contact-widget.open .sub-btns {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.btn-social {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.8rem;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
  text-decoration: none;
  transition: 0.2s;
  position: relative;
}
.btn-social:hover {
  transform: scale(1.1);
}
.btn-social::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 55px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 1.1rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.btn-social:hover::after {
  opacity: 1;
  visibility: visible;
}

.btn-zalo {
  background: #0068ff;
  font-weight: bold;
  font-family: sans-serif;
}
.btn-zalo i {
  font-style: normal;
  font-size: 1.4rem;
}
.btn-mess {
  background: #0084ff;
}
.btn-call {
  background: #2ecc71;
}
.btn-chat-live {
  background: #ff9f43;
}

/* --- 2. CỬA SỔ CHAT --- */
.chat-window {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 340px;
  height: 480px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 5px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.9) translateY(20px);
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: "Montserrat", sans-serif;
  overflow: hidden;
}
.chat-window.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
}

.chat-header {
  background: var(--primary-color);
  color: #fff;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #333;
}
.chat-title {
  font-weight: 700;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-status {
  width: 8px;
  height: 8px;
  background: #2ecc71;
  border-radius: 50%;
}
.btn-close-chat {
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
}

.chat-body {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-body::-webkit-scrollbar {
  width: 5px;
}
.chat-body::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 5px;
}

/* --- MESSAGE BUBBLES --- */
.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 1.3rem;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
  animation: fadeIn 0.2s ease;
}

/* Tin nhắn ADMIN (Shop) - Bên Trái */
.msg.admin {
  align-self: flex-start;
  background: #f0f0f0;
  color: #000;
  border-bottom-left-radius: 4px;
}

/* Tin nhắn ME (Khách) - Bên Phải */
.msg.me {
  align-self: flex-end;
  background: var(--primary-color);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-time {
  display: block;
  font-size: 0.9rem;
  opacity: 0.6;
  margin-top: 5px;
}
.msg.me .msg-time {
  color: rgba(255, 255, 255, 0.8);
  text-align: right;
}
.msg.admin .msg-time {
  color: #888;
  text-align: left;
}

/* --- TYPING INDICATOR (3 chấm động) --- */
.msg.typing {
  align-self: flex-start;
  background: #f0f0f0;
  padding: 12px 15px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
}
.typing-dot {
  width: 6px;
  height: 6px;
  background: #888;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}
.typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}
@keyframes typingBounce {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* --- LOGIN BUTTON --- */
.chat-login-request {
  text-align: center;
  margin-top: 20px;
}
.btn-chat-login {
  display: inline-block;
  background: var(--primary-color);
  color: #fff;
  padding: 8px 15px;
  border-radius: 20px;
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 5px;
}

/* Footer */
.chat-footer {
  padding: 10px;
  border-top: 1px solid #eee;
  background: #fff;
  display: flex;
  gap: 10px;
}
.chat-footer input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 10px 15px;
  outline: none;
  font-family: inherit;
  font-size: 1.3rem;
}
.chat-footer input:focus {
  border-color: var(--primary-color);
}
.btn-send-chat {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Responsive Mobile */
@media (max-width: 480px) {
  .contact-widget {
    right: 15px;
    bottom: 80px;
  }
  .chat-window {
    width: 92%;
    right: 4%;
    bottom: 10px;
    height: 500px;
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
