/* ─── Guyven Chat Widget — Modern Professional Design ────────────────────── */

/* Bubble toggle button — bottom right */
#guyven-chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0F3460 0%, #1a4e8a 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(15,52,96,.40), 0 1px 4px rgba(15,52,96,.20);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .22s;
  outline: none;
}
#guyven-chat-bubble:hover {
  transform: scale(1.09);
  box-shadow: 0 8px 32px rgba(15,52,96,.50), 0 2px 8px rgba(15,52,96,.25);
}
#guyven-chat-bubble:focus-visible {
  box-shadow: 0 0 0 3px rgba(240,78,35,.6);
}
#guyven-chat-bubble svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  transition: opacity .18s, transform .22s;
}
#guyven-chat-bubble .close-icon { display: none; }
#guyven-chat-bubble.open .chat-icon  { display: none; }
#guyven-chat-bubble.open .close-icon { display: block; }
#guyven-chat-bubble.open { box-shadow: 0 4px 20px rgba(15,52,96,.35); }

/* Presence dot */
#guyven-chat-bubble::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 13px;
  height: 13px;
  background: #22c55e;
  border: 2.5px solid #fff;
  border-radius: 50%;
  animation: gc-pulse 2.8s ease-in-out infinite;
}
#guyven-chat-bubble.open::after { display: none; }

@keyframes gc-pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .7; transform: scale(.9); }
}

/* Proactive tooltip */
#guyven-proactive-tip {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9997;
  max-width: 230px;
  background: #0F3460;
  color: #fff;
  font-family: Inter, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 14px;
  border-radius: 12px 12px 4px 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,.20);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}
#guyven-proactive-tip.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#guyven-proactive-tip::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 22px;
  border: 4px solid transparent;
  border-top-color: #0F3460;
}

/* Chat panel — bottom right */
#guyven-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9999;
  width: 370px;
  max-height: 560px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.16), 0 4px 16px rgba(0,0,0,.08);
  font-family: Inter, sans-serif;
  overflow: hidden;
  transform: scale(.93) translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .22s ease;
  transform-origin: bottom right;
}
#guyven-chat-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Panel header */
.gc-header {
  background: linear-gradient(135deg, #0b2d56 0%, #0F3460 60%, #1a4e8a 100%);
  color: #fff;
  padding: 16px 18px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
  position: relative;
}
.gc-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: rgba(255,255,255,.08);
}
.gc-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  border: 1.5px solid rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.gc-avatar img { width: 28px; height: 28px; object-fit: contain; }
.gc-agent-info { flex: 1; min-width: 0; }
.gc-agent-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .01em;
  color: #fff;
}
.gc-status {
  font-size: 11px;
  color: rgba(255,255,255,.75);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.gc-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px rgba(74,222,128,.6);
  animation: gc-pulse 2.8s ease-in-out infinite;
}
.gc-header-actions { display: flex; gap: 2px; margin-left: auto; }
.gc-header-btn {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.8);
  cursor: pointer;
  padding: 5px;
  border-radius: 8px;
  line-height: 1;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gc-header-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.gc-header-btn svg { width: 16px; height: 16px; fill: currentColor; }

/* Messages */
.gc-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* iOS momentum scroll */
  overscroll-behavior: contain;      /* prevent page scroll while scrolling chat */
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: #f9fafb;
  /* Firefox scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #dde3ec transparent;
}
.gc-messages::-webkit-scrollbar { width: 4px; }
.gc-messages::-webkit-scrollbar-track { background: transparent; }
.gc-messages::-webkit-scrollbar-thumb { background: #dde3ec; border-radius: 4px; }

/* Message bubbles */
.gc-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: gc-msg-in .2s ease;
}
@keyframes gc-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.gc-msg.bot { align-self: flex-start; }
.gc-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.gc-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e8edf5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  align-self: flex-end;
  border: 1px solid rgba(15,52,96,.08);
}
.gc-msg-avatar img { width: 20px; height: 20px; object-fit: contain; }
.gc-bubble {
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  color: #1e293b;
}
.gc-msg.bot .gc-bubble {
  background: #fff;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  border: 1px solid rgba(0,0,0,.05);
}
.gc-msg.user .gc-bubble {
  background: linear-gradient(135deg, #0F3460 0%, #1a4e8a 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(15,52,96,.25);
}
.gc-bubble a { color: inherit; text-decoration: underline; opacity: .85; }
.gc-bubble a:hover { opacity: 1; }
.gc-bubble strong { font-weight: 600; }

/* Typing indicator */
.gc-typing .gc-bubble {
  background: #fff;
  border: 1px solid rgba(0,0,0,.05);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  padding: 13px 16px;
}
.gc-dots { display: flex; gap: 5px; align-items: center; }
.gc-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: gc-dot-bounce 1s ease-in-out infinite;
}
.gc-dots span:nth-child(2) { animation-delay: .16s; }
.gc-dots span:nth-child(3) { animation-delay: .32s; }
@keyframes gc-dot-bounce {
  0%,80%,100% { transform: translateY(0); opacity: .5; }
  40%          { transform: translateY(-7px); opacity: 1; }
}

