/* ==============================================
   Support Pilot — always-visible help widget
   Independent from EODR Voice Pilot
   ============================================== */

/* ---------- FAB (floating action button) — pill style, chat icon ---------- */

.sp-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  left: auto;
  z-index: 9000;
  width: 56px;
  height: 48px;
  border-radius: 9999px;
  border: none;
  background: #2563eb;
  color: #fff;
  font-size: 0;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.sp-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.sp-fab:active {
  transform: scale(0.98);
}

.sp-fab--hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.6);
}

.sp-fab__badge-dot {
  position: absolute;
  top: 6px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

.sp-fab__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.sp-fab__svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* ---------- Panel ---------- */

.sp-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  left: auto;
  z-index: 9001;
  width: 380px;
  max-height: min(600px, calc(100vh - 48px));
  border-radius: 16px;
  background: var(--bg-primary, #ffffff);
  border: 1px solid var(--border-primary, rgba(0, 0, 0, 0.08));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.sp-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---------- Header ---------- */

.sp-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-primary, rgba(0, 0, 0, 0.06));
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  flex-shrink: 0;
}

.sp-panel__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sp-panel__logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.sp-panel__title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.sp-panel__header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sp-panel__close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.sp-panel__voice-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.sp-panel__voice-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
}

.sp-panel__voice-toggle--off {
  opacity: 0.6;
}

.sp-panel__close:hover {
  color: #fff;
}

/* ---------- Body ---------- */

.sp-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

/* ---------- Welcome ---------- */

.sp-welcome-text {
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--text-primary, #1a1a2e);
  font-weight: 500;
}

/* ---------- Category buttons ---------- */

.sp-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sp-cat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-primary, rgba(0, 0, 0, 0.08));
  background: var(--bg-secondary, #f8f9fc);
  color: var(--text-primary, #1a1a2e);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  width: 100%;
  text-align: left;
}

.sp-cat-btn:hover {
  background: var(--bg-hover, #eef0f6);
  border-color: #6366f1;
  transform: translateX(2px);
}

.sp-cat-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.sp-cat-label {
  flex: 1;
}

/* ---------- FAQ list (inside messages) ---------- */

.sp-faq-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sp-faq-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-primary, rgba(0, 0, 0, 0.06));
  background: var(--bg-primary, #fff);
  color: #4f46e5;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.sp-faq-btn:hover {
  background: #eef2ff;
}

/* ---------- Guide steps ---------- */

.sp-guide {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sp-guide-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary, #64748b);
  line-height: 1.5;
}

.sp-guide-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.sp-guide-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #6366f1;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.sp-guide-step-body {
  flex: 1;
  font-size: 13px;
  line-height: 1.5;
}

.sp-guide-step-body strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text-primary, #1a1a2e);
}

.sp-guide-step-body p {
  margin: 0;
  color: var(--text-secondary, #64748b);
}

/* ---------- Messages ---------- */

.sp-panel__messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sp-msg {
  display: flex;
}

.sp-msg--user {
  justify-content: flex-end;
}

.sp-msg--assistant {
  justify-content: flex-start;
}

.sp-msg__bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.sp-msg--user .sp-msg__bubble {
  background: #6366f1;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.sp-msg--assistant .sp-msg__bubble {
  background: var(--bg-secondary, #f1f3f9);
  color: var(--text-primary, #1a1a2e);
  border-bottom-left-radius: 4px;
}

.sp-msg--interactive .sp-msg__bubble {
  padding: 8px 10px;
  background: transparent;
}

/* ---------- Typing / thinking indicator ---------- */

.sp-msg__bubble--thinking {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sp-thinking-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
}

.sp-typing-dots {
  display: inline-flex;
  gap: 3px;
}

.sp-typing-dots span {
  display: inline-block;
  font-size: 20px;
  line-height: 1;
  animation: spBounce 1.2s infinite ease-in-out;
  color: #6366f1;
}

.sp-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.sp-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes spBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ---------- Input area ---------- */

.sp-panel__input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-primary, rgba(0, 0, 0, 0.06));
  flex-shrink: 0;
}

.sp-mic {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-primary, rgba(0, 0, 0, 0.1));
  background: var(--bg-secondary, #f8f9fc);
  color: var(--text-primary, #1a1a2e);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.sp-mic:hover {
  background: var(--bg-hover, #eef0f6);
  border-color: #6366f1;
}

.sp-mic.sp-mic--listening {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  animation: spMicPulse 1.2s ease-in-out infinite;
}

@keyframes spMicPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { opacity: 0.9; box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.sp-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border-primary, rgba(0, 0, 0, 0.1));
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  background: var(--bg-primary, #fff);
  color: var(--text-primary, #1a1a2e);
  outline: none;
  transition: border-color 0.15s;
  max-height: 120px;
}

.sp-input:focus {
  border-color: #6366f1;
}

.sp-send {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: #6366f1;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.sp-send:hover {
  background: #4f46e5;
}

/* ---------- Loading ---------- */

.sp-loading {
  font-size: 13px;
  color: var(--text-secondary, #64748b);
  text-align: center;
  padding: 12px;
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  .sp-panel {
    width: calc(100vw - 24px);
    right: 12px;
    left: auto;
    bottom: 12px;
    max-height: calc(100vh - 24px);
  }

  .sp-fab {
    bottom: 16px;
    right: 16px;
    left: auto;
    width: 50px;
    height: 44px;
  }

  .sp-fab__svg {
    width: 22px;
    height: 22px;
  }

  .sp-fab__badge-dot {
    top: 5px;
    right: 8px;
    width: 6px;
    height: 6px;
  }
}
