/* ═══════════════════════════════════════════════════════════
   AI Property Search — SmartSearch Widget CSS v2.0
   Design ispirato a Gardalive / Figma node 1128:9637
   ═══════════════════════════════════════════════════════════ */

/* ── Variables injected via JS on :root ─────────────────── */
:root {
  --aips-bg:      #ffffff;
  --aips-header:  #000000;
  --aips-htext:   #ffffff;
  --aips-accent:  #000000;
  --aips-radius:  20px;
  --aips-width:   420px;
}

/* ── Launcher FAB ────────────────────────────────────────── */
#aips-launcher {
  box-shadow: 0 4px 20px rgba(0,0,0,.28);
  transition: transform .2s ease, box-shadow .2s ease;
}
#aips-launcher:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 28px rgba(0,0,0,.32) !important;
}
#aips-launcher.aips-open {
  box-shadow: 0 2px 10px rgba(0,0,0,.2) !important;
}

/* ── Widget container ────────────────────────────────────── */
.aips-widget {
  width: var(--aips-width);
  max-width: calc(100vw - 32px);
  border-radius: var(--aips-radius);
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
  background: #fff;
  display: flex;
  flex-direction: column;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  animation: aips-slide-up .25s cubic-bezier(.34,1.4,.64,1) both;
}
@keyframes aips-slide-up {
  from { opacity:0; transform: translateY(16px) scale(.97); }
  to   { opacity:1; transform: translateY(0)    scale(1);   }
}
#aips-widget-root.aips-open-down .aips-widget { animation-name: aips-slide-down; }
@keyframes aips-slide-down {
  from { opacity:0; transform: translateY(-16px) scale(.97); }
  to   { opacity:1; transform: translateY(0)     scale(1);   }
}

/* ── Header ──────────────────────────────────────────────── */
.aips-header {
  background: var(--aips-header);
  display: flex;
  align-items: center;
  padding: 0 14px;
  height: 62px;
  gap: 11px;
  flex-shrink: 0;
}
.aips-header-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
  border: 1.5px solid rgba(255,255,255,.2);
}
.aips-header-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.aips-header-title {
  color: var(--aips-htext);
  font-size: 16px; font-weight: 600; flex: 1;
  letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aips-header-btn {
  background: none; border: none;
  color: rgba(255,255,255,.6);
  cursor: pointer; padding: 6px;
  border-radius: 6px; display: flex; align-items: center;
  transition: color .15s, background .15s;
}
.aips-header-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.aips-header-btn svg   { width: 18px; height: 18px; fill: currentColor; }

/* ── Chat scroll area ────────────────────────────────────── */
.aips-chat {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
  background: #fff; min-height: 280px; max-height: 400px;
  position: relative;
  scroll-behavior: auto;
}
.aips-chat::-webkit-scrollbar { width: 4px; }
.aips-chat::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 4px; }

