/* ============================================
   AVM Widget — Immovare Style + WOW Effects
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&display=swap');

:root {
  --avm-primary: #F2E347;
  --avm-primary-hover: #e8d93a;
  --avm-secondary: #A2E9EE;
  --avm-secondary-dark: #7dd4db;
  --avm-text: #1a2b33;
  --avm-text-muted: #5a6f7a;
  --avm-white: #ffffff;
  --avm-shadow: 0 8px 32px rgba(26, 43, 51, 0.12);
  --avm-shadow-lg: 0 16px 48px rgba(26, 43, 51, 0.18);
  --avm-radius: 12px;
  --avm-radius-lg: 20px;
  --avm-transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --avm-font: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---- Widget Container ---- */
.avm-widget {
  position: relative;
  font-family: var(--avm-font);
  color: var(--avm-text);
  max-width: 680px;
  width: 100%;
  overflow: hidden;
}

/* Google Places: append su body — deve stare sopra modali (10050) e cookie FAB */
body > .pac-container,
.pac-container {
  z-index: 2147483646 !important;
  font-family: var(--avm-font);
  border-radius: var(--avm-radius);
  box-shadow: var(--avm-shadow-lg);
  border: none;
  margin-top: 4px;
}

/* ---- Progress Bar ---- */
.avm-progress-wrap {
  margin-bottom: 28px;
}

.avm-progress-track {
  height: 4px;
  background: rgba(26, 43, 51, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.avm-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--avm-primary), #ffe566);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.avm-progress-bar::after {
  content: '';
  position: absolute;
  right: 0;
  top: -2px;
  width: 8px;
  height: 8px;
  background: var(--avm-primary);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--avm-primary);
  animation: avm-glow-pulse 1.5s ease-in-out infinite;
}

@keyframes avm-glow-pulse {
  0%, 100% { box-shadow: 0 0 8px var(--avm-primary); }
  50% { box-shadow: 0 0 20px var(--avm-primary), 0 0 40px rgba(242, 227, 71, 0.4); }
}

.avm-steps-indicator {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  padding: 0 2px;
}

.avm-step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(26, 43, 51, 0.15);
  transition: all var(--avm-transition);
}

.avm-step-dot.active {
  background: var(--avm-primary);
  transform: scale(1.3);
  box-shadow: 0 0 8px rgba(242, 227, 71, 0.6);
}

.avm-step-dot.done {
  background: var(--avm-secondary-dark);
}

/* ---- Steps Container ---- */
.avm-steps-container {
  position: relative;
  min-height: 200px;
}

.avm-step {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  transform: translateX(60px);
  transition: all var(--avm-transition);
  pointer-events: none;
}

.avm-step.avm-step-active {
  position: relative;
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  pointer-events: auto;
}

.avm-step.avm-step-exit-left {
  transform: translateX(-60px);
  opacity: 0;
}

.avm-step.avm-step-exit-right {
  transform: translateX(60px);
  opacity: 0;
}

.avm-animate-in {
  animation: avm-fade-up 0.6s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes avm-fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Typography ---- */
.avm-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--avm-text-muted) !important;
  margin-bottom: 16px;
  animation: avm-fade-up 0.8s 0.2s both;
}

.avm-arrow-down {
  animation: avm-bounce 2s ease-in-out infinite;
  color: var(--avm-text-muted);
}

@keyframes avm-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

.avm-step-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 20px;
  animation: avm-fade-up 0.5s both;
}

.avm-subtitle {
  font-size: 14px;
  color: var(--avm-text-muted);
  margin: -12px 0 20px;
}

/* ---- Address Row ---- */
.avm-address-row {
  display: flex;
  gap: 12px;
  animation: avm-fade-up 0.8s 0.4s both;
}

.avm-input-wrap {
  flex: 1;
  position: relative;
}

.avm-input-glow {
  position: absolute;
  inset: -2px;
  border-radius: var(--avm-radius);
  background: linear-gradient(135deg, var(--avm-primary), var(--avm-secondary));
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s;
}

.avm-input-wrap:focus-within .avm-input-glow {
  opacity: 0.5;
  animation: avm-input-glow 2s ease-in-out infinite;
}

