/* ============================================================
   GRAPHIQUEHUB CHATBOT WIDGET — chatbot.css
   Completely isolated. Zero conflict with existing styles.
   All selectors prefixed with .gh-chat- or #gh-chat-
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');

/* ── Floating Trigger Button ───────────────────────────────── */
#gh-chat-trigger {
  position: fixed;
  bottom: 100px;           /* sits above the scroll btn */
  right: 30px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 9998;
  padding: 0;
  background: transparent;
  outline: none;

  /* Gradient border via pseudo-element */
  display: flex;
  align-items: center;
  justify-content: center;

  animation: gh-float 3s ease-in-out infinite;
  transition: transform 0.2s ease;
  filter: drop-shadow(0 6px 20px rgba(90, 60, 200, 0.45));
}

#gh-chat-trigger:hover {
  animation: gh-bounce 0.5s ease;
  filter: drop-shadow(0 8px 28px rgba(90, 60, 200, 0.65));
}

/* The actual SVG bubble+robot icon */
#gh-chat-trigger svg {
  width: 60px;
  height: 60px;
}

/* Unread badge */
#gh-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: #ff4757;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
  animation: gh-pulse-badge 1.5s ease-in-out infinite;
}
#gh-chat-badge.visible { display: block; }

/* ── Keyframes ─────────────────────────────────────────────── */
@keyframes gh-float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-6px); }
}

@keyframes gh-bounce {
  0%, 100% { transform: scale(1); }
  30%       { transform: scale(1.18) translateY(-4px); }
  60%       { transform: scale(0.94) translateY(2px); }
}

@keyframes gh-pulse-badge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,71,87,0.6); }
  50%       { box-shadow: 0 0 0 5px rgba(255,71,87,0); }
}

@keyframes gh-slide-up {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes gh-slide-down {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(24px) scale(0.97); }
}

@keyframes gh-typing-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

@keyframes gh-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Chat Window ───────────────────────────────────────────── */
#gh-chat-window {
  position: fixed;
  bottom: 170px;           /* above trigger */
  right: 30px;
  width: 360px;
  max-height: 520px;
  border-radius: 20px;
  overflow: hidden;
  z-index: 9997;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 24px 60px rgba(0,0,0,0.22),
    0 6px 20px rgba(90,60,200,0.15);
  font-family: 'Poppins', sans-serif;
  background: #ffffff;

  opacity: 0;
  pointer-events: none;
  transform: translateY(24px) scale(0.97);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

#gh-chat-window.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* ── Header ────────────────────────────────────────────────── */
.gh-chat-header {
  background: linear-gradient(135deg, #5B5FEE 0%, #7C3AED 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}

.gh-chat-header-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.gh-chat-header-logo img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

/* Fallback SVG logo if image fails */
.gh-chat-header-logo svg {
  width: 22px;
  height: 22px;
}

.gh-chat-header-info {
  flex: 1;
}

.gh-chat-header-title {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.gh-chat-header-sub {
  color: rgba(255,255,255,0.75);
  font-size: 11px;
  margin-top: 2px;
}

.gh-chat-close-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
  font-size: 16px;
  line-height: 1;
}

.gh-chat-close-btn:hover {
  background: rgba(255,255,255,0.28);
}

/* Online indicator dot */
.gh-online-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  box-shadow: 0 0 0 2px rgba(74,222,128,0.3);
  animation: gh-pulse-badge 2s ease-in-out infinite;
}

/* ── Messages Body ─────────────────────────────────────────── */
.gh-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7f8fc;
  min-height: 0;
  max-height: 340px;
  scroll-behavior: smooth;
}

.gh-chat-body::-webkit-scrollbar { width: 4px; }
.gh-chat-body::-webkit-scrollbar-track { background: transparent; }
.gh-chat-body::-webkit-scrollbar-thumb { background: #d0d5e8; border-radius: 4px; }

/* ── Message Bubbles ───────────────────────────────────────── */
.gh-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: gh-msg-in 0.28s ease forwards;
  max-width: 100%;
}

.gh-msg.bot  { justify-content: flex-start; }
.gh-msg.user { justify-content: flex-end; }

.gh-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5B5FEE, #7C3AED);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  overflow: hidden;
}

