/* =============================================================
   Zoe Smiles — AI Chatbot Widget
   File: assets/css/chatbot.css
   Fully isolated — zero impact on existing page styles
   ============================================================= */

/* ─── Chatbot Keyframes ─────────────────────────────────────── */
@keyframes cb-slideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cb-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes cb-pulse-ring {
  0%   { transform: scale(1);    opacity: 0.7; }
  70%  { transform: scale(1.85); opacity: 0;   }
  100% { transform: scale(1.85); opacity: 0;   }
}

@keyframes cb-dot-bounce {
  0%, 80%, 100% { transform: translateY(0);    }
  40%           { transform: translateY(-6px); }
}

@keyframes cb-badge-pop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes cb-shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* ─── Toggle Button ─────────────────────────────────────────── */
.chatbot-toggle-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9998;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #006576 0%, #0099B0 60%, #00b5d0 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow:
    0 8px 28px rgba(0, 101, 118, 0.45),
    0 2px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  outline: none;
}

.chatbot-toggle-btn:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow:
    0 14px 40px rgba(0, 101, 118, 0.55),
    0 4px 12px rgba(0, 0, 0, 0.15);
}

.chatbot-toggle-btn:active {
  transform: scale(0.96);
}

/* Animated pulse ring */
.chatbot-toggle-btn .pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(0, 153, 176, 0.55);
  animation: cb-pulse-ring 2.4s ease-out infinite;
  pointer-events: none;
}

/* Tooltip */
.chatbot-toggle-btn .chatbot-tooltip {
  position: absolute;
  right: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}

.chatbot-toggle-btn .chatbot-tooltip::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: #0f172a;
}

.chatbot-toggle-btn:hover .chatbot-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(-4px);
}

/* Unread badge on toggle button */
.chatbot-toggle-btn .cb-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 0.6rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cb-badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  font-family: 'Inter', sans-serif;
}

/* ─── Chat Widget Container ─────────────────────────────────── */
.chatbot-widget {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 9999;
  width: 320px;
  max-height: 500px;
  height: 80vh; /* flexible height */
  border-radius: 1.2rem;
  background: #ffffff;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.18),
    0 8px 24px rgba(0, 101, 118, 0.12),
    0 0 0 1px rgba(0, 101, 118, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px) scale(0.96);
  transition:
    opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
}

.chatbot-widget--open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* Mobile — neatly floating */
@media (max-width: 480px) {
  .chatbot-widget {
    width: calc(100vw - 2rem);
    right: 1rem;
    bottom: 5rem;
    max-height: calc(100vh - 7rem);
    border-radius: 1.2rem;
  }

  .chatbot-toggle-btn {
    bottom: 1rem;
    right: 1rem;
    width: 50px;
    height: 50px;
  }
}

/* ─── Chat Header ────────────────────────────────────────────── */
.chatbot-header {
  background: linear-gradient(135deg, #006576 0%, #0099B0 60%, #00b5d0 100%);
  background-size: 200% 200%;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.chatbot-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,0.08) 40%,
    rgba(255,255,255,0.14) 50%,
    rgba(255,255,255,0.08) 60%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: cb-shimmer 4s infinite;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
  z-index: 1;
}

.chatbot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  border: 2px solid rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 1.1rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  position: relative;
  backdrop-filter: blur(8px);
}

/* Online green dot */
.chatbot-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #34d399;
  border-radius: 50%;
  border: 2px solid rgba(0,80,95,0.8);
  box-shadow: 0 0 0 2px rgba(52,211,153,0.3);
}

.chatbot-header-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.chatbot-header-text h4 {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
}

.chatbot-header-text span {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.82);
  font-weight: 500;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.chatbot-header-text span::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(52,211,153,0.6);
  flex-shrink: 0;
}

.chatbot-close-btn {
  position: relative;
  z-index: 1;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  backdrop-filter: blur(8px);
}

.chatbot-close-btn:hover {
  background: rgba(255,255,255,0.28);
  transform: scale(1.1);
}

/* ─── AI Powered Badge strip ─────────────────────────────────── */
.chatbot-ai-strip {
  background: rgba(0, 101, 118, 0.05);
  border-bottom: 1px solid rgba(0, 101, 118, 0.08);
  padding: 0.38rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.chatbot-ai-strip__dot {
  width: 6px;
  height: 6px;
  background: #006576;
  border-radius: 50%;
  flex-shrink: 0;
}

.chatbot-ai-strip__text {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #006576;
  font-family: 'Inter', sans-serif;
}

/* ─── Chat Body / Messages ───────────────────────────────────── */
.chatbot-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
  background: #f8fafc;
}

