/* ==========================================================
   COPYSTAR AI LIVE CHAT - ONEX EMERALD GREEN THEME
   Inspired by clean modern conversational interface
   ========================================================== */

:root {
  --chat-primary: #33b895;
  --chat-primary-hover: #289679;
  --chat-primary-dark: #207d64;
  --chat-header-bg: #33b895;
  --chat-header-title: #0a2218;
  --chat-header-sub: #0f3b29;
  --chat-header-icon: #0a2218;
  --chat-surface: #ffffff;
  --chat-bg: #ffffff;
  --chat-border: #e6ebf1;
  --chat-text: #0f172a;
  --chat-muted: #64748b;
  --chat-online: #33b895;
  --chat-user-bg: #33b895;
  --chat-user-text: #ffffff;
  --chat-bot-bg: #edf2f7;
  --chat-bot-text: #0f172a;
  --chat-shadow: 0 16px 40px rgba(0, 0, 0, 0.14), 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* Floating Launcher Button & Teaser Badge */
.chat-widget-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.chat-launcher-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

/* Teaser pill that invites the user */
.chat-teaser-pill {
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 24px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--chat-text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  animation: teaser-slide 0.5s ease;
}

.chat-teaser-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(51, 184, 149, 0.22);
  border-color: rgba(51, 184, 149, 0.5);
}

.chat-teaser-pill .teaser-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chat-online);
  box-shadow: 0 0 0 2px rgba(51, 184, 149, 0.35);
  animation: chat-pulse 1.8s infinite;
}

/* Round Floating Action Button */
.chat-launcher-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3cdbb2 0%, #289679 100%);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 24px rgba(51, 184, 149, 0.38), 0 2px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: grid;
  place-items: center;
  position: relative;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  padding: 0;
}

.chat-launcher-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 30px rgba(51, 184, 149, 0.48);
}

.chat-launcher-btn:active {
  transform: scale(0.96);
}

.chat-launcher-icon,
.chat-launcher-close {
  position: absolute;
  transition: all 0.22s ease;
  display: grid;
  place-items: center;
}

.chat-launcher-icon svg,
.chat-launcher-close svg {
  width: 26px;
  height: 26px;
  fill: #ffffff;
}

.chat-widget-container.is-open .chat-launcher-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

.chat-widget-container:not(.is-open) .chat-launcher-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

.chat-widget-container.is-open .chat-teaser-pill {
  display: none;
}

/* Chat Popup Window */
.chat-window {
  position: absolute;
  bottom: 74px;
  right: 0;
  width: 385px;
  max-width: calc(100vw - 32px);
  height: 590px;
  max-height: calc(100vh - 110px);
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-widget-container.is-open .chat-window {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Window Header - Vibrant Emerald Green */
.chat-header {
  background: var(--chat-header-bg);
  color: var(--chat-header-title);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Round White Avatar with Logo & Online Status Dot */
.chat-header-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  padding: 3px;
  box-sizing: border-box;
}

.chat-header-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.chat-avatar-status {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #33b895;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.chat-header-title h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--chat-header-title);
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.chat-header-title p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--chat-header-sub);
  font-weight: 500;
  line-height: 1.2;
}

/* Header Icons (Bell, WhatsApp, Close) */
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header-btn {
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: var(--chat-header-icon);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.18s;
  padding: 0;
  font-size: 14px;
  text-decoration: none;
}

.chat-header-btn:hover {
  background: rgba(0, 0, 0, 0.12);
  transform: scale(1.05);
}

.chat-header-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.chat-header-btn.wa-btn {
  color: #044d2d;
}

/* Language Toggle Bar */
.chat-lang-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--chat-border);
  font-size: 11px;
  flex-shrink: 0;
}

