/* ============================================================================
   Smallville AI — Chatbot Widget
   Brand colours: dark #141620 | yellow #ffc927 | red #e5232b | cream #e8e4d8
   ============================================================================ */

/* ── Floating bubble ─────────────────────────────────────────────────────── */

#smv-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ffc927;
  color: #141620;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.40);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#smv-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.50);
}

#smv-chat-bubble:focus-visible {
  outline: 3px solid #e5232b;
  outline-offset: 3px;
}

/* ── Panel ───────────────────────────────────────────────────────────────── */

#smv-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 9998;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 116px);
  background: #141620;
  border-radius: 16px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Hidden by default — transitions in */
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#smv-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

#smv-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: #1a1d2e;
  border-bottom: 2px solid #ffc927;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #ffc927;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}

#smv-chat-close {
  background: none;
  border: none;
  color: #e8e4d8;
  font-size: 22px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s;
}
#smv-chat-close:hover { opacity: 1; }

/* ── Messages area ───────────────────────────────────────────────────────── */

#smv-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  scrollbar-width: thin;
  scrollbar-color: #2e3250 transparent;
}

#smv-chat-messages::-webkit-scrollbar       { width: 4px; }
#smv-chat-messages::-webkit-scrollbar-thumb { background: #2e3250; border-radius: 2px; }

/* ── Message bubbles ─────────────────────────────────────────────────────── */

.smv-msg {
  max-width: 86%;
  padding: 9px 13px;
  border-radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.smv-msg--bot {
  background: #1e2030;
  color: #e8e4d8;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.smv-msg--user {
  background: #ffc927;
  color: #141620;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

/* ── Links inside bot messages ───────────────────────────────────────────── */

.smv-msg--bot a {
  color: #ffc927;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.smv-msg--bot a:hover {
  color: #fff;
}

/* ── Loading dots ────────────────────────────────────────────────────────── */

.smv-msg--loading {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}

.smv-msg--loading span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffc927;
  opacity: 0.5;
  animation: smv-dot-bounce 1.2s ease-in-out infinite;
}

.smv-msg--loading span:nth-child(2) { animation-delay: 0.15s; }
.smv-msg--loading span:nth-child(3) { animation-delay: 0.30s; }

@keyframes smv-dot-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%            { transform: scale(1.0); opacity: 1.0; }
}

/* ── Input row ───────────────────────────────────────────────────────────── */

#smv-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #2a2d40;
  background: #1a1d2e;
  flex-shrink: 0;
}

#smv-chat-input {
  flex: 1;
  min-width: 0;
  background: #252840;
  border: 1px solid #363a58;
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 14px;
  color: #e8e4d8;
  outline: none;
  transition: border-color 0.15s;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#smv-chat-input::placeholder { color: #5a5e7a; }
#smv-chat-input:focus        { border-color: #ffc927; }
#smv-chat-input:disabled     { opacity: 0.5; }

#smv-chat-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #e5232b;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
}

#smv-chat-send:hover    { background: #c71e24; }
#smv-chat-send:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  #smv-chat-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 82vh;
    max-height: 82vh;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.5);
  }

  #smv-chat-bubble {
    bottom: 16px;
    right: 16px;
  }
}
