/* =============================================================
   VEDATRICKS v2 — Chatbot Widget
   Bottom-right dock, 380×560 desktop, full-screen mobile
   Per ENGINEERING_BEST_PRACTICES.md chat widget dock pattern
   ============================================================= */

.chatbot {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: var(--font);
}

/* Floating Action Button */
.chatbot__fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--g);
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 20px rgba(123,193,66,.4);
  transition: transform 0.25s var(--ease), box-shadow 0.25s;
  position: relative;
  cursor: pointer;
  border: none;
}
.chatbot__fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(123,193,66,.5);
}

.chatbot__fab-icon--close { display: none; }
.chatbot.is-open .chatbot__fab-icon--chat { display: none; }
.chatbot.is-open .chatbot__fab-icon--close { display: block; }

.chatbot__fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border-radius: 50%;
  display: grid;
  place-items: center;
  line-height: 1;
}

/* Chat Panel — hidden by default via [hidden] attr, shown via JS */
.chatbot__panel[hidden] {
  display: none !important;
}

.chatbot__panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--bg);
  border-radius: var(--r-lg);
  box-shadow: 0 12px 48px rgba(0,0,0,.15), 0 4px 16px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatSlideUp 0.35s var(--ease);
}

@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}

/* Header */
.chatbot__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--g);
  color: var(--ink);
  flex-shrink: 0;
}

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

.chatbot__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.chatbot__avatar img { width: 20px; height: 20px; }

.chatbot__header-name { font-size: 15px; font-weight: 700; }
.chatbot__header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.8;
}

.chatbot__status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: livePulse 2.2s infinite;
}

.chatbot__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
}
.chatbot__close:hover { opacity: 1; background: rgba(0,0,0,.1); }

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

.chatbot__msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  line-height: 1.5;
  animation: fadeSlide 0.3s var(--ease);
}

.chatbot__msg--bot {
  background: var(--bg-off);
  color: var(--ink);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chatbot__msg--user {
  background: var(--g);
  color: var(--ink);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.chatbot__typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-off);
  border-radius: var(--r-md);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  max-width: 70px;
}
.chatbot__typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-4);
  animation: typingBounce 1.4s infinite;
}
.chatbot__typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chatbot__typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Quick Replies */
.chatbot__quick {
  padding: 0 20px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.chatbot__quick-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--g-dark);
  background: var(--g-soft);
  border: 1px solid rgba(123,193,66,.2);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chatbot__quick-btn:hover {
  background: var(--g);
  color: var(--ink);
  border-color: var(--g);
}

/* Lead Form */
.chatbot__lead-form {
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  background: var(--bg-soft);
}

.chatbot__lead-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  margin: 0;
}

.chatbot__lead-input {
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--bg);
  transition: border-color 0.15s;
  width: 100%;
}
.chatbot__lead-input:focus {
  outline: none;
  border-color: var(--g);
}

.chatbot__lead-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 700;
  background: var(--g);
  color: var(--ink);
  border: none;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background 0.15s;
}
.chatbot__lead-btn:hover { background: var(--g-hover); }

/* Input Area */
.chatbot__input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.chatbot__input {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--bg-off);
  transition: border-color 0.15s;
  min-width: 0;
}
.chatbot__input:focus {
  outline: none;
  border-color: var(--g);
  background: var(--bg);
}

.chatbot__send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--g);
  color: var(--ink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}
.chatbot__send:hover { background: var(--g-hover); transform: scale(1.05); }

/* WhatsApp fallback link */
.chatbot__wa-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #25D366;
  background: var(--bg-soft);
  border-top: 1px solid var(--line);
  transition: background 0.15s;
  text-decoration: none;
  flex-shrink: 0;
}
.chatbot__wa-link:hover { background: var(--bg-off); }

/* =============================================================
   MOBILE — Full screen
   ============================================================= */

@media (max-width: 480px) {
  .chatbot__panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}
