/* ==========================================================================
   PYRAMORA — AI Sales Assistant Widget
   Uses existing design tokens (tokens.css) — load this AFTER tokens.css
   ========================================================================== */

#pm-ai-launcher-label {
  position: fixed;
  bottom: 96px;
  left: 24px;
  z-index: 998;
  background: var(--pm-ink);
  color: var(--pm-white);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-md, 0 6px 20px rgba(0,0,0,0.15));
  white-space: nowrap;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 420ms var(--ease-out), transform 420ms var(--ease-out);
}
#pm-ai-launcher-label::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 22px;
  width: 10px;
  height: 10px;
  background: var(--pm-ink);
  transform: rotate(45deg);
}
#pm-ai-launcher-label.is-visible { opacity: 1; transform: translateY(0); }
#pm-ai-launcher-label.is-hidden { display: none; }

@media (max-width: 480px) {
  #pm-ai-launcher-label { left: 16px; bottom: 82px; font-size: 0.75rem; }
}

#pm-ai-launcher {
  position: fixed;
  bottom: 24px;
  left: 24px; /* opposite side from WhatsApp FAB which sits bottom-right */
  z-index: 998;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--pm-white);
  box-shadow: var(--shadow-lg);
  border: 1.5px solid var(--pm-line);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out);
}
#pm-ai-launcher:hover { transform: translateY(-3px) scale(1.04); }
#pm-ai-launcher svg { width: 28px; height: 28px; color: var(--pm-ink); }
#pm-ai-launcher .pm-ai-dot {
  position: absolute; top: 4px; right: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #4CAF50; border: 2px solid var(--pm-white);
}

#pm-ai-panel {
  position: fixed;
  bottom: 100px;
  left: 24px;
  z-index: 999;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: var(--pm-white);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-body);
  border: 1px solid var(--pm-line);
}
#pm-ai-panel.is-open { display: flex; animation: pm-ai-rise 320ms var(--ease-out); }
@keyframes pm-ai-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.pm-ai-header {
  background: var(--pm-ink);
  color: var(--pm-white);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.pm-ai-header__avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--pm-cream);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.pm-ai-header__avatar img {
  width: 100%; height: 100%; object-fit: contain; display: block; padding: 3px;
}
.pm-ai-header__text { flex: 1; }
.pm-ai-header__text strong { display: block; font-size: 0.95rem; }
.pm-ai-header__text span { font-size: 0.78rem; color: rgba(255,255,255,0.65); }
.pm-ai-header__close {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.7); transition: background var(--dur-fast) var(--ease-out);
}
.pm-ai-header__close:hover { background: rgba(255,255,255,0.1); color: var(--pm-white); }

.pm-ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: var(--pm-cream);
}

.pm-ai-welcome {
  background: var(--pm-white);
  border-radius: var(--r-md);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
}
.pm-ai-welcome p { font-size: 0.9rem; color: var(--pm-text); margin-bottom: 0.85rem; line-height: 1.5; }
.pm-ai-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pm-ai-chip {
  border: 1.5px solid var(--pm-ink-12);
  border-radius: var(--r-pill);
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all var(--dur-fast) var(--ease-out);
  background: var(--pm-white);
}
.pm-ai-chip:hover { border-color: var(--pm-gold-deep); background: var(--pm-gold-pale); }

.pm-ai-msg { max-width: 85%; font-size: 0.88rem; line-height: 1.55; animation: pm-ai-pop 220ms var(--ease-out); }
@keyframes pm-ai-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.pm-ai-msg--user {
  align-self: flex-end;
  background: var(--pm-ink);
  color: var(--pm-white);
  padding: 0.65rem 1rem;
  border-radius: 16px 16px 4px 16px;
}
.pm-ai-msg--bot {
  align-self: flex-start;
  background: var(--pm-white);
  color: var(--pm-text);
  padding: 0.7rem 1rem;
  border-radius: 16px 16px 16px 4px;
  box-shadow: var(--shadow-sm);
  white-space: pre-wrap;
}
.pm-ai-msg--bot strong { color: var(--pm-gold-deep); }

.pm-ai-typing {
  align-self: flex-start;
  background: var(--pm-white);
  padding: 0.8rem 1.1rem;
  border-radius: 16px 16px 16px 4px;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 4px;
}
.pm-ai-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--pm-stone);
  animation: pm-ai-blink 1.2s infinite ease-in-out;
}
.pm-ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.pm-ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pm-ai-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.pm-ai-whatsapp-cta {
  align-self: flex-start;
  max-width: 90%;
  background: var(--pm-white);
  border: 1.5px solid var(--pm-gold-pale);
  border-radius: var(--r-md);
  padding: 0.9rem;
  box-shadow: var(--shadow-sm);
}
.pm-ai-whatsapp-cta p { font-size: 0.82rem; color: var(--pm-text-muted); margin-bottom: 0.6rem; }
.pm-ai-whatsapp-cta a {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: #25D366; color: white; font-weight: 600; font-size: 0.85rem;
  padding: 0.7rem; border-radius: var(--r-pill);
  transition: transform var(--dur-fast) var(--ease-out);
}
.pm-ai-whatsapp-cta a:hover { transform: translateY(-2px); }
.pm-ai-whatsapp-cta svg { width: 18px; height: 18px; }

.pm-ai-inputbar {
  border-top: 1px solid var(--pm-line);
  padding: 0.75rem;
  display: flex;
  gap: 0.5rem;
  background: var(--pm-white);
}
.pm-ai-inputbar input {
  flex: 1;
  border: 1.5px solid var(--pm-ink-12);
  border-radius: var(--r-pill);
  padding: 0.65rem 1.1rem;
  font-size: 0.88rem;
  background: var(--pm-cream);
}
.pm-ai-inputbar input:focus { outline: none; border-color: var(--pm-gold-deep); }
.pm-ai-inputbar button {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--pm-gold) 0%, var(--pm-gold-deep) 100%);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.pm-ai-inputbar button svg { width: 18px; height: 18px; color: var(--pm-ink); }
.pm-ai-inputbar button:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 480px) {
  #pm-ai-panel { left: 12px; right: 12px; width: auto; bottom: 90px; }
  #pm-ai-launcher { left: 16px; bottom: 16px; }
}