.chat-lang-label {
  color: #64748b;
  font-size: 11px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-lang-switch {
  display: flex;
  background: #e2e8f0;
  border-radius: 14px;
  padding: 2px;
  gap: 2px;
}

.chat-lang-btn {
  background: transparent;
  border: none;
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.16s ease;
  font-family: inherit;
}

.chat-lang-btn:hover {
  color: #0f172a;
}

.chat-lang-btn.active {
  background: var(--chat-primary);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(51, 184, 149, 0.35);
}

/* Chat Messages Area */
.chat-messages {
  flex: 1;
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: #ffffff;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* Centered Date Badge (e.g. "Today") */
.chat-date-pill {
  align-self: center;
  background: #edf2f7;
  color: #64748b;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 16px;
  margin: 4px auto 10px;
}

/* Individual Messages */
.chat-msg-row {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: msg-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  align-items: flex-end;
}

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

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

/* Small Bot Avatar beside message */
.chat-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  padding: 2px;
  box-sizing: border-box;
}

.chat-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

/* Message Bubble */
.chat-msg-bubble {
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.chat-msg-row.bot .chat-msg-bubble {
  background: var(--chat-bot-bg);
  color: var(--chat-bot-text);
  border-bottom-left-radius: 4px;
}

.chat-msg-row.user .chat-msg-bubble {
  background: var(--chat-user-bg);
  color: var(--chat-user-text);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(51, 184, 149, 0.25);
}

.chat-msg-time {
  font-size: 9.5px;
  color: var(--chat-muted);
  margin-top: 5px;
  text-align: right;
  opacity: 0.8;
}

.chat-msg-row.user .chat-msg-time {
  color: rgba(255, 255, 255, 0.85);
}

/* Quick Action Suggestion Chips */
.chat-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.chat-chip {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #334155;
  padding: 7px 12px;
  border-radius: 18px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.chat-chip:hover {
  background: #e6f9f3;
  border-color: #33b895;
  color: #207d64;
  transform: translateY(-1px);
}

/* In-Chat Contact / Enquiry Card (EmailJS Form) */
.chat-contact-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 3px solid var(--chat-primary);
  border-radius: 14px;
  padding: 13px;
  margin-top: 6px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.06);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 100%;
}

.chat-card-header {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  color: var(--chat-text);
  font-size: 12.5px;
}

.chat-card-header span {
  font-size: 16px;
}

.chat-card-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-card-field label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--chat-muted);
}

.chat-card-field input,
.chat-card-field textarea {
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--chat-text);
  font-family: inherit;
  transition: border-color 0.18s;
  width: 100%;
  box-sizing: border-box;
}

.chat-card-field input:focus,
.chat-card-field textarea:focus {
  border-color: var(--chat-primary);
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(51, 184, 149, 0.2);
}

.chat-card-submit {
  background: var(--chat-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 3px;
}

.chat-card-submit:hover:not(:disabled) {
  background: var(--chat-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(51, 184, 149, 0.35);
}

.chat-card-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-card-footnote {
  font-size: 9.5px;
  color: #94a3b8;
  margin: 0;
  text-align: center;
}

.chat-success-box {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.chat-success-title {
  color: #15803d;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
}

.chat-success-desc {
  font-size: 11px;
  color: #166534;
  margin: 0 0 8px;
  line-height: 1.4;
}

.chat-direct-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.chat-direct-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.18s;
}

.chat-direct-btn.wa {
  background: #25d366;
  color: #ffffff;
}
.chat-direct-btn.wa:hover {
  background: #1da851;
}

.chat-direct-btn.call {
  background: #0f172a;
  color: #ffffff;
}
.chat-direct-btn.call:hover {
  background: #1e293b;
}

/* Typing Indicator */
.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: #edf2f7;
  border-radius: 14px;
  align-self: flex-start;
  margin-left: 34px;
  width: fit-content;
}

.chat-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #33b895;
  animation: typing-bounce 1.3s infinite ease-in-out;
}

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

/* Input Footer */
.chat-footer {
  padding: 11px 14px;
  background: #ffffff;
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 9px 15px;
  font-size: 13px;
  outline: none;
  color: var(--chat-text);
  background: #f8fafc;
  font-family: inherit;
  transition: all 0.18s;
}

.chat-input:focus {
  border-color: var(--chat-primary);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(51, 184, 149, 0.18);
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--chat-primary);
  color: #fff;
  border: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.18s;
  flex-shrink: 0;
  padding: 0;
}

.chat-send-btn:hover {
  background: var(--chat-primary-hover);
  transform: scale(1.06);
}

.chat-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.chat-send-btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

/* Animations */
@keyframes teaser-slide {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

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

@keyframes chat-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .chat-widget-container {
    bottom: 16px;
    right: 14px;
  }
  .chat-window {
    width: calc(100vw - 28px);
    right: -4px;
    bottom: 68px;
    height: 520px;
    max-height: calc(100vh - 90px);
  }
  .chat-teaser-pill {
    font-size: 11px;
    padding: 6px 10px;
  }
  .chat-launcher-btn {
    width: 52px;
    height: 52px;
  }
}
