/* ============================================================
   VU AI Agent — Chat UI Styles
   Light theme — matches Vista Urbana vu_style.css design system.
   Scoped to .vu-chat; property card styles scoped to .vu-component.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --vu-bg:            #ffffff;
  --vu-surface:       #ffffff;
  --vu-surface-2:     #f8f8f8;
  --vu-surface-3:     #f0f0f0;
  --vu-border:        #e6e6e6;
  --vu-text:          #0a0a0a;
  --vu-text-muted:    #666666;
  --vu-text-soft:     #444444;
  --vu-accent:        #111111;
  --vu-accent-hover:  #333333;
  --vu-accent-dim:    rgba(0,0,0,0.05);
  --vu-user-bubble:   #f4f4f4;
  --vu-green:         #10b981;
  --vu-yellow:        #d97706;
  --vu-red:           #dc2626;
  --vu-radius:        12px;
  --vu-radius-sm:     8px;
  --vu-radius-xs:     4px;
  --vu-shadow:        0 2px 12px rgba(0,0,0,0.06);
}

html[data-theme="dark"] {
  --vu-bg:            #000000;
  --vu-surface:       #0b0b0b;
  --vu-surface-2:     #141414;
  --vu-surface-3:     #1a1a1a;
  --vu-border:        #222222;
  --vu-text:          #e6e6e6;
  --vu-text-muted:    #a3a3a3;
  --vu-text-soft:     #c0c0c0;
  --vu-accent:        #ffffff;
  --vu-accent-hover:  #cccccc;
  --vu-accent-dim:    rgba(255,255,255,0.07);
  --vu-user-bubble:   #1a1a1a;
  --vu-shadow:        0 2px 12px rgba(0,0,0,0.3);
}

/* ============================================================
   Chat Container
   ============================================================ */
.vu-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  max-width: 800px;
  margin: 0 auto;
  background: var(--vu-bg);
  font-family: "Inter", "Helvetica Neue", Arial, system-ui, sans-serif;
  font-weight: 300;
  color: var(--vu-text);
  font-size: 14px;
  line-height: 1.6;
}

/* Full-page layout when used as a dedicated /chat page */
.vu-chat-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================================
   Header
   ============================================================ */
.vu-chat__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--vu-border);
  background: var(--vu-surface);
  flex-shrink: 0;
}

.vu-chat__header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--vu-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #ffffff;
  flex-shrink: 0;
}

.vu-chat__header-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--vu-text);
}

.vu-chat__header-subtitle {
  font-size: 11px;
  color: var(--vu-text-muted);
}

.vu-chat__header-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vu-green);
  margin-left: auto;
}

/* ============================================================
   Messages Area
   ============================================================ */
.vu-chat__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.vu-chat__messages::-webkit-scrollbar { width: 4px; }
.vu-chat__messages::-webkit-scrollbar-track { background: transparent; }
.vu-chat__messages::-webkit-scrollbar-thumb { background: var(--vu-border); border-radius: 2px; }

/* ============================================================
   Message Rows
   ============================================================ */
.vu-message {
  display: flex;
  gap: 10px;
  max-width: 88%;
}

.vu-message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.vu-message--agent {
  align-self: flex-start;
}

.vu-message__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}

.vu-message--user .vu-message__avatar  { background: var(--vu-surface-3); color: var(--vu-text-muted); }
.vu-message--agent .vu-message__avatar { background: var(--vu-accent);    color: #ffffff; }

.vu-message__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

/* ============================================================
   Bubbles
   ============================================================ */
.vu-message__bubble {
  padding: 11px 15px;
  border-radius: var(--vu-radius);
  line-height: 1.6;
  word-break: break-word;
}

.vu-message--user .vu-message__bubble {
  background: var(--vu-user-bubble);
  border: 1px solid var(--vu-border);
  border-bottom-right-radius: var(--vu-radius-xs);
  color: var(--vu-text);
}

.vu-message--agent .vu-message__bubble {
  background: var(--vu-surface);
  border: 1px solid var(--vu-border);
  border-bottom-left-radius: var(--vu-radius-xs);
  color: var(--vu-text);
}

/* ============================================================
   Typing / Loading States
   ============================================================ */
.vu-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 11px 15px;
  background: var(--vu-surface);
  border: 1px solid var(--vu-border);
  border-radius: var(--vu-radius);
  border-bottom-left-radius: var(--vu-radius-xs);
  width: fit-content;
}