@keyframes avm-input-glow {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* ---- Inputs ---- */
.avm-input {
  width: 100%;
  padding: 16px 20px;
  font-family: var(--avm-font);
  font-size: 16px;
  font-weight: 500;
  color: var(--avm-text);
  background: var(--avm-white);
  border: 2px solid transparent;
  border-radius: var(--avm-radius);
  box-shadow: var(--avm-shadow);
  outline: none;
  transition: all 0.3s;
  box-sizing: border-box;
}

.avm-input:focus {
  border-color: var(--avm-primary);
  box-shadow: var(--avm-shadow), 0 0 0 4px rgba(242, 227, 71, 0.25);
}

.avm-input::placeholder {
  color: #a0b0b8;
}

/* ---- Buttons ---- */
.avm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 28px;
  font-family: var(--avm-font);
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: var(--avm-radius);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  white-space: nowrap;
}

.avm-btn-primary {
  background: var(--avm-primary);
  color: var(--avm-text) !important;
  box-shadow: 0 4px 16px rgba(242, 227, 71, 0.4);
}

.avm-btn-primary:hover {
  background: var(--avm-primary-hover);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(242, 227, 71, 0.5);
}

.avm-btn-primary:active {
  transform: translateY(0) scale(0.98);
}

.avm-btn-glow {
  animation: avm-btn-glow 2s ease-in-out infinite;
}

@keyframes avm-btn-glow {
  0%, 100% { box-shadow: 0 4px 16px rgba(242, 227, 71, 0.4); }
  50% { box-shadow: 0 4px 24px rgba(242, 227, 71, 0.7), 0 0 40px rgba(242, 227, 71, 0.2); }
}

.avm-btn-ghost {
  background: transparent;
  color: var(--avm-text-muted);
  padding: 16px 20px;
}

.avm-btn-ghost:hover {
  color: var(--avm-text);
  background: rgba(26, 43, 51, 0.05);
}

/* ---- Cards Grid (Typology) ---- */
.avm-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.avm-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  background: var(--avm-white);
  border: 2px solid transparent;
  border-radius: var(--avm-radius-lg);
  box-shadow: var(--avm-shadow);
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  animation: avm-card-in 0.5s both;
}

.avm-card:nth-child(1) { animation-delay: 0.1s; }
.avm-card:nth-child(2) { animation-delay: 0.2s; }
.avm-card:nth-child(3) { animation-delay: 0.3s; }
.avm-card:nth-child(4) { animation-delay: 0.4s; }

@keyframes avm-card-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.avm-card:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: var(--avm-shadow-lg);
  border-color: var(--avm-secondary);
}

.avm-card.selected {
  border-color: var(--avm-primary);
  background: linear-gradient(135deg, #fffef5, #fff);
  box-shadow: 0 8px 32px rgba(242, 227, 71, 0.3);
  transform: scale(1.02);
}

.avm-card-icon {
  font-size: 32px;
  transition: transform 0.3s;
}

.avm-card:hover .avm-card-icon,
.avm-card.selected .avm-card-icon {
  transform: scale(1.2);
}

.avm-card-label {
  font-size: 14px;
  font-weight: 600;
}

/* ---- Form Grid ---- */
.avm-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.avm-form-grid-1 {
  grid-template-columns: 1fr;
}

.avm-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--avm-text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---- Counter ---- */
.avm-counter {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--avm-white);
  border-radius: var(--avm-radius);
  box-shadow: var(--avm-shadow);
  overflow: hidden;
}

.avm-counter-btn {
  width: 48px;
  height: 52px;
  border: none;
  background: transparent;
  font-size: 20px;
  font-weight: 600;
  color: var(--avm-text);
  cursor: pointer;
  transition: background 0.2s;
}

.avm-counter-btn:hover {
  background: var(--avm-secondary);
}

.avm-input-counter {
  text-align: center;
  border: none;
  box-shadow: none;
  padding: 16px 8px;
  font-size: 20px;
  font-weight: 700;
  width: 60px;
}

/* ---- Pills ---- */
.avm-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.avm-pill {
  padding: 10px 18px;
  font-family: var(--avm-font);
  font-size: 13px;
  font-weight: 600;
  background: var(--avm-white);
  border: 2px solid transparent;
  border-radius: 50px;
  box-shadow: var(--avm-shadow);
  cursor: pointer;
  transition: all 0.3s;
}

.avm-pill:hover {
  border-color: var(--avm-secondary);
  transform: translateY(-1px);
}

.avm-pill.active {
  background: var(--avm-primary);
  border-color: var(--avm-primary);
  box-shadow: 0 4px 12px rgba(242, 227, 71, 0.4);
}

/* ---- Checkbox ---- */
.avm-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--avm-text-muted);
  margin-bottom: 20px;
  cursor: pointer;
}

.avm-checkbox input {
  margin-top: 2px;
  accent-color: var(--avm-primary);
  width: 18px;
  height: 18px;
}

