/*
 * RWS Site: Landing Page
 * Template: Location v3.4.5
 * Stylesheet: RWS AI Sidebar Shell
 * Last Updated: 2026-10-23 v1.0.1 session continuity: pre-paint desktop restore (html.rws-ai-restore-open), .rws-ai-no-transition guard, mobile "Continue chat" launcher cue (.rws-ai-launcher__cue), "Ask about this listing" chip (.rws-ai-page-context / .rws-ai-page-chip), restored-conversation note (.rws-ai-entry--note); existing styles unchanged.
 * 2026-10-22 - Added location discovery table (.rws-ai-location-table) and Show More (.rws-ai-show-more) styles for Dashboard Preview parity; existing styles unchanged.
 * 2026-08-30 - Restored Preview UX visual hierarchy and binary launcher/sidebar states.
 */

body.rws-ai-enabled {
  --rws-ai-open-width: 440px;
  --rws-ai-surface: #ffffff;
  --rws-ai-border: #d9d9d9;
  --rws-ai-muted: #f7f9fc;
  --rws-ai-pill-bg: #d8e7ff;
  --rws-ai-pill-text: #0d4aa8;
  --rws-ai-brand: #1f6fff;
}

.rws-ai-launcher {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 1030;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  background: var(--rws-ai-brand);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}

.rws-ai-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  z-index: 1020;
}

.rws-ai-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--rws-ai-open-width);
  max-width: var(--rws-ai-open-width);
  height: 100vh;
  background: var(--rws-ai-surface);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.18);
  border-right: 1px solid var(--rws-ai-border);
  z-index: 1025;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.rws-ai-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e8e8e8;
  min-height: 56px;
  padding: 9px 12px 6px;
  gap: 8px;
}

.rws-ai-sidebar__title {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
  font-weight: 700;
  flex: 1;
}

.rws-ai-btn-icon {
  border: 0;
  background: transparent;
  color: #666666;
  border-radius: 6px;
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  font-size: 24px;
}

.rws-ai-sidebar__content {
  padding: 0 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  flex: 1 1 auto;
  background: #ffffff;
}

.rws-ai-welcome {
  margin-top: 2px;
}

.rws-ai-welcome.is-hidden {
  display: none;
}

.rws-ai-welcome__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}

.rws-ai-welcome__copy {
  margin-bottom: 4px;
  line-height: 1.35;
  color: #333333;
  font-size: 14px;
}

.rws-ai-error {
  margin: 0;
  display: none;
  font-size: 14px;
}

.rws-ai-transcript {
  display: none;
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  border: 1px solid var(--rws-ai-border);
  border-radius: 14px;
  background: var(--rws-ai-muted);
  padding: 8px;
}

.rws-ai-transcript.is-visible {
  display: block;
}

.rws-ai-entry {
  margin-bottom: 8px;
}

.rws-ai-speaker {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 1px;
}

.rws-ai-speaker--assistant {
  color: #6c757d;
}

.rws-ai-speaker--user {
  color: var(--rws-ai-brand);
}

.rws-ai-message {
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #dce3ef;
  background: #ffffff;
}

.rws-ai-message--assistant {
  background: #ffffff;
}

.rws-ai-message--user {
  background: #e7f2ff;
  border: 1px solid #c6ddff;
}

.rws-ai-guided-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.rws-ai-choice-card-stack {
  margin-top: 4px;
}

.rws-ai-choice-card {
  border: 1px solid var(--rws-ai-border);
  border-radius: 14px;
  background: #ffffff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  width: 100%;
  text-align: left;
}

.rws-ai-choice-card:disabled {
  opacity: 0.65;
}

.rws-ai-choice-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #f4f7fc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #2a2a2a;
  flex: 0 0 auto;
}

.rws-ai-choice-label {
  font-size: 14px;
  font-weight: 600;
}

