/* SpeedPRO Chat Widget — WhatsApp-style AI assistant */

/* --- Launcher Button --- */
#sp-chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  width: 60px;
  height: 60px;
  background: #C8960C;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: transform 0.2s, background 0.2s;
}
#sp-chat-launcher:hover { transform: scale(1.08); background: #b8870a; }
#sp-chat-launcher svg { pointer-events: none; }

#sp-chat-launcher .sp-close-icon { display: none; }
#sp-chat-launcher.open .sp-open-icon { display: none; }
#sp-chat-launcher.open .sp-close-icon { display: block; }

/* --- Chat Window --- */
#sp-chat-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  z-index: 9001;
  width: 380px;
  max-height: 560px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#sp-chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}
@media (max-width: 480px) {
  #sp-chat-window { right: 12px; left: 12px; width: auto; bottom: 88px; }
}

/* --- Header --- */
.sp-chat-header {
  background: #0F1923;
  color: #fff;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.sp-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #C8960C;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.sp-header-info { flex: 1; }
.sp-header-name {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}
.sp-header-status {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.sp-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4CAF50;
  animation: sp-pulse 2s infinite;
}
@keyframes sp-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.sp-header-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: rgba(255,255,255,0.6);
  transition: color 0.15s;
  flex-shrink: 0;
}
.sp-header-close:hover { color: #fff; }

/* --- Messages --- */
.sp-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.sp-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: sp-msg-in 0.2s ease;
}
@keyframes sp-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sp-msg-user { align-self: flex-end; }
.sp-msg-agent { align-self: flex-start; }

.sp-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.sp-msg-user .sp-msg-bubble {
  background: #C8960C;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.sp-msg-agent .sp-msg-bubble {
  background: #F5F0EB;
  color: #1C1917;
  border-bottom-left-radius: 4px;
}
.sp-msg-time {
  font-size: 10px;
  color: rgba(0,0,0,0.35);
  margin-top: 4px;
  padding: 0 4px;
}
.sp-msg-user .sp-msg-time { text-align: right; }
.sp-msg-agent .sp-msg-time { text-align: left; }

/* Typing indicator */
.sp-typing {
  display: none;
  align-self: flex-start;
  padding: 10px 14px;
  background: #F5F0EB;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.sp-typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #C8960C;
  border-radius: 50%;
  margin-right: 5px;
  animation: sp-typing-bounce 1.2s infinite;
}
.sp-typing span:nth-child(2) { animation-delay: 0.2s; }
.sp-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sp-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}
.sp-typing.visible { display: flex; gap: 4px; align-items: center; padding: 12px 16px; }

/* --- Input --- */
.sp-chat-input {
  padding: 12px 14px;
  border-top: 1px solid #D9D0C5;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: #fff;
}
.sp-input-wrap {
  flex: 1;
  border: 1.5px solid #D9D0C5;
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  transition: border-color 0.15s;
}
.sp-input-wrap:focus-within { border-color: #C8960C; }
.sp-input-lang {
  padding: 0 10px;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 600;
  color: #C8960C;
  cursor: pointer;
  white-space: nowrap;
  border-right: 1px solid #D9D0C5;
  line-height: 40px;
}
#sp-input-field {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: #1C1917;
  background: none;
  min-height: 40px;
  max-height: 100px;
  resize: none;
  line-height: 1.5;
}
#sp-input-field::placeholder { color: #6B6460; }
[dir="rtl"] #sp-input-field { text-align: right; }

.sp-send-btn {
  background: #C8960C;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.sp-send-btn:hover:not(:disabled) { background: #b8870a; }
.sp-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Quote Card in chat --- */
.sp-quote-card {
  background: #0F1923;
  color: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-top: 4px;
  max-width: 82%;
  align-self: flex-start;
}
.sp-quote-card .sp-quote-title {
  font-family: 'Fraunces', serif;
  font-size: 14px;
  font-weight: 600;
  color: #C8960C;
  margin-bottom: 10px;
}
.sp-quote-card .sp-quote-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.sp-quote-card .sp-quote-items li {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  padding-left: 14px;
  position: relative;
}
.sp-quote-card .sp-quote-items li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: #C8960C;
  font-size: 11px;
}
.sp-quote-price {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 12px;
}
.sp-quote-url {
  display: inline-block;
  background: #C8960C;
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.sp-quote-url:hover { background: #b8870a; }