/* =============================================================
   GTB Chat Widget
   Uses the site theme's --lb-* CSS variables when present, with
   fallback values baked in so it still looks right on any theme.
   ============================================================= */

#gtbcw-chat-root {
  --gc-primary: var(--lb-primary, #84BD3F);
  --gc-primary-dark: var(--lb-primary-dark, #699A2F);
  --gc-ink: var(--lb-ink, #232B22);
  --gc-muted: var(--lb-muted, #5C665A);
  --gc-bg: var(--lb-bg, #FAF9F5);
  --gc-surface: #FFFFFF;
  --gc-line: var(--lb-line, #E2E0D5);
  --gc-danger: var(--lb-danger, #C6503D);
  --gc-font: var(--lb-font-body, 'Open Sans', system-ui, sans-serif);
  --gc-heading-font: var(--lb-font-heading, 'Poppins', system-ui, sans-serif);

  position: fixed;
  z-index: 99999;
  left: clamp(14px, 3vw, 28px);
  bottom: clamp(14px, 3vw, 28px);
  font-family: var(--gc-font);
}

.gc-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gc-primary) 0%, var(--gc-primary-dark) 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 26px rgba(35, 43, 34, .28);
  transition: transform .15s ease, box-shadow .15s ease;
}

.gc-bubble:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(35, 43, 34, .34); }
.gc-bubble svg { width: 26px; height: 26px; }
.gc-bubble .gc-icon-close { display: none; }
.gc-bubble.is-open .gc-icon-chat { display: none; }
.gc-bubble.is-open .gc-icon-close { display: block; }

.gc-bubble__badge {
  position: absolute;
  top: -3px;
  left: -3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gc-danger);
  border: 2px solid var(--gc-surface);
}

.gc-panel {
  position: absolute;
  left: 0;
  bottom: 74px;
  width: min(360px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 120px));
  background: var(--gc-surface);
  border-radius: 16px;
  border: 1px solid var(--gc-line);
  box-shadow: 0 24px 60px rgba(35, 43, 34, .22);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.gc-panel.is-open { display: flex; animation: gc-panel-in .18s ease; }

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

.gc-panel__header {
  background: linear-gradient(135deg, var(--gc-primary) 0%, var(--gc-primary-dark) 100%);
  color: #fff;
  padding: .95rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .7rem;
  flex-shrink: 0;
}

.gc-panel__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.gc-panel__avatar svg { width: 19px; height: 19px; }

.gc-panel__title { font-family: var(--gc-heading-font); font-weight: 700; font-size: .95rem; margin: 0; }
.gc-panel__subtitle { font-size: .76rem; opacity: .9; margin: 0; }

.gc-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  background: var(--gc-bg);
}

.gc-msg {
  max-width: 86%;
  font-size: .86rem;
  line-height: 1.45;
  padding: .6rem .85rem;
  border-radius: 12px;
  animation: gc-msg-in .15s ease;
}

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

.gc-msg--bot {
  align-self: flex-start;
  background: var(--gc-surface);
  border: 1px solid var(--gc-line);
  color: var(--gc-ink);
  border-bottom-left-radius: 4px;
}

.gc-msg--user {
  align-self: flex-end;
  background: var(--gc-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.gc-quick-replies {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  align-self: stretch;
}

.gc-quick-reply {
  text-align: left;
  background: var(--gc-surface);
  border: 1px solid var(--gc-line);
  color: var(--gc-ink);
  font-family: var(--gc-font);
  font-size: .82rem;
  font-weight: 600;
  border-radius: 9px;
  padding: .6rem .8rem;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.gc-quick-reply:hover { border-color: var(--gc-primary); background: color-mix(in srgb, var(--gc-primary) 10%, var(--gc-surface)); }

.gc-quick-reply--cta {
  background: var(--gc-primary);
  border-color: var(--gc-primary);
  color: #fff;
}
.gc-quick-reply--cta:hover { background: var(--gc-primary-dark); border-color: var(--gc-primary-dark); }

.gc-panel__footer {
  border-top: 1px solid var(--gc-line);
  padding: .65rem .85rem;
  flex-shrink: 0;
  background: var(--gc-surface);
}

.gc-restart {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--gc-muted);
  font-size: .78rem;
  font-family: var(--gc-font);
  cursor: pointer;
  text-align: center;
  padding: .25rem;
}
.gc-restart:hover { color: var(--gc-primary-dark); text-decoration: underline; }

/* ---- Inline lead form (shown inside the chat body) ---- */
.gc-lead-form {
  align-self: stretch;
  background: var(--gc-surface);
  border: 1px solid var(--gc-line);
  border-radius: 12px;
  padding: .9rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.gc-lead-form label {
  font-size: .74rem;
  font-weight: 700;
  color: var(--gc-ink);
  font-family: var(--gc-heading-font);
  display: block;
  margin-bottom: .2rem;
}

.gc-lead-form input[type="text"],
.gc-lead-form input[type="email"],
.gc-lead-form input[type="tel"] {
  width: 100%;
  font-family: var(--gc-font);
  font-size: .85rem;
  padding: .5rem .65rem;
  border: 1px solid var(--gc-line);
  border-radius: 8px;
  background: var(--gc-bg);
  color: var(--gc-ink);
}

.gc-lead-form input:focus {
  outline: none;
  border-color: var(--gc-primary);
  box-shadow: 0 0 0 3px rgba(132,189,63,.18);
}

.gc-lead-consent {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  font-size: .74rem;
  color: var(--gc-muted);
  line-height: 1.4;
}
.gc-lead-consent input { margin-top: .2rem; flex-shrink: 0; }

.gc-lead-error {
  color: var(--gc-danger);
  font-size: .74rem;
  display: none;
}
.gc-lead-error.is-visible { display: block; }

.gc-lead-submit {
  background: linear-gradient(135deg, var(--gc-primary) 0%, var(--gc-primary-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--gc-heading-font);
  font-weight: 700;
  font-size: .84rem;
  padding: .6rem;
  cursor: pointer;
}
.gc-lead-submit:disabled { opacity: .6; cursor: not-allowed; }

.gc-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: .6rem .85rem;
  background: var(--gc-surface);
  border: 1px solid var(--gc-line);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}
.gc-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gc-muted);
  animation: gc-typing-bounce 1.1s infinite ease-in-out;
}
.gc-typing span:nth-child(2) { animation-delay: .15s; }
.gc-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes gc-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 420px) {
  .gc-panel { left: -8px; }
}

@media (prefers-reduced-motion: reduce) {
  .gc-bubble, .gc-panel, .gc-msg { transition: none !important; animation: none !important; }
}
