/* ========================================================
   GUAN YAO PRECISION MOULD - AI SALES REPRESENTATIVE
   Engineered for Maximum Conversions, Perfectly Centered & Responsive
======================================================== */

#gy-sales-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999990;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  box-sizing: border-box;
}

#gy-sales-widget * {
  box-sizing: border-box;
}

/* Proactive Greeting Bubble */
.gy-agent-bubble {
  position: absolute;
  bottom: 82px;
  right: 0;
  width: 330px;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: 0 16px 45px rgba(15, 23, 42, 0.22), 0 2px 10px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(226, 232, 240, 0.95);
  cursor: pointer;
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 999991;
}

.gy-agent-bubble.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.gy-bubble-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 24px;
  height: 24px;
  border: none;
  background: #f1f5f9;
  border-radius: 50%;
  color: #64748b;
  font-size: 15px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s;
}

.gy-bubble-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.gy-bubble-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.gy-bubble-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #0284c7;
  flex-shrink: 0;
}

.gy-bubble-info h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
  color: #0f172a;
  line-height: 1.2;
}

.gy-bubble-info p {
  margin: 3px 0 0 0;
  font-size: 11.5px;
  color: #16a34a;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

.gy-bubble-info p::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: gy-pulse 1.8s infinite;
}

.gy-bubble-text {
  font-size: 13.5px;
  line-height: 1.5;
  color: #334155;
  margin: 0 0 12px 0;
}

.gy-bubble-prompts {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.gy-bubble-prompts button {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #0369a1;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gy-bubble-prompts button:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

/* Floating Trigger Button */
.gy-agent-trigger {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: 3.5px solid #ffffff;
  box-shadow: 0 12px 30px rgba(2, 132, 199, 0.45), 0 4px 12px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
}

.gy-agent-trigger:hover {
  transform: scale(1.07);
  box-shadow: 0 16px 36px rgba(2, 132, 199, 0.6);
}

.gy-agent-trigger-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.gy-agent-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 17px;
  height: 17px;
  background: #22c55e;
  border: 2.5px solid #ffffff;
  border-radius: 50%;
  animation: gy-pulse 2s infinite;
}

@keyframes gy-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 9px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Full Chat Panel */
.gy-chat-panel {
  position: absolute;
  bottom: 84px;
  right: 0;
  width: 440px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 24px 65px rgba(15, 23, 42, 0.28), 0 4px 16px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(226, 232, 240, 0.95);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 999992;
}

.gy-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Panel Header */
.gy-chat-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.gy-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gy-header-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #38bdf8;
  flex-shrink: 0;
}

.gy-header-meta h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 750;
  color: #ffffff;
  letter-spacing: 0.2px;
}

.gy-header-meta span {
  display: block;
  font-size: 11.5px;
  color: #94a3b8;
  margin-top: 1px;
}

.gy-header-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #4ade80;
  font-weight: 600;
  margin-top: 2px;
}

.gy-header-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}

.gy-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gy-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  font-size: 15px;
  transition: all 0.2s;
}

.gy-action-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.gy-action-btn.whatsapp {
  background: #25D366;
  color: #ffffff;
}

.gy-action-btn.whatsapp:hover {
  background: #20bd5a;
}

/* Notice Strip */
.gy-notice-strip {
  background: #f0fdf4;
  border-bottom: 1px solid #dcfce7;
  padding: 8px 16px;
  font-size: 12px;
  color: #166534;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.gy-notice-strip a {
  color: #0369a1;
  font-weight: 700;
  text-decoration: none;
}

.gy-notice-strip a:hover {
  text-decoration: underline;
}

/* Chat History Area */
.gy-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f8fafc;
}

.gy-chat-messages::-webkit-scrollbar {
  width: 5px;
}

.gy-chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Centered Top Welcome Card */
.gy-welcome-badge {
  text-align: center;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  margin: 0 auto 6px;
  width: 100%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.gy-welcome-badge strong {
  display: block;
  font-size: 12px;
  color: #0f172a;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.gy-welcome-badge span {
  font-size: 11px;
  color: #64748b;
}

/* Message Rows */
.gy-msg {
  display: flex;
  gap: 10px;
  width: 100%;
  animation: gy-msg-in 0.25s ease-out;
}

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

.gy-msg.agent {
  align-self: flex-start;
}

.gy-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.gy-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
  border: 1.5px solid #0284c7;
}

