/* ========== TAWAF CHATBOT — Premium Design ========== */
/* Inspired by shadcn prompt-input component patterns   */

/* ── FAB Button ── */
.chatbot-fab {
  position: fixed;
  bottom: 24px;
  right: 90px;
  z-index: 9998;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2d7d6b 0%, #1a5c4e 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(45,125,107,0.35), 0 0 0 0 rgba(45,125,107,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.chatbot-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 28px rgba(45,125,107,0.45);
}
.chatbot-fab:active { transform: scale(0.96); }
.chatbot-fab svg { width: 26px; height: 26px; fill: #fff; transition: transform 0.3s, opacity 0.2s; }
.chatbot-fab .fab-close { display: none; }
.chatbot-fab.open .fab-chat { display: none; }
.chatbot-fab.open .fab-close { display: block; }

/* Pulse ring */
.chatbot-fab::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid rgba(45,125,107,0.3);
  animation: chatPulse 2.5s ease-in-out infinite;
  pointer-events: none;
}
.chatbot-fab.open::after { animation: none; opacity: 0; }
@keyframes chatPulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 0; }
}

/* Notification dot */
.chatbot-fab .fab-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #ef4444;
  border-radius: 50%;
  border: 2.5px solid #fff;
  animation: dotBounce 2s ease infinite 3s;
}
.chatbot-fab.open .fab-dot,
.chatbot-fab.seen .fab-dot { display: none; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(1); }
  40% { transform: scale(1.3); }
}

/* ── Chat Window ── */
.chatbot-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9999;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 24px;
  box-shadow:
    0 25px 65px rgba(0,0,0,0.15),
    0 8px 24px rgba(0,0,0,0.08),
    0 0 0 1px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.chatbot-window.open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ── */
.chatbot-header {
  background: linear-gradient(135deg, #0a1f1a 0%, #112d26 50%, #0d2119 100%);
  padding: 20px 20px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  position: relative;
}
.chatbot-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201,168,76,0.15), transparent);
}
.chatbot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(45,125,107,0.3), rgba(201,168,76,0.2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.08);
}
.chatbot-header-text { flex: 1; }
.chatbot-header-text h4 {
  color: #fff;
  font-family: 'Playfair Display', 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}
.chatbot-header-text p {
  color: rgba(255,255,255,0.45);
  font-size: 11.5px;
  margin: 3px 0 0;
  font-weight: 400;
  letter-spacing: 0.2px;
}
.chatbot-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}
.chatbot-header-status .status-dot {
  width: 6px;
  height: 6px;
  background: #34d399;
  border-radius: 50%;
  animation: statusPulse 2s ease infinite;
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.chatbot-header-status span {
  font-size: 10.5px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.3px;
}
.chatbot-header-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: all 0.15s;
  display: none;
}
.chatbot-header-close:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7); }

/* ── Messages Area ── */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: linear-gradient(180deg, #fafbfa 0%, #fff 100%);
}
.chatbot-messages::-webkit-scrollbar { width: 3px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 3px; }

/* ── Message Bubbles ── */
.chat-msg {
  max-width: 88%;
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.65;
  animation: msgSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  word-wrap: break-word;
}
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.bot {
  align-self: flex-start;
  background: #f0f4f3;
  color: #1a2e2a;
  border-radius: 4px 18px 18px 18px;
  border: 1px solid rgba(45,125,107,0.06);
}
.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2d7d6b, #1f6356);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 8px rgba(45,125,107,0.2);
}

