/* Gravit8 Chat Widget */

#g8-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
}

/* ── Toggle button ───────────────────────────────────────── */

#g8-chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #CC2222;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  transition: background 0.2s, transform 0.2s;
  outline: none;
}

#g8-chat-toggle:hover {
  background: #aa1a1a;
  transform: scale(1.06);
}

#g8-chat-toggle svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  pointer-events: none;
}

/* Pulse animation — removed via JS after first click */
#g8-chat-toggle.g8-pulse {
  animation: g8-pulse-ring 2s ease-out infinite;
}

@keyframes g8-pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(204, 34, 34, 0.55); }
  70%  { box-shadow: 0 0 0 14px rgba(204, 34, 34, 0); }
  100% { box-shadow: 0 0 0 0 rgba(204, 34, 34, 0); }
}

/* ── Chat panel ──────────────────────────────────────────── */

#g8-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 320px;
  height: 460px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

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

/* ── Header ──────────────────────────────────────────────── */

#g8-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #0A0A0A;
  color: #fff;
  flex-shrink: 0;
}

#g8-chat-header-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
}

#g8-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  padding: 2px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  outline: none;
}

#g8-chat-close:hover {
  color: #fff;
}

#g8-chat-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ── Message area ────────────────────────────────────────── */

#g8-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

/* Minimal scrollbar */
#g8-chat-messages::-webkit-scrollbar {
  width: 4px;
}
#g8-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
#g8-chat-messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 2px;
}

/* ── Message bubbles ─────────────────────────────────────── */

.g8-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.g8-msg-bot {
  align-self: flex-start;
}

.g8-msg-user {
  align-self: flex-end;
}

.g8-msg-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  font-size: 13px;
}

.g8-msg-bot .g8-msg-bubble {
  background: #F5F5F5;
  color: #222;
  border-bottom-left-radius: 4px;
}

.g8-msg-user .g8-msg-bubble {
  background: #CC2222;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Typing indicator ────────────────────────────────────── */

.g8-typing {
  align-self: flex-start;
  padding: 10px 14px;
  background: #F5F5F5;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.g8-typing span {
  width: 7px;
  height: 7px;
  background: #aaa;
  border-radius: 50%;
  display: inline-block;
  animation: g8-bounce 1.2s infinite ease-in-out;
}

.g8-typing span:nth-child(2) { animation-delay: 0.18s; }
.g8-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes g8-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}

/* ── Input bar ───────────────────────────────────────────── */

#g8-chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #efefef;
  background: #fff;
  flex-shrink: 0;
}

#g8-chat-input {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  color: #222;
  outline: none;
  background: #fafafa;
  transition: border-color 0.15s;
  font-family: inherit;
  resize: none;
}

#g8-chat-input:focus {
  border-color: #CC2222;
  background: #fff;
}

#g8-chat-input::placeholder {
  color: #bbb;
}

#g8-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #CC2222;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  outline: none;
  align-self: flex-end;
}

#g8-chat-send:hover {
  background: #aa1a1a;
}

#g8-chat-send:active {
  transform: scale(0.93);
}

#g8-chat-send:disabled {
  background: #e0e0e0;
  cursor: not-allowed;
}

#g8-chat-send svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Mobile ──────────────────────────────────────────────── */

@media (max-width: 480px) {
  #g8-chat-widget {
    bottom: 16px;
    right: 16px;
  }

  #g8-chat-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 75dvh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  #g8-chat-panel.g8-open {
    transform: translateY(0);
  }
}
