/* SpreeMart AI shopping assistant widget. Namespaced under #sm-chat-widget
   so nothing here leaks into/clashes with the rest of the site's CSS. */

#sm-chat-widget, #sm-chat-widget * {
  box-sizing: border-box;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

#sm-chat-bubble {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #13a7df;
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: transform 0.15s ease;
}
#sm-chat-bubble:hover { transform: scale(1.06); }

#sm-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
}
/* The [hidden] attribute normally means display:none by browser default,
   but that default has lower priority than the #sm-chat-panel rule above
   (an ID selector), so it was silently losing and the panel stayed
   visible - the actual bug behind "close doesn't do anything" - JS was
   correctly setting hidden=true the whole time, it just had no visual
   effect. This rule re-asserts it at matching specificity. */
#sm-chat-panel[hidden] {
  display: none;
}

#sm-chat-header {
  background: #13a7df;
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#sm-chat-header-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
#sm-chat-back {
  background: none; border: none; color: #fff; font-size: 16px; cursor: pointer; padding: 0 2px;
}
#sm-chat-header-actions { display: flex; gap: 6px; }
#sm-chat-header-actions button, #sm-chat-back {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#sm-chat-header-actions button:hover, #sm-chat-back:hover { background: rgba(255,255,255,0.28); }

#sm-chat-list-view { flex: 1; overflow-y: auto; background: #f7f8fa; }
#sm-chat-list { padding: 8px; }
.sm-chat-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #eaeaea;
  margin-bottom: 6px;
  cursor: pointer;
}
.sm-chat-list-item:hover { border-color: #13a7df; }
.sm-chat-list-item.active { border-color: #13a7df; background: #eef8fd; }
.sm-chat-list-item-title { font-size: 13px; color: #222; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.sm-chat-list-item-time { font-size: 11px; color: #999; flex-shrink: 0; }
.sm-chat-list-delete {
  background: none; border: none; color: #b33; cursor: pointer; font-size: 14px; flex-shrink: 0; padding: 2px 4px;
}
.sm-chat-list-empty { padding: 24px 12px; text-align: center; color: #888; font-size: 13px; }

#sm-chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#sm-chat-view[hidden] { display: none; }

#sm-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
}
.sm-chat-empty { color: #888; font-size: 13px; text-align: center; padding: 20px 10px; }

.sm-msg { max-width: 84%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; word-wrap: break-word; }
.sm-msg-user { align-self: flex-end; background: #13a7df; color: #fff; border-bottom-right-radius: 3px; }
.sm-msg-assistant { align-self: flex-start; background: #f1f3f5; color: #222; border-bottom-left-radius: 3px; }
.sm-msg p { margin: 0 0 6px; }
.sm-msg p:last-child { margin-bottom: 0; }
.sm-msg ul, .sm-msg ol { margin: 4px 0; padding-left: 20px; }
.sm-msg code { background: rgba(0,0,0,0.08); padding: 1px 4px; border-radius: 4px; font-size: 12px; }
.sm-msg pre { background: rgba(0,0,0,0.08); padding: 8px; border-radius: 6px; overflow-x: auto; margin: 6px 0; }
.sm-msg pre code { background: none; padding: 0; }

.sm-msg-typing { align-self: flex-start; display: flex; gap: 4px; padding: 10px 14px; }
.sm-msg-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: #aaa;
  animation: sm-typing-bounce 1.2s infinite ease-in-out;
}
.sm-msg-typing span:nth-child(2) { animation-delay: 0.15s; }
.sm-msg-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sm-typing-bounce { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

#sm-chat-error {
  margin: 0 14px 8px;
  padding: 8px 10px;
  background: #fdecea;
  color: #a33;
  border-radius: 6px;
  font-size: 12.5px;
}

#sm-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
#sm-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13.5px;
  max-height: 90px;
  overflow-y: auto;
}
#sm-chat-input:focus { outline: none; border-color: #13a7df; }
#sm-chat-input:disabled { background: #f5f5f5; }

#sm-chat-send {
  background: #13a7df;
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
#sm-chat-send:disabled { background: #a9d9ee; cursor: default; }

@media (max-width: 480px) {
  #sm-chat-panel { right: 12px; left: 12px; width: auto; bottom: 80px; }
  #sm-chat-bubble { right: 14px; bottom: 14px; }
}