.chat-msg a { text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
.chat-msg.bot a { color: #2d7d6b; }
.chat-msg.user a { color: #fff; }
.chat-msg strong { font-weight: 700; }
.chat-msg em { font-style: italic; opacity: 0.85; }
.chat-msg hr { border: none; border-top: 1px solid rgba(0,0,0,0.08); margin: 10px 0; }

/* WhatsApp inline CTA inside messages */
.chat-msg .chat-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 16px;
  background: #25d366;
  color: #fff !important;
  text-decoration: none !important;
  border-radius: 50px;
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.15s;
  box-shadow: 0 2px 8px rgba(37,211,102,0.25);
}
.chat-msg .chat-wa-btn:hover { background: #20bd5a; transform: translateY(-1px); }
.chat-msg .chat-wa-btn svg { width: 16px; height: 16px; fill: #fff; flex-shrink: 0; }

/* ── Quick Replies ── */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 16px 10px;
  flex-shrink: 0;
}
.chat-quick-btn {
  background: #fff;
  border: 1px solid rgba(45,125,107,0.18);
  color: #2d7d6b;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: inherit;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.chat-quick-btn:hover {
  background: rgba(45,125,107,0.06);
  border-color: rgba(45,125,107,0.35);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.chat-quick-btn:active { transform: translateY(0); }

/* ── Prompt Input (shadcn-inspired) ── */
.chatbot-prompt {
  border-top: 1px solid rgba(0,0,0,0.06);
  padding: 12px 12px 10px;
  flex-shrink: 0;
  background: #fff;
}
.chatbot-prompt-inner {
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 24px;
  padding: 6px;
  background: #fafbfa;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.chatbot-prompt-inner:focus-within {
  border-color: rgba(45,125,107,0.4);
  box-shadow: 0 0 0 3px rgba(45,125,107,0.08), 0 1px 2px rgba(0,0,0,0.04);
}
.chatbot-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  padding: 6px 12px;
  min-height: 36px;
  max-height: 120px;
  background: transparent;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #1a2e2a;
}
.chatbot-textarea::placeholder { color: rgba(0,0,0,0.35); }

.chatbot-prompt-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 0;
}
.chatbot-prompt-left {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Action buttons in prompt bar */
.chatbot-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  background: transparent;
  position: relative;
}
.chatbot-action-btn svg { width: 18px; height: 18px; }
.chatbot-action-btn:hover { background: rgba(0,0,0,0.05); }
.chatbot-action-btn:active { transform: scale(0.92); }

/* WhatsApp action */
.chatbot-action-wa svg { fill: #25d366; }
.chatbot-action-wa:hover { background: rgba(37,211,102,0.1); }

/* Send button */
.chatbot-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: #2d7d6b;
  box-shadow: 0 2px 6px rgba(45,125,107,0.3);
}
.chatbot-send-btn svg { width: 16px; height: 16px; fill: #fff; }
.chatbot-send-btn:hover { background: #246b5b; transform: scale(1.06); }
.chatbot-send-btn:active { transform: scale(0.94); }
.chatbot-send-btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* Tooltip */
.chatbot-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  background: #1a2e2a;
  color: #fff;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all 0.15s;
}
.chatbot-action-btn:hover .chatbot-tooltip,
.chatbot-send-btn:hover .chatbot-tooltip {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ── Disclaimer ── */
.chatbot-disclaimer {
  padding: 7px 16px 9px;
  background: linear-gradient(135deg, #fefce8, #fef9e7);
  border-top: 1px solid rgba(201,168,76,0.12);
  font-size: 10.5px;
  color: #92751f;
  text-align: center;
  line-height: 1.4;
  flex-shrink: 0;
  letter-spacing: 0.1px;
}

/* ── Typing Indicator ── */
.chat-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 14px 20px;
  background: #f0f4f3;
  border-radius: 4px 18px 18px 18px;
  border: 1px solid rgba(45,125,107,0.06);
  animation: msgSlideIn 0.3s ease;
}
.chat-typing span {
  width: 7px;
  height: 7px;
  background: rgba(45,125,107,0.4);
  border-radius: 50%;
  animation: typingDot 1.4s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Timestamp ── */
.chat-time {
  text-align: center;
  font-size: 10px;
  color: rgba(0,0,0,0.25);
  padding: 4px 0;
  letter-spacing: 0.3px;
}

/* ── RTL Support ── */
body.rtl .chatbot-fab { right: auto; left: 90px; }
body.rtl .chatbot-window { right: auto; left: 24px; }
body.rtl .chat-msg.bot { border-radius: 18px 4px 18px 18px; }
body.rtl .chat-msg.user { border-radius: 18px 18px 18px 4px; }
body.rtl .chat-typing { border-radius: 18px 4px 18px 18px; }
body.rtl .chatbot-textarea { text-align: right; }
body.rtl .chatbot-prompt-actions { flex-direction: row-reverse; }
body.rtl .chatbot-prompt-left { flex-direction: row-reverse; }

/* ── Mobile ── */
@media (max-width: 480px) {
  .chatbot-fab { bottom: 20px; right: 76px; width: 52px; height: 52px; }
  .chatbot-fab svg { width: 22px; height: 22px; }
  .chatbot-window {
    bottom: 0; right: 0; left: 0; top: 0;
    width: 100%; max-width: 100%;
    height: 100%; max-height: 100%;
    border-radius: 0;
  }
  .chatbot-header-close { display: flex; }
  body.rtl .chatbot-fab { left: 76px; right: auto; }
  body.rtl .chatbot-window { left: 0; right: 0; }
}

@media (min-width: 481px) and (max-width: 768px) {
  .chatbot-window { width: 360px; height: 500px; }
}
