/* ═══════════════════════════════════════════════════════════════
   SMART PEDALER — AI chat widget
   Floating assistant, available on every page.
   ═══════════════════════════════════════════════════════════════ */

#sp-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 3000;
  font-family: 'Inter', sans-serif;
}

#sp-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f5c842, #e0a92e);
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(224,169,46,0.45);
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#sp-toggle:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 12px 30px rgba(224,169,46,0.55); }
#sp-widget.sp-open #sp-toggle { transform: scale(0.94); }

#sp-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #dc2626;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 6px;
  border: 2px solid #fff;
}

#sp-panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: 70vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#sp-widget.sp-open #sp-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

#sp-header {
  background: #0f172a;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
#sp-header-text { display: flex; flex-direction: column; gap: 2px; }
#sp-header-text strong { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.01em; }
#sp-header-text span { font-size: 0.68rem; color: rgba(255,255,255,0.55); text-transform: uppercase; letter-spacing: 0.06em; }
#sp-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
#sp-close:hover { color: #fff; background: rgba(255,255,255,0.08); }

#sp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f9fafb;
}

.sp-msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.sp-msg-assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #111827;
  border-bottom-left-radius: 4px;
}
.sp-msg-user {
  align-self: flex-end;
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.sp-msg-error {
  align-self: flex-start;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-bottom-left-radius: 4px;
}
.sp-typing { opacity: 0.65; font-style: italic; }
.sp-typing-dots span {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #9ca3af;
  margin-right: 3px;
  animation: sp-bounce 1.2s infinite ease-in-out;
}
.sp-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.sp-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sp-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-4px); opacity: 1; } }

#sp-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  background: #f9fafb;
  flex-shrink: 0;
}
.sp-suggestion {
  font-size: 0.72rem;
  font-weight: 500;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #374151;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.sp-suggestion:hover { border-color: #f5c842; color: #92660c; background: rgba(245,200,66,0.08); }

#sp-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}
#sp-input {
  flex: 1;
  padding: 10px 13px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#sp-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
#sp-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: #f5c842;
  color: #1a1a2e;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
#sp-send:hover { background: #e0a92e; }
#sp-send:disabled { opacity: 0.5; cursor: not-allowed; }

#sp-footnote {
  font-size: 0.63rem;
  color: #9ca3af;
  text-align: center;
  padding: 0 12px 10px;
  background: #fff;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  #sp-widget { bottom: 16px; right: 16px; }
  #sp-panel {
    position: fixed;
    inset: auto 12px 86px 12px;
    width: auto;
    max-width: none;
    height: 68vh;
    max-height: 68vh;
  }
  #sp-toggle { width: 54px; height: 54px; font-size: 1.4rem; }
}
