/* Ollie AI Chat Widget */
:root {
  --smrez-primary: var(--color-1);
  --smrez-primary-dark: var(--color-3);
  --smrez-bg: var(--color-lightest);
  --smrez-surface: var(--color-lighter);
  --smrez-border: var(--border-color);
  --smrez-text: var(--text-color);
  --smrez-text-muted: var(--color-4);
  --smrez-bubble-user: var(--color-success);
  --smrez-bubble-user-text: var(--color-success-reverse);
  --smrez-bubble-ai: var(--color-light);
  --smrez-bubble-ai-text: var(--text-color);
  --smrez-shadow: var(--shadow-very-far);
  --smrez-radius: var(--card-radius);
  --smrez-font: var(--font-sans-serif);
}

#smrez-chat-widget,
#smrez-chat-widget * {
  box-sizing: border-box;
}

#smrez-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: var(--smrez-font);
  /* Closed, the widget is only as wide as the toggle button so it does not sit on top of
     page content behind it. The full width is applied by the .open rule below. */
  width: auto;
  overflow: hidden;
}

#smrez-chat-widget.open {
  width: 33vw;
  max-width: calc(100vw - 48px);
}

/* Toggle Button */
#smrez-chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--smrez-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  outline: none;
  margin-left: auto;
}

#smrez-chat-toggle:hover {
  background: var(--smrez-primary-dark);
  transform: scale(1.05);
}

#smrez-chat-toggle svg {
  width: 28px;
  height: 28px;
  fill: #ffffff;
}

/* Hide the open-toggle while the window is open */
#smrez-chat-widget.open #smrez-chat-toggle { display: none; }

/* Chat Window */
#smrez-chat-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 100%;
  height: 560px;
  background: var(--smrez-bg);
  border-radius: var(--smrez-radius);
  box-shadow: var(--smrez-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--smrez-border);
  z-index: 9999;
}

#smrez-chat-widget.open #smrez-chat-window {
  display: flex;
  animation: smrez-slide-up 0.25s ease;
}

@keyframes smrez-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Header */
#smrez-chat-header {
  background: var(--smrez-primary);
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#smrez-chat-header .smrez-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

#smrez-chat-header .smrez-avatar img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 50%;
}

#smrez-chat-header-text { flex: 1; }

/* In-header close button */
#smrez-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background 0.15s;
}

#smrez-chat-close:hover {
  background: rgba(255,255,255,0.2);
}

#smrez-chat-close svg {
  width: 26px;
  height: 26px;
  fill: #ffffff;
}
#smrez-chat-header-text h3 {
  margin: 0 !important;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}
#smrez-chat-header-text p {
  margin: 0 !important;
  font-size: .8rem;
  opacity: 0.85;
  color: #fff;
}

/* Messages */
#smrez-chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
  background: var(--smrez-surface);
  scrollbar-width: thin;
  scrollbar-color: var(--smrez-border) transparent;
}

#smrez-chat-messages::-webkit-scrollbar { width: 4px; }
#smrez-chat-messages::-webkit-scrollbar-track { background: transparent; }
#smrez-chat-messages::-webkit-scrollbar-thumb { background: var(--smrez-border); border-radius: 4px; }

.smrez-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.smrez-msg.user { align-self: flex-end; align-items: flex-end; }
.smrez-msg.assistant { align-self: flex-start; align-items: flex-start; }

.smrez-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.1rem;
  word-wrap: break-word;
  font-family: var(--smrez-font);
}

.smrez-bubble ul,
.smrez-bubble ol {
  margin: 6px 0 4px 0;
  padding-left: 20px;
  font-size: .9rem;
  line-height: 1.1rem;
}

.smrez-bubble li {
  margin-bottom: 3px;
  font-size: .9rem;
  line-height: 1.1rem;
  font-family: var(--smrez-font);
}

.smrez-bubble code {
  background: rgba(0,0,0,0.08);
  border-radius: 3px;
  padding: 1px 4px;
  font-size: .9rem;
  line-height: 1.1rem;
  font-family: monospace;
}