.vu-typing span {
  width: 6px;
  height: 6px;
  background: var(--vu-text-muted);
  border-radius: 50%;
  animation: vu-bounce 1.2s ease-in-out infinite;
}
.vu-typing span:nth-child(2) { animation-delay: 0.2s; }
.vu-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes vu-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.6; }
  30%            { transform: translateY(-5px); opacity: 1;   }
}

.vu-tool-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--vu-text-muted);
  padding: 4px 0;
}

.vu-tool-loading::before {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid var(--vu-border);
  border-top-color: var(--vu-accent);
  border-radius: 50%;
  animation: vu-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes vu-spin { to { transform: rotate(360deg); } }

/* ============================================================
   Slash Command Picker
   ============================================================ */
.vu-slash-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--vu-surface);
  border: 1px solid var(--vu-border);
  border-radius: var(--vu-radius);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  overflow: hidden;
  margin-bottom: 6px;
  z-index: 100;
}

.vu-slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--vu-border);
  transition: background 0.1s;
}

.vu-slash-item:last-child { border-bottom: none; }

.vu-slash-item--active,
.vu-slash-item:hover {
  background: var(--vu-surface-2);
}

.vu-slash-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.vu-slash-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--vu-text);
  flex-shrink: 0;
}

.vu-slash-desc {
  font-size: 12px;
  color: var(--vu-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   Input Area
   ============================================================ */
.vu-chat__input-area {
  position: relative;
  padding: 12px 16px 20px;
  border-top: 1px solid var(--vu-border);
  background: var(--vu-bg);
  flex-shrink: 0;
}

.vu-chat__input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--vu-surface);
  border: 1px solid var(--vu-border);
  border-radius: 24px;
  padding: 8px 8px 8px 16px;
  transition: border-color 0.2s;
}

.vu-chat__input-row:focus-within {
  border-color: var(--vu-accent);
}

.vu-chat__textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--vu-text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  padding: 4px 0;
}

.vu-chat__textarea::placeholder { color: var(--vu-text-muted); }
.vu-chat__textarea:disabled     { opacity: 0.5; cursor: not-allowed; }

.vu-chat__send {
  width: 36px;
  height: 36px;
  background: var(--vu-accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}

.vu-chat__send:hover:not(:disabled) {
  background: var(--vu-accent-hover);
  transform: scale(1.05);
}

.vu-chat__send:disabled {
  background: var(--vu-surface-3);
  cursor: not-allowed;
  transform: none;
}

.vu-chat__send svg {
  width: 16px;
  height: 16px;
  fill: white;
}

.vu-chat__hint {
  font-size: 11px;
  color: var(--vu-text-muted);
  text-align: center;
  margin-top: 8px;
}

/* ============================================================
   Welcome / Empty State
   ============================================================ */
.vu-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
  gap: 12px;
}

.vu-welcome__icon {
  font-size: 36px;
  margin-bottom: 4px;
}

.vu-welcome__title {
  font-size: 18px;
  font-weight: 600;
}

.vu-welcome__subtitle {
  color: var(--vu-text-muted);
  font-size: 13px;
  max-width: 320px;
}

.vu-welcome__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.vu-welcome__chip {
  background: var(--vu-surface-2);
  border: 1px solid var(--vu-border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--vu-text-soft);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.vu-welcome__chip:hover {
  background: var(--vu-accent-dim);
  border-color: var(--vu-accent);
  color: var(--vu-text);
}

/* ============================================================
   Rich UI Components (SSR injected via x-html)
   ============================================================ */
.vu-component {
  background: var(--vu-surface-2);
  border: 1px solid var(--vu-border);
  border-radius: var(--vu-radius);
  padding: 16px;
  overflow: hidden;
  box-shadow: var(--vu-shadow);
}

.component-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--vu-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.component-icon { font-size: 14px; }

/* ── Listing Grid — horizontal scroll carousel ── */
.listing-grid__items {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  gap: 12px;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.listing-grid__items::-webkit-scrollbar { height: 3px; }
.listing-grid__items::-webkit-scrollbar-track { background: transparent; }
.listing-grid__items::-webkit-scrollbar-thumb { background: var(--vu-border); border-radius: 2px; }

/* ── Property Card — matches main app .property-card exactly ── */
.vu-component .property-card {
  flex: 0 0 220px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--vu-surface);
  border: 1px solid var(--vu-border);
  box-shadow: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  scroll-snap-align: start;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.vu-component .property-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  text-decoration: none;
}

.vu-component .property-image-container {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--vu-surface-3);
}

