/* ── Alphi Chat Widget Styles ─────────────────────────────────────────────── */

#alphi-widget {
  --alphi-primary: #2563eb;
  --alphi-primary-dark: #1d4ed8;
  --alphi-bg: #ffffff;
  --alphi-surface: #f8fafc;
  --alphi-border: #e2e8f0;
  --alphi-text: #1e293b;
  --alphi-muted: #64748b;
  --alphi-radius: 12px;
  --alphi-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--alphi-text);
  box-sizing: border-box;
}

#alphi-widget *,
#alphi-widget *::before,
#alphi-widget *::after {
  box-sizing: inherit;
}

/* ── Toggle button ───────────────────────────────────────────────────────── */

#alphi-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--alphi-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--alphi-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  z-index: 9999;
}

#alphi-toggle:hover {
  background: var(--alphi-primary-dark);
  transform: scale(1.05);
}

#alphi-toggle svg {
  width: 24px;
  height: 24px;
  pointer-events: none;
}

/* ── Chat window ─────────────────────────────────────────────────────────── */

#alphi-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 360px;
  max-height: 560px;
  background: var(--alphi-bg);
  border: 1px solid var(--alphi-border);
  border-radius: var(--alphi-radius);
  box-shadow: var(--alphi-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  transition: opacity 0.2s, transform 0.2s;
}

#alphi-window.alphi-hidden {
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

#alphi-header {
  background: var(--alphi-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#alphi-header .alphi-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

#alphi-header .alphi-title {
  flex: 1;
}

#alphi-header .alphi-title strong {
  display: block;
  font-size: 14px;
}

#alphi-header .alphi-title span {
  font-size: 11px;
  opacity: 0.8;
}

#alphi-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  opacity: 0.8;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: opacity 0.15s;
}

#alphi-close:hover { opacity: 1; }

/* ── Messages ────────────────────────────────────────────────────────────── */

#alphi-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--alphi-surface);
}

.alphi-msg {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}

.alphi-msg.alphi-bot {
  align-self: flex-start;
  background: var(--alphi-bg);
  border: 1px solid var(--alphi-border);
  border-bottom-left-radius: 3px;
}

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

/* Typing indicator */
.alphi-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}

.alphi-typing span {
  width: 6px;
  height: 6px;
  background: var(--alphi-muted);
  border-radius: 50%;
  animation: alphi-bounce 1.2s infinite;
}

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

@keyframes alphi-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── Input bar ───────────────────────────────────────────────────────────── */

#alphi-input-area {
  padding: 12px;
  border-top: 1px solid var(--alphi-border);
  background: var(--alphi-bg);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#alphi-input {
  flex: 1;
  border: 1px solid var(--alphi-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.15s;
}

#alphi-input:focus {
  border-color: var(--alphi-primary);
}

#alphi-send {
  background: var(--alphi-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

#alphi-send:hover { background: var(--alphi-primary-dark); }
#alphi-send:disabled { opacity: 0.5; cursor: not-allowed; }

#alphi-send svg {
  width: 16px;
  height: 16px;
}

/* ── Lead capture form ───────────────────────────────────────────────────── */

#alphi-lead-form {
  padding: 16px;
  border-top: 1px solid var(--alphi-border);
  background: var(--alphi-bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#alphi-lead-form p {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--alphi-muted);
}

.alphi-field {
  width: 100%;
  border: 1px solid var(--alphi-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.alphi-field:focus { border-color: var(--alphi-primary); }

#alphi-lead-submit {
  background: var(--alphi-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

#alphi-lead-submit:hover { background: var(--alphi-primary-dark); }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 400px) {
  #alphi-window {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100dvh;
    border-radius: var(--alphi-radius) var(--alphi-radius) 0 0;
  }

  #alphi-toggle {
    bottom: 16px;
    right: 16px;
  }
}