.smrez-msg.user .smrez-bubble {
  background: var(--smrez-bubble-user);
  color: var(--smrez-bubble-user-text);
  border-bottom-right-radius: 4px;
}

.smrez-msg.assistant .smrez-bubble {
  background: var(--smrez-bubble-ai);
  color: var(--smrez-bubble-ai-text);
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.smrez-typing .smrez-bubble {
  padding: .8rem 1rem;
}

.smrez-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.smrez-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--smrez-text-muted);
  animation: smrez-bounce 1.2s infinite;
}

.smrez-dots span:nth-child(2) { animation-delay: 0.2s; }
.smrez-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes smrez-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* Property Cards */
.smrez-properties {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}

.smrez-property-card {
  background: #fff;
  border: 1px solid var(--smrez-border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  gap: 10px;
  padding: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s;
  text-decoration: none;
  color: inherit;
}

.smrez-property-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}

.smrez-property-card img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.smrez-property-card .smrez-prop-no-img {
  width: 70px;
  height: 70px;
  background: var(--smrez-surface);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--smrez-text-muted);
  font-size: .7rem;
}

.smrez-prop-info { flex: 1; min-width: 0; }

.smrez-prop-info h4 {
  margin: 0 0 3px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--smrez-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.smrez-prop-info p {
  margin: 0;
  font-size: .8rem;
  color: var(--smrez-text-muted);
  line-height: 1.4;
}

.smrez-prop-info .smrez-rate {
  margin-top: 4px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-2);
}

/* Input Area */
#smrez-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--smrez-border);
  background: var(--smrez-bg);
  flex-shrink: 0;
}

#smrez-chat-input {
  flex: 1;
  border: 1px solid var(--smrez-border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .85rem;
  font-family: var(--smrez-font);
  color: var(--smrez-text);
  background: var(--smrez-surface);
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: hidden;
  transition: border-color 0.2s;
  line-height: 1.4;
}

#smrez-chat-input:focus {
  border-color: var(--smrez-primary);
  background: #fff;
}

#smrez-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--smrez-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
  align-self: flex-end;
}

#smrez-chat-send:hover:not(:disabled) { background: var(--smrez-primary-dark); }
#smrez-chat-send:disabled { background: var(--smrez-border); cursor: not-allowed; }

#smrez-chat-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* Suggestion chips — quick-reply buttons rendered below a question bubble */
.smrez-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.smrez-suggestion-chip {
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--smrez-primary);
  background: transparent;
  color: var(--smrez-primary);
  font-size: .8rem;
  font-family: var(--smrez-font);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.smrez-suggestion-chip:hover {
  background: var(--smrez-primary);
  color: #fff;
}

/* Search Offer Actions */
.smrez-offer-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.smrez-offer-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: .85rem;
  font-family: var(--smrez-font);
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.smrez-offer-btn:active { transform: scale(0.97); }

.smrez-offer-btn--primary {
  background: var(--smrez-primary);
  color: #fff;
}

.smrez-offer-btn--primary:hover {
  background: var(--smrez-primary-dark);
}

.smrez-offer-btn--secondary {
  background: var(--smrez-surface);
  color: var(--smrez-text);
  border: 1px solid var(--smrez-border);
}

.smrez-offer-btn--secondary:hover {
  background: var(--smrez-border);
}

/* Responsive */
@media (max-width: 440px) {
  #smrez-chat-widget {
    right: 12px;
    bottom: 12px;
    z-index: 10000;
  }

  #smrez-chat-widget.open {
    width: calc(100vw - 24px);
  }

  #smrez-chat-window {
    /* Switch to fixed so the window is always relative to the viewport,
       preventing it from being covered by page elements or clipped by
       the widget's own stacking context on mobile browsers. */
    position: fixed;
    right: 12px;
    left: 12px;
    bottom: 78px;
    width: auto;
    height: calc(100svh - 110px);
    max-height: calc(100svh - 110px);
    z-index: 10000;
  }
}