/* Quick replies */
.gc-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px 12px;
  flex-shrink: 0;
  background: #f9fafb;
  border-top: 1px solid #f0f3f8;
}
.gc-qr-btn {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1.5px solid #c7d4e8;
  background: #fff;
  color: #0F3460;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
  font-family: Inter, sans-serif;
  font-weight: 500;
  white-space: nowrap;
}
.gc-qr-btn:hover {
  background: #0F3460;
  border-color: #0F3460;
  color: #fff;
  transform: translateY(-1px);
}
.gc-qr-btn:active { transform: translateY(0); }

/* Lead capture form */
.gc-lead-form {
  padding: 12px 14px;
  background: #f0f5ff;
  border-top: 1px solid #dde8f8;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.gc-lead-form p {
  font-size: 12px;
  color: #475569;
  margin: 0;
  font-weight: 500;
}
.gc-lead-form input {
  border: 1.5px solid #dde3ec;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: Inter, sans-serif;
  color: #1e293b;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.gc-lead-form input:focus {
  border-color: #0F3460;
  box-shadow: 0 0 0 3px rgba(15,52,96,.1);
}
.gc-lead-submit {
  background: #F04E23;
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: Inter, sans-serif;
  transition: background .15s, transform .1s;
  letter-spacing: .01em;
}
.gc-lead-submit:hover { background: #d94018; transform: translateY(-1px); }
.gc-lead-submit:active { transform: translateY(0); }

/* Input bar */
.gc-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #eef0f5;
  flex-shrink: 0;
  background: #fff;
}
.gc-input-bar input {
  flex: 1;
  border: 1.5px solid #dde3ec;
  border-radius: 22px;
  padding: 9px 15px;
  font-size: 13px;
  font-family: Inter, sans-serif;
  outline: none;
  color: #1e293b;
  background: #f9fafb;
  transition: border-color .15s, box-shadow .15s;
}
.gc-input-bar input:focus {
  border-color: #0F3460;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15,52,96,.08);
}
.gc-input-bar input::placeholder { color: #94a3b8; }
.gc-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #F04E23;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .15s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(240,78,35,.30);
}
.gc-send-btn:hover {
  background: #d94018;
  transform: scale(1.07);
  box-shadow: 0 4px 12px rgba(240,78,35,.40);
}
.gc-send-btn:active { transform: scale(.97); }
.gc-send-btn svg { width: 16px; height: 16px; fill: #fff; }

/* Escalate link */
.gc-escalate-btn {
  font-size: 11px;
  color: #94a3b8;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 12px 8px;
  text-align: center;
  width: 100%;
  transition: color .15s;
  font-family: Inter, sans-serif;
  letter-spacing: .01em;
  background: #fff;
}
.gc-escalate-btn:hover { color: #0F3460; }

/* iOS: prevent double-tap zoom on all interactive elements */
#guyven-chat-bubble,
.gc-send-btn,
.gc-quick-btn,
.gc-escalate-btn,
.gc-header-btn,
.gc-lead-submit {
  touch-action: manipulation;
}

/* Mobile */
@media (max-width: 480px) {
  #guyven-chat-panel {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 84px;
    max-height: 72vh;
    border-radius: 16px;
  }
  #guyven-chat-bubble { right: 14px; bottom: 14px; }
  #guyven-proactive-tip { right: 80px; bottom: 22px; max-width: 200px; }
}
