/* ============================================
   CHAT WIDGET CSS
   WhatsApp Style Chat UI
   ============================================ */

/* CSS Variables Fix */
:root {
  --primary: #6c63ff;
  --secondary: #a855f7;
  --bg-card: #ffffff;
  --bg-secondary: #f5f7fa;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-light: #718096;
}
.chat-float-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(108, 99, 255, 0.4);
  transition: all 0.3s ease;
  z-index: 998;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-float-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(108, 99, 255, 0.5);
}

/* Notification Badge */
.chat-notification {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--secondary);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pop 0.3s ease;
}

.chat-notification.hidden {
  display: none;
}

@keyframes pop {
  0% { transform: scale(0); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ---- Chat Widget Box ---- */
.chat-widget {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 370px;
  height: 550px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 997;
  overflow: hidden;
  transition: all 0.3s ease;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
}

/* Chat Widget Open State */
.chat-widget.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Widget Minimized */
.chat-widget.minimized {
  height: 65px;
}

/* ---- Chat Header ---- */
.chat-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 15px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

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

.chat-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #43e97b;
  border-radius: 50%;
  border: 2px solid white;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.chat-header-info h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.chat-status {
  font-size: 0.75rem;
  opacity: 0.85;
}

.chat-header-btns {
  display: flex;
  gap: 8px;
}

.chat-minimize,
.chat-close {
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.chat-minimize:hover,
.chat-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* ---- Chat Messages Area ---- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-secondary);
  scroll-behavior: smooth;
}

/* Scrollbar Style */
.chat-messages::-webkit-scrollbar {
  width: 4px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

/* ---- Message Bubbles ---- */
.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: slideIn 0.3s ease;
}

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

/* User Message - Right Side */
.message.user {
  align-self: flex-end;
  align-items: flex-end;
}

/* AI Message - Left Side */
.message.ai {
  align-self: flex-start;
  align-items: flex-start;
}

/* Message Bubble */
.message-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-wrap: break-word;
}

/* User Bubble - Purple */
.message.user .message-bubble {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-bottom-right-radius: 4px;
}

/* AI Bubble - White/Dark */
.message.ai .message-bubble {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Message Timestamp */
.message-time {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 4px;
  padding: 0 4px;
}

/* ---- Typing Indicator ---- */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: typing 1.2s infinite;
}

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

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ---- Chat Input Area ---- */
.chat-input-area {
  padding: 12px 15px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}

.chat-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 6px 6px 6px 16px;
  transition: all 0.3s ease;
}

.chat-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

#chatInput {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: "Poppins", sans-serif;
  font-size: 0.875rem;
  outline: none;
}

#chatInput::placeholder {
  color: var(--text-light);
}

.send-btn {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

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

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

.chat-hint {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 6px;
}

/* ---- Welcome Message ---- */
.welcome-msg {
  text-align: center;
  padding: 10px 0;
}

.welcome-msg p {
  font-size: 0.75rem;
  color: var(--text-light);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 4px 14px;
  display: inline-block;
}

/* ---- Quick Questions ---- */
.quick-questions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 5px;
}

.quick-q {
  background: var(--bg-card);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 7px 14px;
  border-radius: 50px;
  font-size: 0.78rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  font-family: "Poppins", sans-serif;
}

.quick-q:hover {
  background: var(--primary);
  color: white;
}

/* ---- Mobile Responsive ---- */
@media (max-width: 480px) {
  .chat-widget {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 90px;
    height: 500px;
  }

  .chat-float-btn {
    right: 20px;
    bottom: 20px;
    width: 55px;
    height: 55px;
  }
}