.vu-component .property-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Badge — identical to main app */
.vu-component .property-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #ffffff;
}

.vu-component .property-badge--venda   { background-color: #3b82f6; }
.vu-component .property-badge--sale    { background-color: #3b82f6; }
.vu-component .property-badge--aluguel { background-color: #10b981; }
.vu-component .property-badge--rent    { background-color: #10b981; }

.vu-component .property-details { padding: 10px 12px 12px; }

.vu-component .property-price {
  font-size: 17px;
  font-weight: 700;
  color: var(--vu-text);
  margin-bottom: 3px;
  letter-spacing: -0.01em;
}

.vu-component .property-address {
  font-size: 12px;
  color: var(--vu-text-muted);
  line-height: 1.4;
  margin-bottom: 6px;
  word-wrap: break-word;
}

.vu-component .property-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11px;
  color: var(--vu-text-muted);
}

.vu-component .property-info span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.empty-state {
  color: var(--vu-text-muted);
  font-size: 13px;
  text-align: center;
  padding: 16px 0;
}

/* ── Metric Card ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  background: var(--vu-surface);
  border: 1px solid var(--vu-border);
  border-radius: var(--vu-radius-sm);
  text-align: center;
}

.metric-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--vu-text);
}

.metric-label {
  font-size: 10px;
  color: var(--vu-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Score / Map Preview ── */
.score-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.score-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.score-item--wide { margin-top: 4px; }

.score-label {
  font-size: 12px;
  color: var(--vu-text-soft);
  font-weight: 500;
}

.score-bar-track {
  width: 100%;
  height: 6px;
  background: var(--vu-surface-3);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  background: var(--vu-accent);
  border-radius: 3px;
  transition: width 0.6s ease;
}

.score-bar-fill--green { background: var(--vu-green); }

.score-value {
  font-size: 16px;
  font-weight: 700;
}

.score-unit {
  font-size: 11px;
  font-weight: 400;
  color: var(--vu-text-muted);
}

.gisrank-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.gisrank-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--vu-surface);
  border: 1px solid var(--vu-border);
  border-radius: var(--vu-radius-sm);
  padding: 8px 10px;
}

.gisrank-icon  { font-size: 14px; }
.gisrank-label { font-size: 11px; color: var(--vu-text-muted); flex: 1; }
.gisrank-value { font-size: 14px; font-weight: 700; }

/* ── Bar Chart ── */
.chart-container {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 110px;
  padding-bottom: 4px;
}

.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  gap: 4px;
  justify-content: flex-end;
}

.bar-count {
  font-size: 10px;
  color: var(--vu-text-muted);
}

.bar {
  width: 100%;
  background: var(--vu-accent);
  border-radius: var(--vu-radius-xs) var(--vu-radius-xs) 0 0;
  min-height: 4px;
  transition: opacity 0.2s;
}

.bar:hover { opacity: 0.8; }

.bar-label {
  font-size: 9px;
  color: var(--vu-text-muted);
  text-align: center;
  word-break: break-all;
  line-height: 1.2;
}

.chart-footnote {
  font-size: 11px;
  color: var(--vu-text-muted);
  margin-top: 8px;
  text-align: right;
}

/* ── Data Table ── */
.table-wrapper {
  overflow-x: auto;
}

