/* ============================================
   Xgrid Temporal Chatbot — chatbot.css
   Path: /wp-content/themes/xgrid-resources-child/chatbot.css
   ============================================ */

@font-face {
  font-family: 'XgridSans';
  src: url(/resources/wp-content/themes/xgrid-resources-child/assets/fonts/XgridSans-Lightnormal.otf) format('opentype');
  font-weight: normal;
  font-style: normal;
}

/* ====== CSS VARIABLES ====== */
:root {
  --xgrid-purple: #6f63de;
  --xgrid-purple-light: #8f85e8;
  --xgrid-purple-dark: #5548c8;
  --xgrid-purple-faint: rgba(111,99,222,0.12);
  --xgrid-purple-border: rgba(111,99,222,0.3);
  --xgrid-white: #ffffff;
  --xgrid-bg: #ffffff;
  --xgrid-bg-msg: #f4f3fd;
  --xgrid-text: #2d2b4e;
  --xgrid-text-light: #6b6894;
}

/* ====== CHAT LAUNCHER BUTTON ====== */
#xgrid-chat-launcher {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--xgrid-purple), var(--xgrid-purple-dark));
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 24px rgba(111,99,222,0.5);
  animation: xgrid-pulse 2.5s infinite;
  z-index: 9999;
  border: none;
  transition: transform 0.2s;
}
#xgrid-chat-launcher:hover { transform: scale(1.08); }
#xgrid-chat-launcher svg { width: 26px; height: 26px; }

@keyframes xgrid-pulse {
  0%   { box-shadow: 0 4px 24px rgba(111,99,222,0.5), 0 0 0 0 rgba(111,99,222,0.4); }
  70%  { box-shadow: 0 4px 24px rgba(111,99,222,0.5), 0 0 0 14px rgba(111,99,222,0); }
  100% { box-shadow: 0 4px 24px rgba(111,99,222,0.5), 0 0 0 0 rgba(111,99,222,0); }
}

#xgrid-chat-launcher::after {
  content: '1';
  position: absolute;
  top: -4px; right: -4px;
  background: #ff3d71;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'XgridSans', sans-serif !important;
}

/* ====== CHAT WINDOW ====== */
#xgrid-chat-window {
  position: fixed;
  bottom: 100px; right: 28px;
  width: 380px;
  max-height: 560px;
  background: var(--xgrid-white);
  border: 1px solid rgba(111,99,222,0.2);
  border-radius: 20px;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(111,99,222,0.18), 0 4px 16px rgba(0,0,0,0.08);
  z-index: 9998;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#xgrid-chat-window.xgrid-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ====== HEADER ====== */
.xgrid-chat-header {
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--xgrid-purple), var(--xgrid-purple-dark));
  border-bottom: none;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.xgrid-avatar {
  width: 38px; height: 38px;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.xgrid-header-info { flex: 1; }
.xgrid-header-name { font-size: 14px; font-weight: 700; color: #fff; letter-spacing: 0.02em; font-family: 'XgridSans', sans-serif !important; }
.xgrid-header-status { font-size: 11px; color: rgba(255,255,255,0.8); font-family: 'XgridSans', sans-serif !important; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.xgrid-status-dot { width: 6px; height: 6px; background: #a8ff78; border-radius: 50%; animation: xgrid-blink 1.5s infinite; }
@keyframes xgrid-blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

.xgrid-close-btn {
  background: rgba(255,255,255,0.15); border: none; cursor: pointer;
  color: #fff; font-size: 18px; line-height: 1;
  transition: background 0.2s; padding: 6px 8px;
  border-radius: 8px;
}
.xgrid-close-btn:hover { background: rgba(255,255,255,0.28); }

/* ====== MESSAGES BODY ====== */
.xgrid-chat-body {
  flex: 1; overflow-y: auto;
  padding: 20px 16px;
  display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth;
  background: #fafafa;
}
.xgrid-chat-body::-webkit-scrollbar { width: 4px; }
.xgrid-chat-body::-webkit-scrollbar-track { background: transparent; }
.xgrid-chat-body::-webkit-scrollbar-thumb { background: rgba(111,99,222,0.25); border-radius: 2px; }

/* ====== BOT MESSAGE ====== */
.xgrid-msg-bot {
  display: flex; gap: 10px; align-items: flex-start;
  animation: xgrid-slideIn 0.35s ease forwards;
  opacity: 0;
}
@keyframes xgrid-slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.xgrid-msg-avatar {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--xgrid-purple), var(--xgrid-purple-dark));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 2px;
}
.xgrid-bubble {
  background: var(--xgrid-white);
  border: 1px solid rgba(111,99,222,0.15);
  border-radius: 4px 16px 16px 16px;
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--xgrid-text);
  max-width: 280px;
  font-family: 'XgridSans', sans-serif !important;
  box-shadow: 0 2px 8px rgba(111,99,222,0.08);
}
.xgrid-bubble strong { color: var(--xgrid-purple); font-weight: 700; }

/* ====== TYPING INDICATOR ====== */
.xgrid-typing-indicator {
  display: flex; gap: 5px; align-items: center;
  padding: 10px 14px;
}
.xgrid-typing-dot {
  width: 7px; height: 7px;
  background: var(--xgrid-purple);
  border-radius: 50%;
  animation: xgrid-typingBounce 1.2s infinite;
}
.xgrid-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.xgrid-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes xgrid-typingBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30%          { transform: translateY(-6px); opacity: 1; }
}