/* ── Message rows ────────────────────────────────────────── */
.aips-msg { display: flex; align-items: flex-start; gap: 8px; }
.aips-msg.aips-user { flex-direction: row-reverse; }
.aips-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--aips-accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px; overflow: hidden;
}
.aips-avatar img  { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.aips-avatar svg  { width: 15px; height: 15px; fill: #fff; }

.aips-bubble {
  padding: 9px 13px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.55; max-width: 80%;
}
.aips-bubble.aips-bot  { background: rgba(0,0,0,.06); color: #000; border-radius: 4px 14px 14px 14px; }
.aips-bubble.aips-user { background: var(--aips-accent); color: #fff; border-radius: 14px 4px 14px 14px; }

/* ── Typing indicator ────────────────────────────────────── */
.aips-typing-dots { display: flex; gap: 4px; align-items: center; padding: 4px 2px; }
/* Nome proprio: .aips-dot sono i pallini del carosello più in basso, e vincevano loro
   (stessa specificità, definiti dopo) lasciando i puntini della bolla bianchi su bianco. */
.aips-typing-dot {
  width: 7px; height: 7px; background: #999; border-radius: 50%;
  animation: aips-bounce 1.3s ease-in-out infinite;
}
.aips-typing-dot:nth-child(2) { animation-delay: .18s; }
.aips-typing-dot:nth-child(3) { animation-delay: .36s; }
@keyframes aips-bounce {
  0%,80%,100% { transform: scale(.8); opacity:.5; }
  40%          { transform: scale(1.2); opacity:1; }
}

/* ── Property card ───────────────────────────────────────── */
/* Markup e classi della card del tema (modules/estate): qui solo ciò che il widget cambia. */
.aips-result-card { padding-left: 34px; font-family: var(--font-1, inherit); }
.aips-card { width: 100%; box-shadow: 0 1px 6px rgba(0,0,0,.13); }
/* Nel widget compatto la chat è alta 400px: foto 16:9 invece del quasi quadrato della lista. */
.aips-result-card .estate__top { aspect-ratio: 16/9; }
.aips-card-img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* La card del widget è più stretta di quella della lista: badge proprietà su una riga anche in EN/DE */
.aips-result-card .estate__properties-wrap { gap: 14px; }
.aips-result-card .estate__property span { white-space: nowrap; }
#aips-widget-root.aips-fullscreen .aips-result-card .estate__properties-wrap { gap: 24px; }
.aips-card-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  color: rgba(255,255,255,.35); font-size: 11px; letter-spacing: .15em; font-weight: 600;
}

/* ── Input bar ───────────────────────────────────────────── */
.aips-input-bar {
  padding: 9px 9px 6px; background: #fff;
  display: flex; gap: 5px; align-items: center;
  border-top: 1px solid rgba(0,0,0,.07);
}
.aips-icon-btn {
  width: 40px; height: 40px; border-radius: 6px;
  border: 1px solid rgba(0,0,0,.16);
  background: var(--aips-accent); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, transform .1s;
}
.aips-icon-btn:hover  { opacity: .88; }
.aips-icon-btn:active { transform: scale(.95); }
.aips-icon-btn svg { width: 17px; height: 17px; fill: #fff; }

.aips-input {
  flex: 1; border: 1px solid rgba(0,0,0,.14); border-radius: 6px;
  padding: 10px 12px; font-size: 13px; font-family: inherit;
  outline: none; color: #000; background: #fff; resize: none;
  height: 40px; transition: border-color .15s;
}
.aips-input:focus { border-color: rgba(0,0,0,.38); }
.aips-input::placeholder { color: rgba(0,0,0,.38); }
/* Il tema porta i campi a 16px sotto 768px (zoom di iOS): il testo scritto resta a 16px,
   il placeholder torna ai 13px del desktop, altrimenti a 360-390px è tagliato. */
@media screen and (max-width: 768px) {
  .aips-input { padding-inline: 10px; text-overflow: ellipsis; }
  .aips-input::placeholder { font-size: 13px; }
}

/* ── Disclaimer ──────────────────────────────────────────── */
.aips-disclaimer {
  text-align: center; font-size: 9px; color: rgba(0,0,0,.42);
  padding: 4px 10px 9px; background: #fff; line-height: 1.5;
}

/* ── Error / empty states ────────────────────────────────── */
.aips-notice {
  padding: 10px 13px; border-radius: 10px; font-size: 13px; line-height: 1.5;
  background: rgba(0,0,0,.05); color: #444;
}
.aips-notice.error { background: #fff0f0; color: #c00; }

/* ── Inline wrapper ──────────────────────────────────────── */
.aips-inline-wrapper .aips-widget {
  box-shadow: 0 0 0 1px rgba(0,0,0,.1), 0 4px 20px rgba(0,0,0,.12);
  width: 100%; max-width: 100%; border-radius: 16px;
}

/* ── Responsive ──────────────────────────────────────────── */
/* Il posizionamento mobile di #aips-widget-root è gestito inline dal PHP
   in base al breakpoint configurato. Qui solo il full-width del widget. */
@media (max-width: 480px) {
  .aips-widget { max-width: 100% !important; width: 100% !important; }
}

/* ── Vedi tutti ──────────────────────────────────────────── */
.aips-viewall-wrap{display:flex;justify-content:center;padding:6px 0 10px}
.aips-viewall{background:#000;color:#fff;border:none;border-radius:8px;padding:11px 22px;font-size:14px;font-weight:600;cursor:pointer;font-family:inherit;transition:opacity .15s,transform .15s;box-shadow:inset 0 0 0 1.5px rgba(255,255,255,.2)}
.aips-viewall:hover{opacity:.85;transform:translateY(-1px)}
.aips-viewall:disabled{opacity:.5;cursor:default}

/* ── Chip suggerimenti ───────────────────────────────────── */
.aips-suggestions { padding: 2px 4px 0; }
.aips-suggestions-title {
  font-size: 12px; color: #777; margin: 0 0 8px 2px; font-weight: 500;
}
.aips-suggestions-row { display: flex; flex-wrap: wrap; gap: 7px; }
.aips-chip {
  background: #fff; color: #222; border: 1.5px solid rgba(0,0,0,.14);
  border-radius: 999px; padding: 7px 13px; font-size: 12.5px; font-weight: 500;
  cursor: pointer; font-family: inherit; line-height: 1.3;
  transition: background .15s, border-color .15s, transform .1s;
}
.aips-chip:hover {
  background: var(--aips-accent, #000); color: #fff;
  border-color: var(--aips-accent, #000); transform: translateY(-1px);
}
.aips-chip:active { transform: translateY(0); }
.aips-choices .aips-chip-choice {
  border-color: var(--aips-accent, #000); font-weight: 600;
}
.aips-choices .aips-chip-choice:first-child {
  background: var(--aips-accent, #000); color: #fff;
}

/* ── Schermo intero ──────────────────────────────────────── */
.aips-btn-expand .aips-ico-collapse { display: none; }
#aips-widget-root.aips-fullscreen {
  top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
  width: 100% !important; max-width: none !important;
  height: 100% !important; transform: none !important;
  padding: 0 !important;
  z-index: 100001;   /* #vueHeader del tema sta a 100000 e copriva la testata del widget */
}
#aips-widget-root.aips-fullscreen .aips-widget {
  width: 100% !important; max-width: 100% !important; height: 100%;
  border-radius: 0; box-shadow: none; animation: none;
}
#aips-widget-root.aips-fullscreen .aips-btn-expand .aips-ico-expand { display: none; }
#aips-widget-root.aips-fullscreen .aips-btn-expand .aips-ico-collapse { display: block; }
/* Blocca lo scroll della pagina sotto al widget a schermo intero */
body.aips-fs-lock { overflow: hidden; }
/* Nascondi il FAB quando la chat è a schermo intero */
body.aips-fs-lock #aips-fab { display: none; }

/* ── Schermo intero: layout leggibile ────────────────────── */
/* La chat diventa una CSS Grid: le card occupano una cella ciascuna e restano
   allineate a sinistra anche quando l'ultima riga è incompleta (con flex +
   justify-content:center l'ultima riga si accentrava, creando l'effetto scalino).
   Tutti gli altri messaggi (bolle, chip, pulsanti) occupano l'intera riga. */
#aips-widget-root.aips-fullscreen .aips-chat {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  align-content: start;
  justify-content: center;   /* centra la griglia, non le singole card */
  gap: 14px;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  flex: 1;                   /* occupa l'altezza disponibile */
  max-height: none;          /* annulla il limite di 400px del widget compatto */
  overflow-y: auto;
}
/* Bolle, note, chip e pulsanti: riga intera, larghezza di lettura contenuta */
#aips-widget-root.aips-fullscreen .aips-chat > *:not(.aips-result-card) {
  grid-column: 1 / -1;
  max-width: 900px;
  width: 100%;
}
/* Le card riempiono la loro cella */
#aips-widget-root.aips-fullscreen .aips-result-card {
  width: 100%;
  max-width: none;
  padding-left: 0;   /* in griglia l'avatar è nascosto: niente rientro */
}
#aips-widget-root.aips-fullscreen .aips-chat > .aips-viewall-wrap { max-width: none; }
#aips-widget-root.aips-fullscreen .aips-result-card .aips-card { width: 100%; }
/* In griglia la foto torna quella della lista: quasi quadrata, 4:3 sotto i 768px (estate.scss) */
@media (min-width: 769px) {
  #aips-widget-root.aips-fullscreen .aips-result-card .estate__top { aspect-ratio: 1/1.02; }
}
/* L'avatar accanto alle card ruba spazio orizzontale: nascosto in griglia */
#aips-widget-root.aips-fullscreen .aips-result-card .aips-avatar { display: none; }

/* Mobile in fullscreen: una colonna */
@media (max-width: 700px) {
  #aips-widget-root.aips-fullscreen .aips-chat {
    grid-template-columns: 1fr;
    padding: 14px;
  }
}
body.aips-fs-lock { overflow: hidden; }
body.aips-fs-lock #aips-fab { display: none; }

/* ── Carosello foto nella card ───────────────────────────── */
.aips-slides { position: absolute; inset: 0; z-index: 0; }
/* Foto nascosta finché non è caricata: sotto c'è il placeholder della card del tema (onload in aips.js) */
.estate__body:not(.is-loaded) .aips-card-img.is-active { opacity: 0; }
.aips-slides .aips-card-img {
  position: absolute; inset: 0; opacity: 0; transition: opacity .25s ease;
  pointer-events: none;
}
.aips-slides .aips-card-img.is-active { opacity: 1; }
.aips-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border: none; border-radius: 50%;
  background: rgba(255,255,255,.9); cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 5px rgba(0,0,0,.22);
  opacity: 0; transition: opacity .2s; z-index: 2;
}
.estate__body:hover .aips-nav { opacity: 1; }
.aips-nav svg { width: 20px; height: 20px; fill: #222; }
.aips-prev { left: 7px; }
.aips-next { right: 7px; }
.aips-dots {
  position: absolute; top: 9px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 5px; z-index: 2;
}
.aips-dot {
  width: 6px; height: 6px; border-radius: 50%; cursor: pointer;
  background: rgba(255,255,255,.55); box-shadow: 0 0 2px rgba(0,0,0,.4);
  transition: background .2s;
}
.aips-dot.is-active { background: #fff; }
/* Su touch le frecce restano sempre visibili (niente hover) */
@media (hover: none) {
  .aips-nav { opacity: .85; }
}

/* ── Dark mode del tema (html[data-theme='dark'], vedi variables.scss) ──
   Stessa palette del tema: pannello nero come la pagina, card #1e1e1e, testo #e8e8e8;
   nero e bianco si invertono su bottoni, chip e bolla utente. Le ombre diventano
   bianche, altrimenti su fondo nero l'elevazione non si vede. */
html[data-theme='dark'] #aips-fab { filter: drop-shadow(0 0 10px rgba(255,255,255,.35)); }
html[data-theme='dark'] #aips-fab:hover { filter: drop-shadow(0 3px 14px rgba(255,255,255,.4)); }
html[data-theme='dark'] .aips-widget { background: #000; box-shadow: 0 8px 40px rgba(255,255,255,.18); }
html[data-theme='dark'] .aips-inline-wrapper .aips-widget { box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 4px 20px rgba(0,0,0,.4); }
html[data-theme='dark'] .aips-header { border-bottom: 1px solid rgba(255,255,255,.12); }
html[data-theme='dark'] .aips-chat,
html[data-theme='dark'] .aips-input-bar,
html[data-theme='dark'] .aips-disclaimer { background: #000; }
html[data-theme='dark'] .aips-chat::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); }
html[data-theme='dark'] .aips-avatar { background: #fff; }
html[data-theme='dark'] .aips-avatar svg { fill: #000; }
html[data-theme='dark'] .aips-bubble.aips-bot { background: rgba(255,255,255,.08); color: #e8e8e8; }
html[data-theme='dark'] .aips-bubble.aips-user { background: #fff; color: #000; }
html[data-theme='dark'] .aips-card { box-shadow: 0 1px 6px rgba(0,0,0,.5); }
html[data-theme='dark'] .aips-suggestions-title { color: #aaa; }
html[data-theme='dark'] .aips-input-bar { border-top-color: rgba(255,255,255,.1); }
html[data-theme='dark'] .aips-icon-btn { background: #fff; border-color: rgba(255,255,255,.2); }
html[data-theme='dark'] .aips-icon-btn svg { fill: #000; }
html[data-theme='dark'] .aips-input { color: #e8e8e8; background: #1e1e1e; border-color: rgba(255,255,255,.16); }
html[data-theme='dark'] .aips-input:focus { border-color: rgba(255,255,255,.45); }
html[data-theme='dark'] .aips-input::placeholder { color: rgba(255,255,255,.4); }
html[data-theme='dark'] .aips-disclaimer { color: rgba(255,255,255,.45); }
html[data-theme='dark'] .aips-notice { background: rgba(255,255,255,.06); color: #ccc; }
html[data-theme='dark'] .aips-notice.error { background: #3a1414; color: #ff8a8a; }
html[data-theme='dark'] .aips-viewall { background: #fff; color: #000; box-shadow: inset 0 0 0 1.5px rgba(0,0,0,.15); }
html[data-theme='dark'] .aips-chip { background: #1e1e1e; color: #e8e8e8; border-color: rgba(255,255,255,.2); }
html[data-theme='dark'] .aips-chip:hover,
html[data-theme='dark'] .aips-choices .aips-chip-choice:first-child { background: #fff; color: #000; border-color: #fff; }
html[data-theme='dark'] .aips-choices .aips-chip-choice { border-color: rgba(255,255,255,.6); }
