/* ── Pixel Global AI Chatbot Widget CSS ── */
:root {
  --pgai-primary: var(--pgai-color, #0066cc);
  --pgai-radius: 16px;
  --pgai-shadow: 0 8px 32px rgba(0,0,0,0.18);
  --pgai-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Floating Button ── */
#pgai-toggle-btn {
  position: fixed;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99998;
  box-shadow: var(--pgai-shadow);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s;
  bottom: 24px;
}
#pgai-toggle-btn.pgai-pos-right { right: 24px; }
#pgai-toggle-btn.pgai-pos-left  { left: 24px; }
#pgai-toggle-btn:hover { transform: scale(1.1); box-shadow: 0 12px 40px rgba(0,0,0,0.25); }
#pgai-toggle-btn:active { transform: scale(0.95); }
#pgai-toggle-btn svg { transition: transform 0.3s; }
#pgai-toggle-btn.open svg.icon-chat  { display: none; }
#pgai-toggle-btn.open svg.icon-close { display: block !important; }

/* ── Chat Window (Floating) ── */
#pgai-chat-window {
  position: fixed;
  bottom: 94px;
  width: 360px;
  max-height: 540px;
  border-radius: var(--pgai-radius);
  box-shadow: var(--pgai-shadow);
  display: flex;
  flex-direction: column;
  z-index: 99999;
  background: #fff;
  font-family: var(--pgai-font);
  overflow: hidden;
  transform: scale(0.92) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s ease;
}
#pgai-chat-window.pgai-pos-right { right: 24px; }
#pgai-chat-window.pgai-pos-left  { left: 24px; }
#pgai-chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Inline Container ── */
.pgai-inline-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  border-radius: var(--pgai-radius);
  box-shadow: var(--pgai-shadow);
  overflow: hidden;
  background: #fff;
  font-family: var(--pgai-font);
}
.pgai-inline-container .pgai-chat-window-inner {
  max-height: 500px;
}

/* ── Header ── */
.pgai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  color: #fff;
}
.pgai-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pgai-header-info { flex: 1; }
.pgai-header-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.pgai-header-status { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 5px; }
.pgai-status-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #4ade80;
  animation: pgai-pulse 2s infinite;
}
@keyframes pgai-pulse {
  0%,100% { opacity: 1; } 50% { opacity: 0.5; }
}
.pgai-header-close {
  background: none; border: none; color: #fff; cursor: pointer;
  padding: 4px; border-radius: 50%; opacity: 0.8; transition: opacity 0.2s;
  display: none;
}
.pgai-header-close:hover { opacity: 1; background: rgba(255,255,255,0.15); }

/* ── Messages Area ── */
.pgai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fc;
  min-height: 280px;
  max-height: 360px;
  scroll-behavior: smooth;
}
.pgai-messages::-webkit-scrollbar { width: 4px; }
.pgai-messages::-webkit-scrollbar-track { background: transparent; }
.pgai-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* ── Message Bubbles ── */
.pgai-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: pgai-fadein 0.3s ease;
}
@keyframes pgai-fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.pgai-msg.user  { flex-direction: row-reverse; }
.pgai-msg-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; font-weight: 600;
}
.pgai-msg.bot  .pgai-msg-avatar { color: #fff; }
.pgai-msg.user .pgai-msg-avatar { background: #e2e8f0; color: #475569; }
.pgai-msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.pgai-msg.bot  .pgai-msg-bubble {
  background: #fff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.pgai-msg.user .pgai-msg-bubble {
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Typing Indicator ── */
.pgai-typing .pgai-msg-bubble {
  background: #fff;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 5px;
}
.pgai-typing-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #94a3b8;
  animation: pgai-bounce 1.2s infinite;
}
.pgai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.pgai-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pgai-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-5px); }
}

/* ── Input Area ── */
.pgai-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #e8edf2;
  background: #fff;
}
.pgai-input-area input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: var(--pgai-font);
  color: #1e293b;
  background: #f8f9fc;
}
.pgai-input-area input:focus { border-color: var(--pgai-color, #0066cc); background: #fff; }
.pgai-send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; cursor: pointer; color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, opacity 0.2s;
}
.pgai-send-btn:hover  { transform: scale(1.08); }
.pgai-send-btn:active { transform: scale(0.93); }
.pgai-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Footer Branding ── */
.pgai-footer {
  text-align: center;
  padding: 6px;
  font-size: 11px;
  color: #94a3b8;
  background: #fff;
  border-top: 1px solid #f1f5f9;
}
.pgai-footer a { color: inherit; text-decoration: none; }
.pgai-footer a:hover { text-decoration: underline; }

/* ── Notification Badge ── */
#pgai-badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 18px; height: 18px;
  background: #ef4444;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  display: none;
}

/* ── Mobile Responsive ── */
@media (max-width: 480px) {
  #pgai-chat-window {
    width: calc(100vw - 24px);
    right: 12px !important;
    left: 12px !important;
    bottom: 80px;
  }
  .pgai-inline-container { border-radius: 10px; }
}