.rws-ai-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rws-ai-choice-chip {
  border: 0;
  border-radius: 999px;
  background: var(--rws-ai-pill-bg);
  color: var(--rws-ai-pill-text);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.rws-ai-choice-chip:disabled {
  opacity: 0.65;
}

.rws-ai-listing-heading {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.3;
  color: #2f3b47;
}

.rws-ai-listing-table {
  width: 100%;
  table-layout: fixed;
  margin-bottom: 0;
  font-size: 13px;
}

.rws-ai-listing-table th,
.rws-ai-listing-table td {
  padding: 6px;
  vertical-align: middle;
}

.rws-ai-listing-detail {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  background: #ffffff;
}

.rws-ai-listing-thumb {
  width: 140px;
  max-width: 40%;
  flex: 0 0 auto;
}

.rws-ai-listing-thumb img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #dfe5ef;
}

.rws-ai-listing-info {
  flex: 1 1 auto;
  min-width: 0;
}

.rws-ai-listing-address {
  font-weight: 600;
  margin: 0 0 4px;
}

.rws-ai-listing-price {
  font-size: 16px;
  font-weight: 700;
  color: #0d4aa8;
  margin: 0 0 4px;
}

.rws-ai-listing-row {
  margin: 0 0 2px;
  font-size: 13px;
  color: #2f3b47;
}

.rws-ai-listing-muted {
  margin: 0;
  font-size: 12px;
  color: #6c757d;
}

.rws-ai-listing-view-btn {
  margin-top: 8px;
}

/* 2026-10-22 Community/location discovery table: name | Details. Fixed layout so long names wrap inside the
   first column instead of overflowing under the Details link (no horizontal scroll at 375px). */
.rws-ai-location-table {
  width: 100%;
  table-layout: fixed;
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.25;
}

.rws-ai-location-table th,
.rws-ai-location-table td {
  padding: 6px;
  vertical-align: middle;
}

.rws-ai-location-table th:nth-child(1),
.rws-ai-location-table td:nth-child(1) {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}

.rws-ai-location-table th:nth-child(2),
.rws-ai-location-table td:nth-child(2) {
  width: 4.75rem;
  white-space: nowrap;
}

.rws-ai-location-table a[href^="#rws-location-"] {
  font-size: 12px;
  white-space: nowrap;
}

/* 2026-10-22 Show More (listing and discovery continuation). */
.rws-ai-show-more {
  border: 0;
  border-radius: 999px;
  background: var(--rws-ai-brand);
  color: #ffffff;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  margin-top: 8px;
}

.rws-ai-show-more:disabled {
  opacity: 0.65;
}

.rws-ai-sidebar__footer {
  border-top: 1px solid #e8e8e8;
  background: #fff;
  padding: 8px 10px 8px;
}

.rws-ai-composer {
  border: 1px solid var(--rws-ai-border);
  border-radius: 12px;
  padding: 4px 8px;
  background: #ffffff;
  min-height: 50px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 0;
}

.rws-ai-composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: none;
  width: auto;
  min-height: 32px;
  max-height: 88px;
  font-size: 14px;
  color: #333333;
  background: transparent;
  line-height: 1.3;
  overflow-y: auto;
  margin: 0;
  padding: 5px 0;
}

.rws-ai-composer__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.rws-ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: #f0f0f0;
  color: #666666;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rws-ai-send-btn.is-ready {
  background: var(--rws-ai-brand);
  color: #ffffff;
}

.rws-ai-send-btn:disabled {
  opacity: 0.7;
}

.rws-ai-footer-meta {
  margin-top: 6px;
}

.rws-ai-new-chat {
  padding: 0;
  font-weight: 600;
  font-size: 12px;
}

.rws-ai-disclaimer {
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.3;
  color: #6c757d;
}

.rws-ai-status {
  min-height: 18px;
  font-size: 13px;
  color: #5f6b73;
  margin: 0;
}

body.rws-ai-enabled.rws-ai-sidebar-open .rws-ai-sidebar {
  transform: translateX(0);
}

