/* iRendity — Favorites & Compare UI (modale auth-gate, toast, stati) */

/* === Auth-gate modal === */
.auth-gate-overlay{
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(10, 21, 18, 0.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; transition: opacity .18s ease;
}
.auth-gate-overlay[hidden]{ display: none; }
.auth-gate-overlay.is-open{ opacity: 1; }

.auth-gate-modal{
  background: #fff;
  border-radius: 14px;
  width: 100%; max-width: 420px;
  padding: 28px 28px 24px;
  box-shadow: 0 20px 60px rgba(10, 21, 18, .25);
  position: relative;
  text-align: center;
  transform: translateY(10px);
  transition: transform .18s ease;
  outline: none;
}
.auth-gate-overlay.is-open .auth-gate-modal{ transform: translateY(0); }

.auth-gate-close{
  position: absolute; top: 10px; right: 12px;
  width: 32px; height: 32px;
  background: transparent; border: 0;
  font-size: 24px; line-height: 1; color: #9FA39D;
  cursor: pointer; border-radius: 50%;
  transition: background .15s, color .15s;
}
.auth-gate-close:hover{ background: #F2F1EA; color: #0A1512; }

.auth-gate-icon{
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: rgba(30, 122, 87, .08);
  color: #1E7A57;
  display: flex; align-items: center; justify-content: center;
}
.auth-gate-title{
  font-size: 1.15rem; font-weight: 700;
  color: #0A1512; margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.auth-gate-text{
  font-size: .92rem; color: #4E5652;
  margin: 0 0 20px; line-height: 1.45;
}
.auth-gate-actions{
  display: flex; flex-direction: column; gap: 8px;
}
.auth-gate-btn{
  display: block; width: 100%;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: .94rem; font-weight: 600;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s;
}
.auth-gate-btn--primary{
  background: #1E7A57; color: #fff;
}
.auth-gate-btn--primary:hover{ background: #1E7A57; color: #fff; }
.auth-gate-btn--secondary{
  background: #fff; color: #0A1512;
  border: 1px solid #D5D5CF;
}
.auth-gate-btn--secondary:hover{ background: #F2F1EA; }

@media (min-width: 480px){
  .auth-gate-actions{ flex-direction: row; }
  .auth-gate-btn{ flex: 1; }
}

/* === Toast (accessibile: aria-live, CTA, chiusura) === */
.fc-toast{
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0A1512; color: #fff;
  padding: 12px 14px 12px 18px;
  border-radius: 10px;
  font-size: .88rem; font-weight: 500;
  box-shadow: 0 10px 30px rgba(10, 21, 18, .35);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 10001;
  max-width: calc(100vw - 32px);
  width: max-content;
  display: flex; align-items: flex-start; gap: 6px;
}
.fc-toast.is-visible{
  opacity: 1; transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.fc-toast[data-kind="success"]{ background: #065f46; }
.fc-toast[data-kind="error"]{ background: #991b1b; }

.fc-toast__body{
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0; padding-top: 3px;
}
.fc-toast__msg{ line-height: 1.35; }
.fc-toast__hint{
  font-size: .8rem; font-weight: 400; color: rgba(255,255,255,.85);
  line-height: 1.35;
}
.fc-toast__action{
  display: inline-flex; align-items: center;
  align-self: flex-start;
  min-height: 44px; margin-top: 2px; padding: 5px 14px;
  background: #fff; color: #0A1512;
  border-radius: 7px;
  font-weight: 700; font-size: .85rem;
  text-decoration: none;
}
.fc-toast__action:hover{ background: #F2F1EA; color: #0A1512; text-decoration: none; }
.fc-toast__close{
  flex: 0 0 auto;
  width: 44px; height: 44px; margin: -8px -10px 0 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 8px;
  color: rgba(255,255,255,.8);
  font-size: 20px; line-height: 1; cursor: pointer;
}
.fc-toast__close:hover{ background: rgba(255,255,255,.14); color: #fff; }
.fc-toast__action:focus-visible,
.fc-toast__close:focus-visible{
  outline: 2px solid #fff; outline-offset: 2px;
}

/* === Badge numerico nav "Confronti" === */
.cmp-nav-badge{
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  margin-left: 5px;
  border-radius: 999px;
  background: #1E7A57; color: #fff;
  font-size: .72rem; font-weight: 700; line-height: 1;
  vertical-align: middle;
}
.cmp-nav-badge[hidden]{ display: none; }

/* === Tray persistente confronto (pagine ricerca/scheda) === */
.cmp-tray{
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 950; /* sopra sticky CTA scheda (900), sotto header/cookie banner (10000+) */
  background: #fff;
  border-top: 1px solid #EAE9E3;
  box-shadow: 0 -6px 24px rgba(10, 21, 18, .12);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  transform: translateY(110%);
  transition: transform .25s ease;
}
.cmp-tray[hidden]{ display: none; }
.cmp-tray.is-visible{ transform: translateY(0); }

.cmp-tray__thumbs{ display: flex; gap: 6px; flex: 0 0 auto; }
.cmp-tray__thumb{
  width: 44px; height: 44px;
  border-radius: 8px; overflow: hidden;
  border: 1px solid #EAE9E3; background: #F2F1EA;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem; color: #1E7A57;
}
.cmp-tray__thumb img{ width: 100%; height: 100%; object-fit: cover; display: block; }

.cmp-tray__info{ flex: 1 1 180px; min-width: 0; }
.cmp-tray__count{ font-weight: 700; color: #0A1512; font-size: .92rem; }
.cmp-tray__hint{ color: #4E5652; font-size: .8rem; margin-top: 2px; line-height: 1.35; }

.cmp-tray__actions{ display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.cmp-tray__open{
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 18px;
  background: #1E7A57; color: #fff;
  border-radius: 8px; font-weight: 700; font-size: .9rem;
  text-decoration: none; white-space: nowrap;
}
.cmp-tray__open:hover{ background: #16603F; color: #fff; text-decoration: none; }
.cmp-tray__clear{
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 14px;
  background: #fff; color: #0A1512;
  border: 1px solid #D5D5CF; border-radius: 8px;
  font-weight: 600; font-size: .9rem; cursor: pointer;
}
.cmp-tray__clear:hover{ background: #F2F1EA; }
.cmp-tray__open:focus-visible,
.cmp-tray__clear:focus-visible{
  outline: 2px solid #1E7A57; outline-offset: 2px;
}

/* Il contenuto non deve finire sotto il tray */
body.has-cmp-tray{ padding-bottom: 96px; }

/* Scheda immobile mobile: il tray si alza sopra la sticky CTA esistente */
@media (max-width: 768px){
  .cmp-tray--lifted{
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: 10px;
  }
  body.has-cmp-tray .property-detail-container{ padding-bottom: 180px; }
}
@media (max-width: 480px){
  .cmp-tray{ gap: 10px; padding-left: 12px; padding-right: 12px; }
  .cmp-tray__thumb{ width: 40px; height: 40px; }
  .cmp-tray__open{ padding: 10px 14px; }
}

/* === Favorite (heart) active state === */
.property-favorite{ user-select: none; }
.property-favorite.is-favorited{
  background: #fff;
  color: #ef4444;
}
.property-favorite.is-favorited svg{
  fill: #ef4444; stroke: #ef4444;
}
.property-favorite.is-loading{ opacity: .55; pointer-events: none; }

/* === Compare button (listing card overlay) === */
.property-compare{
  position: absolute;
  top: 56px; right: 14px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border: 0; border-radius: 50%;
  cursor: pointer;
  color: #4E5652;
  transition: all .2s;
  padding: 0;
}
.property-compare:hover{
  background: #fff; color: #1E7A57; transform: scale(1.08);
}
.property-compare.is-compared{
  background: #1E7A57; color: #fff;
}
.property-compare.is-compared:hover{ background: #1E7A57; color: #fff; }
.property-compare.is-loading{ opacity: .55; pointer-events: none; }

/* Icona di conferma (check) sui bottoni card listing: due SVG nel markup,
   lo stato .is-compared decide quale è visibile. */
.property-compare .cmp-ico--added{ display: none; }
.property-compare.is-compared .cmp-ico--add{ display: none; }
.property-compare.is-compared .cmp-ico--added{ display: block; }

/* Override scoped: polish-6-1.css applica `display: block` a TUTTI gli svg
   dentro i bottoni overlay delle card (selettore più specifico). Ripetiamo
   il toggle con la stessa scoping + classe svg per vincere in specificità. */
article.property-card .property-image .property-compare svg.cmp-ico--added,
.property-card--home .property-image .property-compare svg.cmp-ico--added{ display: none; }
article.property-card .property-image .property-compare.is-compared svg.cmp-ico--add,
.property-card--home .property-image .property-compare.is-compared svg.cmp-ico--add{ display: none; }
article.property-card .property-image .property-compare.is-compared svg.cmp-ico--added,
.property-card--home .property-image .property-compare.is-compared svg.cmp-ico--added{ display: block; }

/* Label pseudo-elemento della pill card (polish-6-1.css: content 'Confronta'):
   nello stato attivo comunica l'avvenuta aggiunta. Il testo per screen reader
   resta l'aria-label aggiornata dal JS ("Aggiunto al confronto — …"). */
article.property-card .property-image .property-compare.is-compared::after,
.property-card--home .property-image .property-compare.is-compared::after{ content: 'Aggiunto'; }

/* === Compare button (detail page, secondary CTA stile invariato) === */
.btn-compact.is-compared{
  background: #EFFAF4; border-color: #DCF5E9; color: #1E7A57;
}
.btn-compact.is-compared i{ color: #1E7A57; }

/* ===== DARK MODE ===== */
/* Auth-gate modal — superficie elevata scura */
html[data-theme="dark"] .auth-gate-modal{
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-modal);
}
html[data-theme="dark"] .auth-gate-close{
  color: var(--color-text-muted);
}
html[data-theme="dark"] .auth-gate-close:hover{
  background: var(--color-bg-muted);
  color: var(--color-text-strong);
}
html[data-theme="dark"] .auth-gate-icon{
  background: var(--color-accent-soft);
  color: var(--color-text-link);
}
html[data-theme="dark"] .auth-gate-title{
  color: var(--color-text-strong);
}
html[data-theme="dark"] .auth-gate-text{
  color: var(--color-text-muted);
}
html[data-theme="dark"] .auth-gate-btn--secondary{
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
html[data-theme="dark"] .auth-gate-btn--secondary:hover{
  background: var(--color-surface-raised);
}

/* Toast — è scuro by design (fondo #0A1512): resta leggibile su dark.
   Aggiungiamo un bordo di stacco dal fondo pagina scuro. */
html[data-theme="dark"] .fc-toast{
  border: 1px solid var(--color-border);
}

/* Tray persistente confronto — superficie scura con bordo top */
html[data-theme="dark"] .cmp-tray{
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
}
html[data-theme="dark"] .cmp-tray__thumb{
  border: 1px solid var(--color-border);
  background: var(--color-bg-muted);
  color: var(--color-text-link);
}
html[data-theme="dark"] .cmp-tray__count{
  color: var(--color-text-strong);
}
html[data-theme="dark"] .cmp-tray__hint{
  color: var(--color-text-muted);
}
html[data-theme="dark"] .cmp-tray__clear{
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
html[data-theme="dark"] .cmp-tray__clear:hover{
  background: var(--color-surface-raised);
}

/* Favorite (heart) attivo — su dark la superficie base è scura */
html[data-theme="dark"] .property-favorite.is-favorited{
  background: var(--color-surface-raised);
  color: #ef4444;
}

/* Compare button overlay card — superficie scura leggibile su foto */
html[data-theme="dark"] .property-compare{
  background: rgba(18, 33, 26, 0.9);
  color: var(--color-text-muted);
}
html[data-theme="dark"] .property-compare:hover{
  background: var(--color-surface-raised);
  color: var(--color-text-link);
}

/* Compare button detail page (secondary CTA) */
html[data-theme="dark"] .btn-compact.is-compared{
  background: var(--color-accent-soft);
  border-color: var(--color-border);
  color: var(--color-text-link);
}
html[data-theme="dark"] .btn-compact.is-compared i{
  color: var(--color-text-link);
}