.gy-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  max-width: 88%;
}

.gy-msg.agent .gy-msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-top-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.gy-msg.user .gy-msg-bubble {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.gy-msg-time {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 5px;
  text-align: right;
}

.gy-msg.user .gy-msg-time {
  color: #dbeafe;
}

/* ========================================================
   CENTERED GUIDED ASSISTANCE CARDS (Fixes off-center issue)
======================================================== */
.gy-guided-box {
  width: 100%;
  margin: 10px 0;
  background: #ffffff;
  border: 1.5px solid #e0e7ff;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  text-align: center;
}

.gy-guided-step-badge {
  display: inline-block;
  background: #eff6ff;
  color: #0284c7;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.gy-guided-title {
  font-size: 13.5px;
  font-weight: 750;
  color: #0f172a;
  margin: 0 0 10px 0;
  line-height: 1.35;
}

.gy-guided-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
}

.gy-guided-opt-btn {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.gy-guided-opt-btn:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  transform: translateX(2px);
}

.gy-guided-opt-btn span.arrow {
  color: inherit;
  font-size: 13px;
  opacity: 0.7;
}

/* Centered Lead & Quotation Form Card */
.gy-lead-card {
  width: 100%;
  background: #ffffff;
  border: 1.5px solid #fed7aa;
  border-radius: 14px;
  padding: 16px;
  margin: 10px 0 0;
  box-shadow: 0 6px 18px rgba(255, 122, 0, 0.1);
  text-align: center;
}

.gy-lead-card-header {
  margin-bottom: 12px;
}

.gy-lead-card-header h5 {
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 800;
  color: #9a3412;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.gy-lead-card-header p {
  margin: 0;
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

.gy-lead-form-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.gy-lead-form-fields input,
.gy-lead-form-fields textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  background: #f8fafc;
  color: #0f172a;
  transition: all 0.2s;
}

.gy-lead-form-fields input:focus,
.gy-lead-form-fields textarea:focus {
  outline: none;
  background: #ffffff;
  border-color: #ea580c;
  box-shadow: 0 0 0 2.5px rgba(234, 88, 12, 0.15);
}

.gy-lead-card-btn {
  width: 100%;
  background: linear-gradient(135deg, #ff7a00 0%, #ea580c 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 13.5px;
  font-weight: 750;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(255, 122, 0, 0.3);
  margin-top: 4px;
}

.gy-lead-card-btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

/* Typing Indicator */
.gy-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  border-top-left-radius: 4px;
  width: fit-content;
}

.gy-typing span {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: gy-typing-dot 1.2s infinite ease-in-out;
}

.gy-typing span:nth-child(2) { animation-delay: 0.2s; }
.gy-typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* Input Area */
.gy-chat-input-area {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.gy-chat-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-family: inherit;
  color: #0f172a;
  outline: none;
  background: #f8fafc;
  transition: all 0.2s;
}

.gy-chat-input:focus {
  background: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.gy-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0284c7;
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.gy-send-btn:hover {
  background: #0369a1;
  transform: scale(1.05);
}

.gy-send-btn svg {
  width: 19px;
  height: 19px;
  margin-left: 2px;
}

/* Footer Tagline */
.gy-chat-footer-note {
  text-align: center;
  font-size: 10.5px;
  color: #94a3b8;
  padding: 6px 0 9px;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #gy-sales-widget {
    bottom: 74px; /* Float above mobile sticky bottom bar */
    right: 12px;
  }
  .gy-agent-trigger {
    width: 60px;
    height: 60px;
  }
  .gy-agent-bubble {
    width: calc(100vw - 28px);
    bottom: 72px;
    right: 0;
    padding: 14px 16px;
  }
  .gy-chat-panel {
    bottom: 72px;
    right: 0;
    width: calc(100vw - 24px);
    height: calc(100vh - 150px);
  }
}
