/* =========================================================
   Azterion AI — Chat Widget
   ========================================================= */

:root {
  --azai-yellow:    #ffcc00;
  --azai-black:     #0d0d0d;
  --azai-white:     #ffffff;
  --azai-gray-50:   #f9f9f9;
  --azai-gray-100:  #f3f3f3;
  --azai-gray-200:  #e8e8e8;
  --azai-gray-400:  #9e9e9e;
  --azai-gray-600:  #5c5c5c;
  --azai-radius:    16px;
  --azai-shadow:    0 8px 40px rgba(0,0,0,.18);
  --azai-z:         9999;
}

/* ── Hard reset — prevent theme styles from leaking in ── */
#azai-widget button,
#azai-widget button:hover,
#azai-widget button:focus,
#azai-widget button:active {
  background-color: transparent;
  color: inherit;
  border: none;
  box-shadow: none;
  text-shadow: none;
  border-radius: 0;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  outline: none;
}

/* ── Widget container ─────────────────────────────────── */
#azai-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--azai-z);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  /* Bubble hidden on load, appears on scroll */
  font-size: 14px;
  line-height: 1.5;
}

/* ── Hide reCAPTCHA badge (referenced in privacy policy) ── */
.grecaptcha-badge {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ── Bubble button ────────────────────────────────────── */
/* Bubble scroll-in animation */
#azai-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50% !important;
  background: #ffffff !important;
  color: #111111 !important;
  border: none !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.20), 0 1px 4px rgba(0,0,0,.12) !important;
  position: relative;
  /* Hidden by default */
  opacity: 0;
  transform: scale(0.5) translateY(12px);
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.34,1.56,0.64,1),
              transform 0.35s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.2s ease;
}
/* Visible state — added by JS on scroll */
#azai-bubble.az-bubble-in {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

#azai-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0,0,0,.25), 0 2px 6px rgba(0,0,0,.15) !important;
  background: #ffffff !important;
  color: #111111 !important;
}

#azai-bubble.is-open {
  background: #ffffff !important;
  color: #111111 !important;
  box-shadow: 0 4px 12px rgba(0,0,0,.20), 0 1px 4px rgba(0,0,0,.12) !important;
}

.azai-bubble-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--azai-yellow);
  border: 2px solid var(--azai-white);
  display: none;
}

.azai-bubble-dot.is-visible {
  display: block;
  animation: azai-pulse 2s infinite;
}

@keyframes azai-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.2); }
}

/* ── Panel ────────────────────────────────────────────── */
#azai-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 360px;
  max-height: 600px;
  background: var(--azai-white);
  border-radius: var(--azai-radius);
  box-shadow: var(--azai-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#azai-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ── Header ───────────────────────────────────────────── */
.azai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--azai-black);
  color: var(--azai-white);
  flex-shrink: 0;
}

.azai-panel-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.azai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--azai-yellow);
  color: var(--azai-black);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.azai-avatar--sm {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.azai-panel-title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.azai-panel-sub {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  margin-top: 1px;
}

.azai-panel-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.azai-panel-close:hover {
  color: var(--azai-white);
  background: rgba(255,255,255,.12);
}

/* ── Messages area ────────────────────────────────────── */
.azai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.azai-messages::-webkit-scrollbar { width: 4px; }
.azai-messages::-webkit-scrollbar-track { background: transparent; }
.azai-messages::-webkit-scrollbar-thumb { background: var(--azai-gray-200); border-radius: 4px; }

/* ── Message bubble ───────────────────────────────────── */
.azai-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: azai-msg-in 0.2s ease;
}

@keyframes azai-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.azai-msg-text {
  max-width: 80%;
  padding: 10px 13px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 13.5px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Bot message */
.azai-msg--bot {
  justify-content: flex-start;
}

.azai-msg--bot .azai-msg-text {
  background: var(--azai-gray-100);
  color: var(--azai-black);
  border-bottom-left-radius: 4px;
}

/* User message */
.azai-msg--user {
  justify-content: flex-end;
}

.azai-msg--user .azai-msg-text {
  background: var(--azai-black);
  color: var(--azai-white);
  border-bottom-right-radius: 4px;
}

/* Error state */
.azai-msg--error .azai-msg-text {
  background: #fff0f0;
  color: #c0392b;
}

/* ── Typing indicator ─────────────────────────────────── */
.azai-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 4px;
  flex-shrink: 0;
}

