/* ==============================
   Simply Promotions AI Chat Widget
   ============================== */

/* ── Keyframes ── */
@keyframes sp-bob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-7px); }
}

@keyframes sp-slide-up {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes sp-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Standing figure trigger ── */
.sp-chat-wrap {
  position: fixed;
  bottom: 0;
  right: 20px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.sp-chat-figure {
  display: block;
  width: 62px;
  height: auto;
  cursor: pointer;
  animation: sp-bob 3.2s ease-in-out infinite;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.22));
  transition: filter 0.2s;
}

.sp-chat-figure:hover {
  filter: drop-shadow(0 8px 20px rgba(52,183,155,0.45));
}

/* tooltip badge — floats to the left of the figure */
.sp-chat-badge {
  position: absolute;
  bottom: 160px;
  right: 72px;
  background: #fff;
  color: #43404A;
  font-family: 'Albert Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 20px;
  box-shadow: 0 3px 14px rgba(0,0,0,0.13);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

/* little arrow pointing right toward the figure */
.sp-chat-badge::after {
  content: '';
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  border: 7px solid transparent;
  border-left-color: #fff;
  border-right: none;
}

.sp-chat-badge.sp-hidden {
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
}

/* ── Chat panel ── */
.sp-chat-panel {
  display: none;
  flex-direction: column;
  position: fixed;
  bottom: 20px;
  right: 90px;
  width: 340px;
  max-height: 520px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  overflow: hidden;
  z-index: 9001;
  animation: sp-slide-up 0.28s ease both;
}

.sp-chat-panel.sp-open {
  display: flex;
}

/* header */
.sp-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #2DBFB0, #66469B);
  flex-shrink: 0;
}

.sp-chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.4);
  flex-shrink: 0;
}

.sp-chat-header-info {
  flex: 1;
  min-width: 0;
}

.sp-chat-header-info strong {
  display: block;
  color: #fff;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 15px;
}

.sp-chat-header-info span {
  display: block;
  color: rgba(255,255,255,0.78);
  font-size: 11px;
  margin-top: 1px;
}

.sp-chat-header-info span::before {
  content: '●';
  color: #7EFFD4;
  font-size: 8px;
  margin-right: 4px;
  vertical-align: middle;
}

.sp-chat-close {
  background: rgba(255,255,255,0.18);
  border: none;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.sp-chat-close:hover { background: rgba(255,255,255,0.3); }

/* messages area */
.sp-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.sp-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  font-family: 'Albert Sans', sans-serif;
}

.sp-msg--ai {
  background: #F4F5F6;
  color: #333;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.sp-msg--user {
  background: linear-gradient(135deg, #34B79B, #2DBFB0);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* typing dots */
.sp-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 14px;
  background: #F4F5F6;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: fit-content;
}

.sp-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34B79B;
  animation: sp-dot-bounce 1.2s ease-in-out infinite;
}

.sp-typing span:nth-child(2) { animation-delay: 0.15s; }
.sp-typing span:nth-child(3) { animation-delay: 0.3s; }

/* input row */
.sp-chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(0,0,0,0.07);
  flex-shrink: 0;
}

.sp-chat-input {
  flex: 1;
  border: 1.5px solid #E0E0E8;
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 14px;
  font-family: 'Albert Sans', sans-serif;
  color: #333;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.sp-chat-input:focus { border-color: #34B79B; }

.sp-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #34B79B, #66469B);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.2s;
}

.sp-chat-send:hover { transform: scale(1.1); }
.sp-chat-send:disabled { opacity: 0.5; cursor: default; transform: none; }

/* ── Mobile ── */
@media (max-width: 480px) {
  .sp-chat-wrap {
    bottom: 0;
    right: 12px;
  }

  .sp-chat-figure {
    width: 50px;
  }

  .sp-chat-badge {
    bottom: 130px;
    right: 62px;
    font-size: 12px;
    padding: 6px 11px;
  }

  .sp-chat-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 16px;
    max-height: 65vh;
    border-radius: 14px;
  }
}