/* Custom scrollbar */
.chatbot-body::-webkit-scrollbar { width: 4px; }
.chatbot-body::-webkit-scrollbar-track { background: transparent; }
.chatbot-body::-webkit-scrollbar-thumb {
  background: rgba(0, 101, 118, 0.2);
  border-radius: 4px;
}
.chatbot-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 101, 118, 0.4);
}

/* ─── Message Bubbles ────────────────────────────────────────── */
.chat-message {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  animation: cb-fadeIn 0.3s ease both;
  max-width: 88%;
}

.chat-message.bot {
  align-self: flex-start;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-bubble {
  padding: 0.6rem 0.85rem;
  border-radius: 1rem;
  font-size: 0.82rem;
  line-height: 1.5;
  font-family: 'Inter', sans-serif;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message.bot .chat-bubble {
  background: #ffffff;
  color: #1e293b;
  border-radius: 0.35rem 1.1rem 1.1rem 1.1rem;
  border: 1px solid rgba(0, 101, 118, 0.1);
  box-shadow: 0 2px 8px rgba(0, 101, 118, 0.06);
}

.chat-message.user .chat-bubble {
  background: linear-gradient(135deg, #006576 0%, #0099B0 100%);
  color: #ffffff;
  border-radius: 1.1rem 0.35rem 1.1rem 1.1rem;
  box-shadow: 0 4px 14px rgba(0, 101, 118, 0.32);
}

/* Bot sender label */
.chat-sender {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #006576;
  padding-left: 0.25rem;
  font-family: 'Inter', sans-serif;
}

/* ─── Quick Action Chips ─────────────────────────────────────── */
.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.chat-action-btn {
  background: #fff;
  border: 1.5px solid rgba(0, 101, 118, 0.22);
  color: #006576;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  padding: 0.35rem 0.65rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
  letter-spacing: 0.01em;
  white-space: nowrap;
  outline: none;
}

.chat-action-btn:hover {
  background: #006576;
  color: #fff;
  border-color: #006576;
  transform: translateY(-1px);
}

.chat-action-btn:active {
  transform: translateY(0);
}

/* ─── Typing Indicator ───────────────────────────────────────── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.5rem 0.8rem;
  background: #ffffff;
  border: 1px solid rgba(0, 101, 118, 0.1);
  border-radius: 0.35rem 1.1rem 1.1rem 1.1rem;
  width: fit-content;
  box-shadow: 0 2px 8px rgba(0, 101, 118, 0.06);
  animation: cb-fadeIn 0.3s ease both;
}

.chat-typing span {
  width: 7px;
  height: 7px;
  background: #006576;
  border-radius: 50%;
  display: inline-block;
  opacity: 0.7;
}

.chat-typing span:nth-child(1) { animation: cb-dot-bounce 1.2s 0s ease-in-out infinite; }
.chat-typing span:nth-child(2) { animation: cb-dot-bounce 1.2s 0.2s ease-in-out infinite; }
.chat-typing span:nth-child(3) { animation: cb-dot-bounce 1.2s 0.4s ease-in-out infinite; }

/* ─── Error message ──────────────────────────────────────────── */
.chat-error-bubble {
  background: #fef2f2;
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #b91c1c;
  font-size: 0.8rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.35rem 1.1rem 1.1rem 1.1rem;
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
}

/* ─── Input Area ─────────────────────────────────────────────── */
.chatbot-input-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  background: #fff;
  border-top: 1px solid rgba(0, 101, 118, 0.09);
  flex-shrink: 0;
}

#chatbot-input {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  color: #1e293b;
  background: #f8fafc;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

#chatbot-input:focus {
  border-color: #006576;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 101, 118, 0.1);
}

#chatbot-input::placeholder {
  color: #94a3b8;
  font-size: 0.83rem;
}

.chatbot-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #006576 0%, #0099B0 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 14px rgba(0, 101, 118, 0.35);
  outline: none;
}

.chatbot-send-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 18px rgba(0, 101, 118, 0.45);
}

.chatbot-send-btn:active {
  transform: scale(0.96);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ─── Footer API Branding ────────────────────────────────────── */
.chatbot-footer {
  padding: 0.4rem 1rem 0.6rem;
  text-align: center;
  background: #fff;
  border-top: 1px solid rgba(0,101,118,0.06);
  flex-shrink: 0;
}

.chatbot-footer span {
  font-size: 0.62rem;
  color: #94a3b8;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.02em;
}

.chatbot-footer a {
  color: #006576;
  font-weight: 600;
  text-decoration: none;
}

.chatbot-footer a:hover {
  text-decoration: underline;
}

/* ─── Accessibility ──────────────────────────────────────────── */
.chatbot-toggle-btn:focus-visible,
.chatbot-close-btn:focus-visible,
.chatbot-send-btn:focus-visible,
.chat-action-btn:focus-visible {
  outline: 2px solid #006576;
  outline-offset: 2px;
}
