/* ============================================================
   PriceAlert — Asistent AI (chat widget)
   CSS izolat, prefixat pa-chat-*, zero conflicte cu Bootstrap.
   Culoarea de accent se schimba din O SINGURA variabila:
   ============================================================ */

#pa-chat {
  --pa-accent: #6d4bd8;          /* ← culoarea brandului, ajusteaza aici */
  --pa-accent-soft: #f1edfc;
  --pa-bg: #ffffff;
  --pa-text: #1f2430;
  --pa-muted: #7a8194;
  --pa-border: #e6e8ef;
  --pa-danger: #d6336c;
  --pa-radius: 16px;
  --pa-shadow: 0 12px 40px rgba(20, 20, 50, .18);

  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1050;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
  color: var(--pa-text);
}

#pa-chat * { box-sizing: border-box; }

/* ---------- Bubble ---------- */
.pa-chat-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--pa-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(109, 75, 216, .45);
  transition: transform .15s ease, box-shadow .15s ease;
}
.pa-chat-bubble:hover { transform: scale(1.07); }
.pa-chat-bubble svg { width: 26px; height: 26px; }
.pa-chat-bubble .pa-chat-unread {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 20px; height: 20px;
  border-radius: 10px;
  background: var(--pa-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

/* ---------- Panel ---------- */
.pa-chat-panel {
  position: absolute;
  right: 0; bottom: 72px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--pa-bg);
  border: 1px solid var(--pa-border);
  border-radius: var(--pa-radius);
  box-shadow: var(--pa-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(.98);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
#pa-chat.pa-open .pa-chat-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ---------- Header ---------- */
.pa-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--pa-accent);
  color: #fff;
}
.pa-chat-header .pa-chat-title { font-weight: 700; font-size: 15px; flex: 1; }
.pa-chat-header .pa-chat-usage {
  font-size: 11.5px;
  background: rgba(255,255,255,.2);
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}
.pa-chat-header .pa-chat-usage.pa-warn { background: var(--pa-danger); }
.pa-chat-icon-btn {
  background: rgba(255,255,255,.15);
  border: none; color: #fff;
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.pa-chat-icon-btn:hover { background: rgba(255,255,255,.3); }
.pa-chat-icon-btn svg { width: 16px; height: 16px; }

/* ---------- Messages ---------- */
.pa-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafafc;
}
.pa-chat-msg { max-width: 88%; }
.pa-chat-msg.pa-user {
  align-self: flex-end;
  background: var(--pa-accent);
  color: #fff;
  padding: 9px 13px;
  border-radius: 14px 14px 4px 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.pa-chat-msg.pa-assistant {
  align-self: flex-start;
  max-width: 100%;
  width: 100%;
}
.pa-chat-msg.pa-assistant .pa-chat-text {
  background: var(--pa-bg);
  border: 1px solid var(--pa-border);
  padding: 10px 13px;
  border-radius: 4px 14px 14px 14px;
  word-break: break-word;
}
.pa-chat-msg.pa-assistant .pa-chat-text strong { font-weight: 700; }
.pa-chat-msg.pa-assistant .pa-chat-text a { color: var(--pa-accent); }

/* Typing indicator */
.pa-chat-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.pa-chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--pa-muted);
  animation: pa-chat-blink 1.2s infinite;
}
.pa-chat-typing span:nth-child(2) { animation-delay: .2s; }
.pa-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes pa-chat-blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ---------- Product cards (scroll orizontal) ---------- */
.pa-chat-products {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 2px 4px;
  scroll-snap-type: x mandatory;
}
.pa-chat-product {
  flex: 0 0 150px;
  scroll-snap-align: start;
  background: var(--pa-bg);
  border: 1px solid var(--pa-border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.pa-chat-product img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: #f0f0f4;
  display: block;
}
.pa-chat-product .pa-chat-pbody { padding: 8px 9px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pa-chat-product .pa-chat-ptitle {
  font-size: 12px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pa-chat-product .pa-chat-pprice { font-size: 14px; font-weight: 700; }
.pa-chat-product .pa-chat-pold {
  font-size: 11.5px;
  color: var(--pa-muted);
  text-decoration: line-through;
  margin-left: 5px;
}
.pa-chat-product .pa-chat-pvendor { font-size: 11px; color: var(--pa-muted); }
.pa-chat-product .pa-chat-pbadges { display: flex; flex-wrap: wrap; gap: 4px; }
.pa-chat-product .pa-chat-pbadge {
  font-size: 10px;
  font-weight: 700;
  border-radius: 6px;
  padding: 1px 6px;
  background: var(--pa-accent-soft);
  color: var(--pa-accent);
}
.pa-chat-product .pa-chat-pbadge.pa-discount { background: #fde8f0; color: var(--pa-danger); }
.pa-chat-product .pa-chat-pcta {
  margin-top: auto;
  display: block;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff !important;
  background: var(--pa-accent);
  border-radius: 8px;
  padding: 6px 8px;
  text-decoration: none;
}
.pa-chat-product .pa-chat-pcta:hover { filter: brightness(1.1); }

/* ---------- Chips (filtre) + actiuni ---------- */
.pa-chat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pa-chat-chip {
  font-size: 11.5px;
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--pa-accent-soft);
  color: var(--pa-accent);
}
.pa-chat-chip.pa-ignored { background: #f3f4f7; color: var(--pa-muted); }
.pa-chat-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pa-chat-action {
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--pa-accent);
  color: var(--pa-accent);
  background: var(--pa-bg);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.pa-chat-action:hover { background: var(--pa-accent); color: #fff; }

/* ---------- Note (profil, erori, limite) ---------- */
.pa-chat-note {
  font-size: 12px;
  color: var(--pa-muted);
  background: #f3f4f7;
  border-radius: 10px;
  padding: 7px 11px;
  margin-top: 8px;
}
.pa-chat-note.pa-error { background: #fde8f0; color: var(--pa-danger); }
.pa-chat-note button {
  border: none;
  background: none;
  color: var(--pa-accent);
  font-weight: 700;
  cursor: pointer;
  padding: 0 0 0 6px;
  font-size: 12px;
}

/* ---------- Stare login / empty ---------- */
.pa-chat-empty {
  margin: auto;
  text-align: center;
  color: var(--pa-muted);
  padding: 20px;
}
.pa-chat-empty .pa-chat-login-btn, .pa-chat-newchat-btn {
  display: inline-block;
  margin-top: 12px;
  background: var(--pa-accent);
  color: #fff !important;
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

/* ---------- Input ---------- */
.pa-chat-inputbar {
  border-top: 1px solid var(--pa-border);
  padding: 10px 12px 12px;
  background: var(--pa-bg);
}
.pa-chat-inputwrap { display: flex; gap: 8px; align-items: flex-end; }
.pa-chat-inputbar textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--pa-border);
  border-radius: 12px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  max-height: 110px;
  outline: none;
}
.pa-chat-inputbar textarea:focus { border-color: var(--pa-accent); }
.pa-chat-inputbar textarea:disabled { background: #f3f4f7; }
.pa-chat-send {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border: none;
  border-radius: 12px;
  background: var(--pa-accent);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.pa-chat-send:disabled { opacity: .45; cursor: default; }
.pa-chat-send svg { width: 18px; height: 18px; }
.pa-chat-counter {
  font-size: 11px;
  color: var(--pa-muted);
  text-align: right;
  margin-top: 4px;
}
.pa-chat-counter.pa-over { color: var(--pa-danger); font-weight: 700; }

/* ---------- Mobil: full-screen ---------- */
@media (max-width: 640px) {
  #pa-chat { right: 16px; bottom: 16px; }
  #pa-chat.pa-open .pa-chat-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    bottom: 0; right: 0;
  }
}
