/* =========================================
   Chatbot Widget Styles
   Premium Glassmorphism & Animations
========================================= */

:root {
  --chat-primary: #3b82f6; /* Modern Blue */
  --chat-primary-hover: #2563eb;
  --chat-bg: rgba(255, 255, 255, 0.85);
  --chat-bg-dark: rgba(30, 41, 59, 0.85);
  --chat-text: #1e293b;
  --chat-text-dark: #f8fafc;
  --chat-border: rgba(255, 255, 255, 0.2);
  --chat-border-dark: rgba(255, 255, 255, 0.1);
  --chat-user-msg: #3b82f6;
  --chat-bot-msg: #f1f5f9;
  --chat-bot-msg-dark: #334155;
  --glass-blur: blur(16px);
  --chat-shadow: 0 10px 40px -10px rgba(0,0,0,0.2);
}

/* Floating Action Button */
#chatbot-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-primary), #60a5fa);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

#chatbot-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

/* Chat Window Container (Glassmorphism) */
#chatbot-window {
  position: fixed;
  bottom: 110px;
  right: 30px;
  width: 380px;
  height: 550px;
  max-height: calc(100vh - 140px);
  max-width: calc(100vw - 40px);
  background: var(--chat-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.19, 1, 0.22, 1);
  font-family: 'Sora', sans-serif;
}

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

/* Dark Mode Adaptation */
body.dark-mode #chatbot-window {
  background: var(--chat-bg-dark);
  border: 1px solid var(--chat-border-dark);
  color: var(--chat-text-dark);
}

/* Header */
.chat-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(59,130,246,0.05));
  border-bottom: 1px solid rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

body.dark-mode .chat-header {
  background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(59,130,246,0.1));
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

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

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid white;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

body.dark-mode .chat-avatar {
  border-color: #1e293b;
}

.chat-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--chat-text);
}

body.dark-mode .chat-title {
  color: var(--chat-text-dark);
}

.chat-subtitle {
  font-size: 12px;
  color: #64748b;
  margin: 0;
}

body.dark-mode .chat-subtitle {
  color: #94a3b8;
}

.close-chat {
  background: none;
  border: none;
  color: #64748b;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.close-chat:hover {
  color: #ef4444;
}

/* Messages Area */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.2);
  border-radius: 10px;
}
body.dark-mode .chat-messages::-webkit-scrollbar-thumb {
  background-color: rgba(255,255,255,0.2);
}

/* Individual Message Bubbles */
.chat-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  animation: slideIn 0.3s ease forwards;
  opacity: 0;
  transform: translateY(10px);
}

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

.chat-msg.bot {
  align-self: flex-start;
  background: var(--chat-bot-msg);
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
}

body.dark-mode .chat-msg.bot {
  background: var(--chat-bot-msg-dark);
  color: var(--chat-text-dark);
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--chat-user-msg);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--chat-bot-msg);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: fit-content;
  display: none;
}

body.dark-mode .typing-indicator {
  background: var(--chat-bot-msg-dark);
}

.typing-indicator.active {
  display: flex;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: #94a3b8;
  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); }
}

/* Input Area */
.chat-input-area {
  padding: 16px;
  border-top: 1px solid rgba(0,0,0,0.05);
  background: rgba(255,255,255,0.5);
  display: flex;
  gap: 8px;
}

body.dark-mode .chat-input-area {
  border-top: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.2);
}

#chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 24px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  background: rgba(255,255,255,0.8);
  transition: all 0.2s;
}

body.dark-mode #chat-input {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(255,255,255,0.1);
  color: var(--chat-text-dark);
}

#chat-input:focus {
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

#chat-send {
  background: var(--chat-primary);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

#chat-send:hover {
  background: var(--chat-primary-hover);
  transform: scale(1.05);
}

#chat-send:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

body.dark-mode #chat-send:disabled {
  background: #475569;
}