body.rws-ai-enabled.rws-ai-sidebar-open .rws-ai-launcher {
  display: none;
}

@media (min-width: 992px) {
  body.rws-ai-enabled.rws-ai-sidebar-open #body-wrap {
    margin-left: var(--rws-ai-open-width);
    transition: margin-left 0.2s ease;
  }

  body.rws-ai-enabled:not(.rws-ai-sidebar-open) #body-wrap {
    margin-left: 0;
    transition: margin-left 0.2s ease;
  }
}

@media (max-width: 991px) {
  .rws-ai-launcher {
    left: 50%;
    transform: translateX(-50%);
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .rws-ai-sidebar {
    width: min(92vw, 420px);
    max-width: 420px;
  }

  body.rws-ai-enabled.rws-ai-sidebar-open .rws-ai-sidebar {
    transform: translateX(0);
  }

  body.rws-ai-enabled.rws-ai-sidebar-open .rws-ai-backdrop {
    opacity: 1;
    visibility: visible;
  }

  body.rws-ai-enabled.rws-ai-sidebar-open {
    overflow: hidden;
  }

  body.rws-ai-enabled.rws-ai-sidebar-open #body-wrap {
    margin-left: 0;
  }

  .rws-ai-listing-detail {
    flex-direction: column;
    gap: 8px;
  }

  .rws-ai-listing-thumb {
    width: min(145px, 60%);
    max-width: 60%;
  }
}

/* ---- 2026-10-23 v1.0.1 session continuity ---------------------------------------------------------------- */

/*
 * Desktop pre-paint restore. The header integration block adds html.rws-ai-restore-open before first paint when the
 * previous page left the sidebar open; these rules reserve exactly the layout the body classes produce once
 * rws-ai-sidebar.js initialises (440px push, sidebar in place, launcher hidden), so there is no layout jump. The script
 * removes the class; the header block also removes it after a few seconds if the script never runs.
 */
@media (min-width: 992px) {
  html.rws-ai-restore-open #body-wrap {
    margin-left: var(--rws-ai-open-width, 440px);
  }

  html.rws-ai-restore-open .rws-ai-sidebar {
    width: var(--rws-ai-open-width, 440px);
    max-width: var(--rws-ai-open-width, 440px);
    transform: translateX(0);
    transition: none;
  }

  html.rws-ai-restore-open .rws-ai-launcher {
    display: none;
  }
}

/* Applied by the script for ~60ms while it restores an open sidebar so nothing animates on page load. */
body.rws-ai-no-transition .rws-ai-sidebar,
body.rws-ai-no-transition #body-wrap,
body.rws-ai-no-transition .rws-ai-backdrop {
  transition: none !important;
}

/* Restored-conversation notes (trimmed history, interrupted message). */
.rws-ai-entry--note {
  margin: 4px 0 8px;
}

.rws-ai-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: #6c757d;
  text-align: center;
}

/* "Continue chat" launcher cue: mobile/tablet only; desktop reopens the sidebar itself. */
.rws-ai-launcher__cue {
  display: none;
}

@media (max-width: 991px) {
  .rws-ai-launcher--continue .rws-ai-launcher__cue {
    display: inline-block;
    margin-left: 2px;
    padding-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.55);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
  }
}

/* "Ask about this listing" chip: one quiet line above the composer. */
.rws-ai-page-context {
  padding: 6px 10px 0;
}

.rws-ai-page-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid var(--rws-ai-pill-text, #0d4aa8);
  border-radius: 999px;
  background: var(--rws-ai-pill-bg, #d8e7ff);
  color: var(--rws-ai-pill-text, #0d4aa8);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  padding: 5px 12px;
  cursor: pointer;
}

.rws-ai-page-chip:disabled {
  opacity: 0.6;
  cursor: default;
}

.rws-ai-page-chip__mls {
  font-weight: 400;
  opacity: 0.85;
}
