/* Live chat widget — self-contained theme (inherits site vars when present) */
.chat-widget {
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --primary-light: #3b82f6;
  --danger: #ef4444;
  --text: #0f172a;
  --text-muted: #64748b;
  --bg-subtle: #f8fafc;
  --border: #e2e8f0;
  --radius-lg: 20px;
  --shadow-lg: 0 20px 60px rgba(15, 23, 42, 0.12);
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --transition: 0.2s ease;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
}
.chat-launcher {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(29, 78, 216, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
  position: relative;
}
.chat-launcher:hover { transform: scale(1.06); }
.chat-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-launcher-badge[hidden] {
  display: none !important;
}
.chat-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: min(360px, calc(100vw - 32px));
  height: 480px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.chat-widget.open .chat-panel { display: flex; }
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
}
.chat-header strong { display: block; font-size: 0.95rem; }
.chat-header small { opacity: 0.85; font-size: 0.75rem; }
.chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.9;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.chat-bubble {
  max-width: 85%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
}
.chat-bubble p { margin: 0; }
.chat-bubble-name {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
  opacity: 0.9;
  letter-spacing: 0.01em;
}
.chat-bubble-visitor .chat-bubble-name {
  color: rgba(255, 255, 255, 0.92);
}
.chat-bubble-staff .chat-bubble-name,
.chat-bubble-bot .chat-bubble-name {
  color: var(--primary, #1d4ed8);
}
.chat-bubble small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.65rem;
  opacity: 0.65;
}
.chat-bubble-visitor {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble-staff,
.chat-bubble-bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-bubble-bot { background: #eff6ff; border-color: #bfdbfe; }
.chat-intake {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.1rem 1.25rem;
  background: #fff;
}
.chat-intake-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.chat-intake-intro {
  margin: 0 0 0.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.chat-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.chat-field span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
}
.chat-field span em {
  font-style: normal;
  font-weight: 400;
  color: var(--text-muted);
}
.chat-field-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.88rem;
  background: #fff;
}
.chat-field-input:focus {
  outline: none;
  border-color: var(--primary);
}
.chat-intake-error {
  margin: 0;
  font-size: 0.8rem;
  color: var(--danger);
}
.chat-intake-submit {
  margin-top: 0.25rem;
  width: 100%;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.chat-intake-submit:hover { background: var(--primary-dark, #1e40af); }
.chat-intake-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.chat-compose {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  background: #fff;
}
.chat-end-session {
  display: block;
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  text-decoration: underline;
}
.chat-end-session:hover { color: var(--danger); }
.chat-name-input {
  width: 100%;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.8rem;
}
.chat-input-row {
  display: flex;
  gap: 0.5rem;
}
.chat-input {
  flex: 1;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.9rem;
}
.chat-input:focus {
  outline: none;
  border-color: var(--primary);
}
.chat-send-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-send-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.45rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary, #1d4ed8);
  flex-shrink: 0;
  background: #eff6ff;
  border-top: 1px solid #dbeafe;
  border-bottom: 1px solid #dbeafe;
}
.chat-typing-indicator[hidden] { display: none !important; }
.chat-typing-label {
  font-style: italic;
  font-weight: 600;
}
.chat-typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.chat-typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary, #1d4ed8);
  opacity: 0.45;
  animation: chat-typing-bounce 1.2s infinite ease-in-out;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-typing-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
.chat-whatsapp-link {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--whatsapp-dark);
  font-weight: 600;
  text-align: center;
}
.chat-error {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem;
}