.vu-component table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.vu-component th {
  background: var(--vu-surface);
  padding: 8px 10px;
  text-align: left;
  color: var(--vu-text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.vu-component td {
  padding: 8px 10px;
  border-top: 1px solid var(--vu-border);
  color: var(--vu-text-soft);
  white-space: nowrap;
}

.vu-component tr:hover td { background: var(--vu-surface); }

.table-footnote {
  font-size: 11px;
  color: var(--vu-text-muted);
  margin-top: 8px;
  text-align: center;
}

/* ── Knowledge Sources ── */
.knowledge-sources__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.knowledge-source-card {
  background: var(--vu-surface);
  border: 1px solid var(--vu-border);
  border-radius: 8px;
  padding: 10px 12px;
}

.knowledge-source-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.knowledge-source-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--vu-text);
  line-height: 1.3;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-source-relevance {
  font-size: 10px;
  font-weight: 500;
  color: var(--vu-accent);
  background: var(--vu-accent-dim);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.knowledge-source-id {
  font-size: 10px;
  color: var(--vu-text-muted);
  margin-bottom: 6px;
}

.knowledge-source-excerpt {
  font-size: 12px;
  color: var(--vu-text-soft);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Alert ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
}

.alert--info    { border-color: var(--vu-accent); background: var(--vu-accent-dim); }
.alert--warning { border-color: var(--vu-yellow); background: rgba(245,166,35,0.1); }
.alert--error   { border-color: var(--vu-red);    background: rgba(224,82,82,0.1);  }
.alert--success { border-color: var(--vu-green);  background: rgba(76,175,80,0.1);  }

.alert-icon    { font-size: 16px; flex-shrink: 0; }
.alert-message { font-size: 13px; line-height: 1.5; }

/* ============================================================
   Mobile & Native-App Feel
   iOS safe areas, 44px touch targets, no zoom, momentum scroll
   ============================================================ */

/* ── Ionic Icons — size + alignment ── */
ion-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  pointer-events: none;
  font-size: inherit;
  line-height: 1;
}

.vu-chat__header-avatar ion-icon { font-size: 15px; color: #ffffff; }
.vu-message__avatar ion-icon     { font-size: 14px; }
.component-icon ion-icon         { font-size: 14px; }
.vu-slash-icon ion-icon          { font-size: 16px; }
.alert-icon ion-icon             { font-size: 16px; }
.gisrank-icon ion-icon           { font-size: 14px; color: var(--vu-text-muted); }
.score-label ion-icon            { font-size: 12px; margin-right: 3px; color: var(--vu-text-muted); }
.vu-welcome__icon ion-icon       { font-size: 36px; color: var(--vu-text-muted); }
.vu-welcome__chip ion-icon       { font-size: 13px; margin-right: 4px; color: var(--vu-text-muted); }
.vu-chat__send ion-icon          { font-size: 18px; color: #ffffff; }
/* Replace old SVG rule */
.vu-chat__send svg { display: none; }

/* Prevent iOS double-tap zoom on buttons */
* { -webkit-tap-highlight-color: transparent; }

/* Momentum scrolling on the messages area */
.vu-chat__messages {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Horizontal property-card strip — touch scroll */
.listing-grid__items {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* iOS safe area: pad the input area so it clears the home indicator */
.vu-chat__input-area {
  padding-bottom: max(20px, calc(12px + env(safe-area-inset-bottom)));
}

/* Ensure send button always meets 44×44 tap target */
.vu-chat__send {
  width: 44px;
  height: 44px;
}

@media (max-width: 600px) {
  /* Lock the chat to the dynamic viewport height so the flex column never overflows.
     dvh updates when the on-screen keyboard appears/disappears, keeping the input in view. */
  .vu-chat {
    max-width: 100%;
    border-radius: 0;
    height: 100dvh;          /* override parent's 100% — use actual viewport */
    max-height: 100dvh;
    overflow: hidden;        /* nothing can scroll out of this box */
  }

  /* Messages fill remaining space and scroll internally */
  .vu-chat__messages {
    flex: 1 1 0;             /* critical: allow shrink below content size */
    min-height: 0;
    overflow-y: auto;
    padding: 16px 12px;
    gap: 16px;
  }

  /* Input area stays glued to the bottom — never scrolls */
  .vu-chat__input-area {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding: 10px 12px max(16px, calc(8px + env(safe-area-inset-bottom)));
  }

  /* Prevent iOS textarea zoom (requires ≥16px font) */
  .vu-chat__textarea {
    font-size: 16px;
  }

  /* Messages can use more width on small screens */
  .vu-message {
    max-width: 96%;
  }

  /* Chips wrap more tightly */
  .vu-welcome__chips {
    gap: 6px;
  }

  .vu-welcome__chip {
    font-size: 13px;
    padding: 8px 14px;
  }

  /* Property cards: narrower on mobile so 1.5 are visible = clear swipeable hint */
  .vu-component .property-card {
    flex: 0 0 180px;
  }

  /* Component block full-width, no side padding */
  .vu-component {
    padding: 12px;
  }
}

/* ============================================================
   Conversation Sidebar
   ============================================================ */

/* Outer shell: sidebar + chat side by side */
.vu-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: var(--vu-bg);
  font-family: "Inter", "Helvetica Neue", Arial, system-ui, sans-serif;
}

/* Make .vu-chat fill remaining space inside the shell */
.vu-shell .vu-chat {
  flex: 1;
  min-width: 0;
  max-width: none;
  margin: 0;
  height: 100%;
}

/* ── Sidebar panel ── */
.vu-sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--vu-surface-2);
  border-right: 1px solid var(--vu-border);
  transition: transform 0.25s ease;
  overflow: hidden;
}

.vu-sidebar__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--vu-border);
  flex-shrink: 0;
}