/* ====== BUTTONS ====== */
.xgrid-btn-group {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 4px;
  animation: xgrid-slideIn 0.35s ease 0.15s forwards;
  opacity: 0;
}
.xgrid-chat-btn {
  background: var(--xgrid-white);
  border: 1.5px solid var(--xgrid-purple-border);
  color: var(--xgrid-purple);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-family: 'XgridSans', sans-serif !important;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  line-height: 1.4;
}
.xgrid-chat-btn:hover {
  background: var(--xgrid-purple-faint);
  border-color: var(--xgrid-purple);
  color: var(--xgrid-purple-dark);
  transform: translateX(3px);
}
.xgrid-chat-btn.xgrid-primary {
  background: linear-gradient(135deg, var(--xgrid-purple), var(--xgrid-purple-dark));
  border-color: transparent;
  color: #fff;
}
.xgrid-chat-btn.xgrid-primary:hover {
  background: linear-gradient(135deg, var(--xgrid-purple-light), var(--xgrid-purple));
  transform: translateX(3px);
}

/* ====== USER MESSAGE ====== */
.xgrid-msg-user {
  display: flex; justify-content: flex-end;
  animation: xgrid-slideIn 0.3s ease forwards; opacity: 0;
}
.xgrid-bubble-user {
  background: linear-gradient(135deg, var(--xgrid-purple), var(--xgrid-purple-dark));
  border-radius: 16px 4px 16px 16px;
  padding: 10px 14px;
  font-size: 13px;
  color: #fff;
  max-width: 240px;
  line-height: 1.5;
  font-family: 'XgridSans', sans-serif !important;
  box-shadow: 0 2px 10px rgba(111,99,222,0.3);
}

/* ====== CTA CARD ====== */
.xgrid-cta-card {
  background: linear-gradient(135deg, #f0eeff, #e8e5ff);
  border: 1.5px solid rgba(111,99,222,0.25);
  border-radius: 12px;
  padding: 14px;
  margin-top: 4px;
  animation: xgrid-slideIn 0.35s ease 0.2s forwards; opacity: 0;
}
.xgrid-cta-label { font-size: 10px; color: var(--xgrid-purple); font-family: 'XgridSans', sans-serif !important; letter-spacing: 0.15em; text-transform: uppercase; margin-bottom: 6px; }
.xgrid-cta-title { font-size: 13px; font-weight: 700; color: var(--xgrid-text); margin-bottom: 10px; line-height: 1.4; font-family: 'XgridSans', sans-serif !important; }
.xgrid-cta-btn {
  display: block; width: 100%;
  background: linear-gradient(135deg, var(--xgrid-purple), var(--xgrid-purple-dark));
  color: #fff;
  font-family: 'XgridSans', sans-serif !important;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.05em;
  padding: 10px;
  border: none; border-radius: 8px;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 4px 14px rgba(111,99,222,0.4);
}
.xgrid-cta-btn:hover { opacity: 0.88; transform: scale(0.98); }

/* ====== FOOTER ====== */
.xgrid-chat-footer {
  padding: 10px;
  text-align: center;
  font-size: 10px;
  color: var(--xgrid-text-light);
  font-family: 'XgridSans', sans-serif !important;
  border-top: 1px solid rgba(111,99,222,0.1);
  background: var(--xgrid-white);
  flex-shrink: 0;
}

/* ====== EXIT POPUP ====== */
#xgrid-exit-overlay {
  position: fixed; inset: 0;
  background: rgba(45,43,78,0.5);
  z-index: 9999;
  display: none;
}
#xgrid-exit-overlay.xgrid-show { display: block; }

#xgrid-exit-popup {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: var(--xgrid-white);
  border: 1.5px solid rgba(111,99,222,0.25);
  border-radius: 20px;
  padding: 32px 28px;
  width: 340px;
  z-index: 10000;
  display: none;
  box-shadow: 0 32px 80px rgba(111,99,222,0.2), 0 8px 24px rgba(0,0,0,0.1);
  text-align: center;
}
#xgrid-exit-popup.xgrid-show {
  display: block;
  animation: xgrid-popIn 0.4s ease forwards;
}
@keyframes xgrid-popIn {
  from { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.xgrid-popup-tag { font-size: 10px; color: var(--xgrid-purple); font-family: 'XgridSans', sans-serif !important; letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 12px; }
.xgrid-popup-title { font-size: 17px; font-weight: 800; color: var(--xgrid-text); line-height: 1.4; margin-bottom: 20px; font-family: 'XgridSans', sans-serif !important; }
.xgrid-popup-title span { color: var(--xgrid-purple); }
.xgrid-popup-btns { display: flex; flex-direction: column; gap: 10px; }

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
  #xgrid-chat-launcher {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }

  #xgrid-chat-window {
    position: fixed;
    bottom: 80px;
    right: 12px;
    left: 12px;
    width: auto !important;
    max-height: 70vh !important;
    height: auto !important;
    border-radius: 16px;
  }

  .xgrid-chat-body {
    max-height: calc(70vh - 140px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .xgrid-nav-bar {
    flex-shrink: 0;
    padding: 10px 12px;
  }

  #xgrid-exit-popup { width: calc(100vw - 40px); }

  #xgrid-hs-modal {
    width: calc(100vw - 24px) !important;
    max-height: 85vh !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
  }
}
