/* ============================================================
   AMPF AI Chatbot Widget
   ============================================================ */

:root {
  --ampf-primary: #0ea5e9;
  --ampf-primary-dark: #0284c7;
  --ampf-radius: 18px;
  --ampf-shadow: 0 20px 60px rgba(0,0,0,.18), 0 4px 12px rgba(0,0,0,.10);
  --ampf-font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Launcher Button ─────────────────────────────────────── */
#ampf-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ampf-primary);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(14,165,233,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99998;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  outline: none;
}
#ampf-launcher.left { right: auto; left: 24px; }
#ampf-launcher:hover { transform: scale(1.12); box-shadow: 0 6px 28px rgba(14,165,233,.55); }
#ampf-launcher:active { transform: scale(.95); }

.ampf-launcher-icon { font-size: 26px; line-height: 1; transition: opacity .2s, transform .2s; }
.ampf-launcher-icon.hide { opacity: 0; transform: scale(.6) rotate(-90deg); position: absolute; }
.ampf-launcher-icon.show { opacity: 1; transform: scale(1) rotate(0); }

/* Pulse ring */
#ampf-launcher::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--ampf-primary);
  opacity: 0;
  animation: ampfPulse 2.5s ease-out infinite;
}
@keyframes ampfPulse {
  0%   { opacity:.6; transform:scale(1); }
  100% { opacity:0;  transform:scale(1.5); }
}

/* Unread badge */
#ampf-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}

/* ── Chat Window ─────────────────────────────────────────── */
#ampf-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-height: 580px;
  border-radius: var(--ampf-radius);
  background: #fff;
  box-shadow: var(--ampf-shadow);
  display: flex;
  flex-direction: column;
  z-index: 99999;
  font-family: var(--ampf-font);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(.97);
  transition: opacity .25s ease, transform .25s cubic-bezier(.34,1.2,.64,1);
}
#ampf-window.left { right: auto; left: 24px; }
#ampf-window.open { opacity: 1; pointer-events: all; transform: translateY(0) scale(1); }

/* Header */
#ampf-header {
  background: var(--ampf-primary);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ampf-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.ampf-header-info { flex: 1; min-width: 0; }
.ampf-header-name {
  font-weight: 700;
  color: #fff;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ampf-header-status {
  font-size: 11px;
  color: rgba(255,255,255,.8);
  display: flex;
  align-items: center;
  gap: 4px;
}
.ampf-status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  animation: ampfBlink 2s ease-in-out infinite;
}
@keyframes ampfBlink { 0%,100%{opacity:1} 50%{opacity:.4} }

#ampf-close {
  width: 28px; height: 28px;
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
#ampf-close:hover { background: rgba(255,255,255,.3); }

/* Messages */
#ampf-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
  scroll-behavior: smooth;
}
#ampf-messages::-webkit-scrollbar { width: 4px; }
#ampf-messages::-webkit-scrollbar-track { background: transparent; }
#ampf-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.ampf-msg {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  animation: ampfMsgIn .25s ease forwards;
  max-width: 92%;
}
@keyframes ampfMsgIn {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}
.ampf-msg.bot  { align-self: flex-start; }
.ampf-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.ampf-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--ampf-primary);
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.ampf-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 100%;
  word-wrap: break-word;
}
.ampf-msg.bot .ampf-bubble {
  background: #fff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.ampf-msg.user .ampf-bubble {
  background: var(--ampf-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ampf-bubble p { margin: 0 0 6px; }
.ampf-bubble p:last-child { margin-bottom: 0; }
.ampf-bubble strong { font-weight: 600; }
.ampf-bubble ul, .ampf-bubble ol { padding-left: 18px; margin: 4px 0; }

/* RTL support for Arabic */
.ampf-bubble[dir="rtl"] { text-align: right; direction: rtl; }

/* Typing indicator */
.ampf-typing .ampf-bubble {
  background: #fff;
  padding: 12px 16px;
}
.ampf-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}
.ampf-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: ampfDot 1.2s ease-in-out infinite;
}
.ampf-dots span:nth-child(2) { animation-delay: .15s; }
.ampf-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes ampfDot {
  0%,80%,100% { transform:scale(.6); opacity:.4; }
  40%          { transform:scale(1);  opacity:1; }
}

/* Input area */
#ampf-input-area {
  padding: 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
#ampf-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 100px;
  transition: border-color .15s;
  background: #f8fafc;
  color: #1e293b;
  line-height: 1.4;
}
#ampf-input:focus { border-color: var(--ampf-primary); background: #fff; }
#ampf-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--ampf-primary);
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .15s;
  flex-shrink: 0;
}
#ampf-send:hover   { background: var(--ampf-primary-dark); transform: scale(1.08); }
#ampf-send:active  { transform: scale(.92); }
#ampf-send:disabled { opacity: .4; cursor: default; transform: none; }

/* Branding */
#ampf-branding {
  text-align: center;
  font-size: 10px;
  color: #94a3b8;
  padding: 4px 0 8px;
  background: #fff;
}
#ampf-branding a { color: #94a3b8; text-decoration: none; }

/* Mobile */
@media (max-width: 480px) {
  #ampf-window {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 84px;
    max-height: calc(100vh - 110px);
  }
  #ampf-window.left { right: 12px; left: 12px; }
}