.vu-sidebar__title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--vu-text-muted);
  flex: 1;
}

.vu-sidebar__new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--vu-radius-sm);
  border: 1px solid var(--vu-border);
  background: var(--vu-bg);
  color: var(--vu-text);
  cursor: pointer;
  font-size: 18px;
  transition: background 0.15s, border-color 0.15s;
}

.vu-sidebar__new-btn:hover {
  background: var(--vu-accent);
  border-color: var(--vu-accent);
  color: #fff;
}

/* ── Search ── */
.vu-sidebar__search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--vu-border);
  position: relative;
  flex-shrink: 0;
}

.vu-sidebar__search-input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  border-radius: var(--vu-radius-sm);
  border: 1px solid var(--vu-border);
  background: var(--vu-bg);
  color: var(--vu-text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.vu-sidebar__search-input:focus {
  border-color: var(--vu-accent);
}

.vu-sidebar__search-icon {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--vu-text-muted);
  font-size: 14px;
  pointer-events: none;
}

/* ── Conversation list ── */
.vu-sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.vu-sidebar__empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--vu-text-muted);
}

/* ── Conversation item ── */
.vu-conv-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: var(--vu-radius-sm);
  margin: 1px 6px;
  transition: background 0.12s;
  min-width: 0;
}

.vu-conv-item:hover {
  background: var(--vu-border);
}

.vu-conv-item--active {
  background: var(--vu-surface-3);
}

.vu-conv-item__title {
  flex: 1;
  font-size: 13px;
  font-weight: 400;
  color: var(--vu-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.vu-conv-item--active .vu-conv-item__title {
  font-weight: 500;
}

.vu-conv-item__date {
  font-size: 11px;
  color: var(--vu-text-muted);
  flex-shrink: 0;
}

.vu-conv-item__delete {
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--vu-radius-xs);
  border: none;
  background: transparent;
  color: var(--vu-text-muted);
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  padding: 0;
}

.vu-conv-item:hover .vu-conv-item__delete {
  display: flex;
}

.vu-conv-item__delete:hover {
  color: var(--vu-red);
  background: rgba(220, 38, 38, 0.08);
}

/* ── Sidebar toggle (hamburger) — desktop hidden, mobile visible ── */
.vu-sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--vu-text);
  cursor: pointer;
  font-size: 22px;
  border-radius: var(--vu-radius-sm);
  flex-shrink: 0;
}

.vu-sidebar-toggle:hover {
  background: var(--vu-border);
}

/* ── Mobile: sidebar becomes an overlay drawer ── */
@media (max-width: 700px) {
  .vu-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80vw;
    max-width: 300px;
    z-index: 200;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
  }

  .vu-sidebar--open {
    transform: translateX(0);
  }

  .vu-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 199;
    backdrop-filter: blur(2px);
  }

  .vu-sidebar-overlay--visible {
    display: block;
  }

  .vu-sidebar-toggle {
    display: flex;
  }

}

/* ============================================================
   Dark mode — icon contrast fixes
   Accent becomes white (#ffffff) in dark mode, so icons inside
   accent-coloured backgrounds need to flip to black.
   ============================================================ */
html[data-theme="dark"] .vu-chat__header-avatar,
html[data-theme="dark"] .vu-chat__header-avatar ion-icon {
  color: #000000;
}

html[data-theme="dark"] .vu-message--agent .vu-message__avatar {
  color: #000000;
}

html[data-theme="dark"] .vu-message--agent .vu-message__avatar ion-icon {
  color: #000000;
}

html[data-theme="dark"] .vu-chat__send:not(:disabled) ion-icon {
  color: #000000;
}
