/* =============================================
   PlantIQX Chatbot Widget Styles
   ============================================= */

:root {
  --chat-primary: #0a84ff;
  --chat-primary-dark: #0060cc;
  --chat-bg: #0d1117;
  --chat-surface: #161b22;
  --chat-surface-2: #1f2937;
  --chat-border: #30363d;
  --chat-text: #e6edf3;
  --chat-text-muted: #8b949e;
  --chat-user-bubble: #0a84ff;
  --chat-bot-bubble: #1f2937;
  --chat-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

/* ---- Floating Toggle Button ---- */
#piqx-chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a84ff, #0055cc);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(10,132,255,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#piqx-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(10,132,255,0.6);
}
#piqx-chat-toggle svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: opacity 0.2s;
}
#piqx-chat-toggle .icon-close { display: none; }
#piqx-chat-toggle.open .icon-chat  { display: none; }
#piqx-chat-toggle.open .icon-close { display: block; }

/* Notification dot */
#piqx-chat-toggle .notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  background: #ff453a;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.3); opacity: 0.8; }
}

/* ---- Chat Window ---- */
#piqx-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 370px;
  max-height: 580px;
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}
#piqx-chat-window.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ---- Header ---- */
#piqx-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #0d1f3c, #0a2a5e);
  border-bottom: 1px solid var(--chat-border);
  flex-shrink: 0;
}
.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a84ff, #0055cc);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-avatar svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}
.chat-header-info h4 {
  margin: 0;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}
.chat-header-info span {
  font-size: 12px;
  color: #34d399;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.chat-header-info span::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #34d399;
  border-radius: 50%;
  display: inline-block;
}
.chat-close-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--chat-text-muted);
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-close-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.chat-close-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* ---- Messages Area ---- */
#piqx-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
#piqx-chat-messages::-webkit-scrollbar { width: 4px; }
#piqx-chat-messages::-webkit-scrollbar-track { background: transparent; }
#piqx-chat-messages::-webkit-scrollbar-thumb { background: var(--chat-border); border-radius: 4px; }

/* Message bubbles */
.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msg-in 0.2s ease;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.user { flex-direction: row-reverse; }
.msg-bubble {
  max-width: 80%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--chat-text);
}
.chat-msg.bot  .msg-bubble {
  background: var(--chat-bot-bubble);
  border-bottom-left-radius: 4px;
}
.chat-msg.user .msg-bubble {
  background: var(--chat-user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-bubble a { color: #60b4ff; text-decoration: underline; }
.msg-bubble ul { padding-left: 18px; margin: 6px 0 0; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble strong { color: #fff; }

/* Bot mini avatar */
.msg-bot-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a84ff, #0055cc);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.msg-bot-avatar svg { width: 15px; height: 15px; fill: #fff; }

/* Typing indicator */
.typing-indicator .msg-bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px 18px;
}
.typing-dot {
  width: 7px; height: 7px;
  background: var(--chat-text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-6px); }
}

/* ---- Quick Replies ---- */
#piqx-quick-replies {
  padding: 0 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.quick-reply-btn {
  background: transparent;
  border: 1px solid var(--chat-primary);
  color: var(--chat-primary);
  padding: 6px 13px;
  border-radius: 20px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.quick-reply-btn:hover {
  background: var(--chat-primary);
  color: #fff;
}

/* ---- Input Area ---- */
#piqx-chat-input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--chat-border);
  background: var(--chat-surface);
  flex-shrink: 0;
}
#piqx-chat-input {
  flex: 1;
  background: var(--chat-surface-2);
  border: 1px solid var(--chat-border);
  border-radius: 24px;
  padding: 10px 16px;
  color: var(--chat-text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
#piqx-chat-input:focus { border-color: var(--chat-primary); }
#piqx-chat-input::placeholder { color: var(--chat-text-muted); }
#piqx-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--chat-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
#piqx-chat-send:hover { background: var(--chat-primary-dark); transform: scale(1.05); }
#piqx-chat-send svg { width: 18px; height: 18px; fill: #fff; }

/* ---- Responsive ---- */
@media (max-width: 480px) {
  #piqx-chat-window {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 90px;
    max-height: 70vh;
  }
  #piqx-chat-toggle { bottom: 16px; right: 16px; }
}