.gh-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gh-msg-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.gh-msg.bot .gh-msg-bubble {
  background: #fff;
  color: #2d3354;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.gh-msg.user .gh-msg-bubble {
  background: linear-gradient(135deg, #5B5FEE 0%, #7C3AED 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(91,95,238,0.35);
}

.gh-msg-time {
  font-size: 10px;
  color: #a0a5bd;
  margin-top: 3px;
  text-align: right;
}

.gh-msg.bot .gh-msg-time { text-align: left; padding-left: 36px; }
.gh-msg.user .gh-msg-time { text-align: right; }

/* ── Typing Indicator ──────────────────────────────────────── */
.gh-typing-indicator {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.gh-typing-dots {
  background: #fff;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.gh-typing-dots span {
  width: 7px;
  height: 7px;
  background: #a0a5bd;
  border-radius: 50%;
  animation: gh-typing-dot 1.2s ease-in-out infinite;
}
.gh-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.gh-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ── Input Area ────────────────────────────────────────────── */
.gh-chat-footer {
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid #eef0f7;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

#gh-chat-input {
  flex: 1;
  border: 1.5px solid #e8eaf6;
  border-radius: 14px;
  padding: 10px 14px;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  color: #2d3354;
  background: #f7f8fc;
  outline: none;
  resize: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 40px;
  max-height: 100px;
  line-height: 1.4;
}

#gh-chat-input::placeholder { color: #b0b5cc; }

#gh-chat-input:focus {
  border-color: #7C3AED;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

#gh-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #5B5FEE, #7C3AED);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(91,95,238,0.4);
}

#gh-chat-send:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 18px rgba(91,95,238,0.5);
}

#gh-chat-send:active { transform: scale(0.95); }

#gh-chat-send svg {
  width: 18px;
  height: 18px;
}

/* ── Error message ─────────────────────────────────────────── */
.gh-msg-error .gh-msg-bubble {
  background: #fff0f0;
  color: #cc3333;
  font-size: 12px;
}

/* ── Mobile Responsive ─────────────────────────────────────── */
@media (max-width: 480px) {
  #gh-chat-window {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 160px;
    max-height: 70vh;
  }

  #gh-chat-trigger {
    right: 20px;
    bottom: 90px;
  }
}

/* ── Mic Button ────────────────────────────────────────────── */
#gh-chat-mic {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1.5px solid #e8eaf6;
  background: #f7f8fc;
  color: #7C3AED;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

#gh-chat-mic svg {
  width: 17px;
  height: 17px;
}

#gh-chat-mic:hover {
  background: #ede9fe;
  border-color: #7C3AED;
}

/* Active/listening state */
#gh-chat-mic.gh-mic-active {
  background: linear-gradient(135deg, #5B5FEE, #7C3AED);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.2);
  animation: gh-mic-pulse 1s ease-in-out infinite;
}

@keyframes gh-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.2); }
  50%       { box-shadow: 0 0 0 8px rgba(124, 58, 237, 0.05); }
}

/* ── Fullscreen Button ─────────────────────────────────────── */
.gh-chat-fullscreen-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
  margin-right: 6px;
}

.gh-chat-fullscreen-btn:hover {
  background: rgba(255,255,255,0.28);
}

/* ── Fullscreen Mode ───────────────────────────────────────── */
#gh-chat-window.gh-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100% !important;
  max-height: 100% !important;
  height: 100%;
  border-radius: 0;
  z-index: 99999;
}

#gh-chat-window.gh-fullscreen .gh-chat-body {
  max-height: none;
  flex: 1;
}

@media (max-width: 480px) {
  #gh-chat-window.gh-fullscreen {
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
  }
}

/* ── Speech Bubble Tooltip ─────────────────────────────────── */
#gh-chat-tooltip {
  position: fixed;
  bottom: 172px;
  right: 30px;
  background: #fff;
  color: #2d3354;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 18px;
  border-bottom-right-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border: 1px solid #eef0f7;
  pointer-events: none;
  z-index: 99999;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#gh-chat-tooltip::after {
  content: "";
  position: absolute;
  bottom: -10px;
  right: 18px;
  border-width: 10px 8px 0 8px;
  border-style: solid;
  border-color: #fff transparent transparent transparent;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.08));
}

#gh-chat-tooltip {
  animation: gh-tooltip-bounce 6s ease-in-out infinite;
}

#gh-chat-tooltip.hidden {
  opacity: 0 !important;
  transform: translateY(8px) scale(0.95) !important;
  animation: none !important;
}

@keyframes gh-tooltip-bounce {
  0%   { transform: translateY(0) scale(1); }
  10%  { transform: translateY(-6px) scale(1.03); }
  20%  { transform: translateY(0) scale(1); }
  28%  { transform: translateY(-4px) scale(1.02); }
  36%  { transform: translateY(0) scale(1); }
  100% { transform: translateY(0) scale(1); }
}