.azai-typing-dots {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: var(--azai-gray-100);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.azai-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--azai-gray-400);
  animation: azai-dot 1.2s infinite ease-in-out;
}

.azai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.azai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes azai-dot {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}

/* ── Lead form ────────────────────────────────────────── */
.azai-lead-form {
  padding: 16px;
  border-top: 1px solid var(--azai-gray-200);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--azai-gray-50);
  flex-shrink: 0;
  animation: azai-msg-in 0.2s ease;
}

/* When rendered inline inside the messages scroll area */
.azai-lead-form--inline {
  border-top: none;
  border: 1px solid var(--azai-gray-200);
  border-radius: 14px;
  margin-top: 4px;
  flex-shrink: unset;
}

.azai-lead-form-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--azai-black);
  margin: 0;
}

.azai-lead-form input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--azai-gray-200);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: var(--azai-white);
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.azai-lead-form input:focus {
  border-color: var(--azai-black);
}

.azai-lead-submit {
  padding: 11px 20px;
  background: #ffcc00 !important;
  color: #0d0d0d !important;
  border: none !important;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: -0.01em;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 2px 12px rgba(255,204,0,0.30) !important;
  outline: none;
  align-self: stretch;
}

.azai-lead-submit:hover {
  background: #f5c400 !important;
  color: #0d0d0d !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255,204,0,0.40) !important;
}

.azai-lead-submit:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(255,204,0,0.25) !important;
}

.azai-lead-cancel {
  background: transparent;
  border: none;
  font-size: 12px;
  color: var(--azai-gray-400);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  padding: 0;
}

.azai-lead-cancel:hover { color: var(--azai-black); }

/* ── Input area ───────────────────────────────────────── */
.azai-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--azai-gray-200);
  background: var(--azai-white);
  flex-shrink: 0;
}

#azai-input {
  flex: 1;
  border: 1px solid var(--azai-gray-200);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
  background: var(--azai-gray-50);
  transition: border-color 0.15s, background 0.15s;
}

#azai-input:focus {
  border-color: var(--azai-black);
  background: var(--azai-white);
}

#azai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--azai-black);
  color: var(--azai-yellow);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

#azai-send-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

#azai-send-btn:not(:disabled):hover {
  opacity: 0.85;
}

/* ── Footer ───────────────────────────────────────────── */
.azai-panel-footer {
  padding: 6px 14px 10px;
  font-size: 11px;
  color: var(--azai-gray-400);
  text-align: center;
  flex-shrink: 0;
}

.azai-panel-footer a {
  color: var(--azai-gray-600);
  text-decoration: none;
}

.azai-panel-footer a:hover {
  text-decoration: underline;
  color: var(--azai-black);
}

/* ── Suggestions ──────────────────────────────────────── */
.azai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
}

#azai-widget .azai-suggestion-btn,
#azai-widget button.azai-suggestion-btn {
  display: inline-block !important;
  padding: 7px 14px !important;
  background: #ffffff !important;
  border: 1.5px solid #c8ccd2 !important;
  border-radius: 8px !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  color: #333333 !important;
  cursor: pointer !important;
  font-family: inherit !important;
  line-height: 1.4 !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.08) !important;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s !important;
  text-decoration: none !important;
  outline: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}

#azai-widget .azai-suggestion-btn:hover,
#azai-widget button.azai-suggestion-btn:hover {
  background: #0d0d0d !important;
  color: #ffffff !important;
  border-color: #0d0d0d !important;
  box-shadow: 0 2px 6px rgba(0,0,0,.18) !important;
}

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 480px) {
  #azai-widget {
    bottom: 16px;
    right: 16px;
  }

  #azai-panel {
    width: calc(100vw - 32px);
    max-height: calc(100dvh - 110px);
    bottom: 68px;
    right: 0;
  }
}