.avm-checkbox a {
  color: var(--avm-text);
  font-weight: 600;
}

/* ---- Navigation ---- */
.avm-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

/* ---- Error ---- */
.avm-error {
  color: #e53935;
  font-size: 13px;
  font-weight: 500;
  margin-top: 12px;
  animation: avm-shake 0.4s;
}

@keyframes avm-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ---- Result ---- */
.avm-result {
  text-align: center;
  animation: avm-fade-up 0.6s both;
}

.avm-result-icon {
  margin-bottom: 16px;
}

.avm-house-pulse {
  color: var(--avm-primary);
  animation: avm-house-bounce 1s ease-in-out;
}

@keyframes avm-house-bounce {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.avm-result-title {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 24px;
}

.avm-price-reveal {
  background: var(--avm-white);
  border-radius: var(--avm-radius-lg);
  padding: 32px;
  box-shadow: var(--avm-shadow-lg);
  margin-bottom: 20px;
  animation: avm-price-pop 0.8s 0.3s both;
}

@keyframes avm-price-pop {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.avm-price-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--avm-text-muted);
  margin-bottom: 8px;
}

.avm-price-value {
  display: block;
  font-size: 42px;
  font-weight: 800;
  color: var(--avm-text);
  line-height: 1.1;
  animation: avm-count-glow 2s ease-in-out infinite;
}

@keyframes avm-count-glow {
  0%, 100% { text-shadow: none; }
  50% { text-shadow: 0 0 20px rgba(242, 227, 71, 0.3); }
}

.avm-price-range {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e8eef2;
}

.avm-price-range-item span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--avm-text-muted);
  margin-bottom: 4px;
}

.avm-price-range-item strong {
  font-size: 18px;
  font-weight: 700;
}

.avm-result-meta {
  font-size: 13px;
  color: var(--avm-text-muted);
  margin-bottom: 8px;
}

.avm-result-email {
  font-size: 14px;
  color: var(--avm-text);
  margin-bottom: 24px;
}

.avm-result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---- Loading Overlay ---- */
.avm-widget [hidden] {
  display: none !important;
}

.avm-loading[hidden] {
  display: none !important;
}

.avm-loading:not([hidden]) {
  position: absolute;
  inset: 0;
  background: rgba(162, 233, 238, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: var(--avm-radius-lg);
  animation: avm-fade-in 0.3s;
}

@keyframes avm-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.avm-loading-house {
  animation: avm-house-float 1.5s ease-in-out infinite;
}

@keyframes avm-house-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.avm-house-body {
  animation: avm-house-color 2s ease-in-out infinite;
}

@keyframes avm-house-color {
  0%, 100% { fill: #F2E347; }
  50% { fill: #ffe566; }
}

.avm-loading-text {
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 8px;
  animation: avm-text-pulse 1.5s ease-in-out infinite;
}

@keyframes avm-text-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.avm-loading-dots {
  display: flex;
  gap: 6px;
}

.avm-loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--avm-text);
  border-radius: 50%;
  animation: avm-dot-bounce 1.2s ease-in-out infinite;
}

.avm-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.avm-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes avm-dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---- Confetti ---- */
.avm-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .avm-address-row {
    flex-direction: column;
  }

  .avm-btn-primary {
    width: 100%;
  }

  .avm-cards-grid {
    grid-template-columns: 1fr 1fr;
  }

  .avm-form-grid {
    grid-template-columns: 1fr;
  }

  .avm-price-value {
    font-size: 32px;
  }

  .avm-price-range {
    gap: 24px;
  }

  .avm-result-actions {
    flex-direction: column;
  }

  .avm-result-actions .avm-btn {
    width: 100%;
  }
}

/* ---- Modal overlay (menu rapido Valuta / data-avm-open) ---- */
.avm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 43, 51, 0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.avm-modal-overlay.open {
  display: flex;
}

.avm-modal-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: visible;
  background: #fff;
  border-radius: 18px;
  padding: 28px 24px 24px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.avm-modal-panel .avm-widget {
  max-width: none;
  width: 100%;
  overflow: visible;
}

.avm-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #f1f7f9;
  color: #1a2b33;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.avm-modal-close:hover {
  background: #e4eef1;
}

/* Mobile: modale valutazione a tutto schermo (come listing) */
@media (max-width: 768px) {
  .avm-modal-overlay {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  .avm-modal-panel {
    width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: 100%;
    border-radius: 0;
    padding: 20px 16px 28px;
    box-shadow: none;
  }
}

