#popup {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#popup.popup-active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

#popup .popup-content {
  background: #fff;
  border-radius: 0.4rem;
  padding: 1.5rem;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-sizing: border-box;
}

/* Parte superiore: immagine + testo affiancati */
.popup-top {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.popup-img {
  flex: 0 0 220px;
  max-width: 220px;
  border-radius: 0.5rem;
  overflow: hidden;
  margin: 0;
}

.popup-img img {
  width: 100%;
  height: auto;
  display: block;
}

.popup-text {
  flex: 1;
  font-size: 1.1rem;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  justify-content: center;
}

.popup-text h3 {
  margin: 0 0 0.6rem;
  color: #04211A;
}

.popup-text p {
  margin: 0;
}

/* Form sotto */
.popup-form {
  width: 100%;
  margin-top: 1.5rem;
}

/* Eventuale vecchio pulsante */
.popup-button {
  display: inline-block;
  align-self: flex-start;
  margin-top: 0.2rem;
  background: #c2380c;
  color: #fff !important;
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  transition: background 0.3s ease;
}

.popup-button:hover {
  background: #084537;
  color: #fff !important;
}

/* Pulsante chiusura */
.popup-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  z-index: 2;
  width: 1rem;
  height: 1.5rem;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-overlay {
  position: absolute;
  inset: 0;
  z-index: -1;
}

/* Responsive */
@media (max-width: 768px) {

  #popup .popup-content {
    padding: 3rem 1rem 1.5rem;
    max-width: 92%;
  }

  .popup-top {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }

  .popup-close {
    top: 0.1rem;
    right: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0.2rem;
  }

  .popup-img {
    flex: none;
    width: 180px;
    max-width: 180px;
    margin: 0 auto;
    text-align: center;
  }

  .popup-img img {
    width: 100%;
    margin: 0 auto;
  }

  .popup-text {
    font-size: 1rem;
    text-align: center;
    align-items: center;
  }

  .popup-text h3 {
    font-size: 1.5rem;
    margin: 0 0 0.25rem;
  }

  .popup-form {
    margin-top: 1.25rem;
  }

  .popup-button {
    align-self: center;
    font-size: 1rem;
    padding: 0.6rem 1.2rem;
  }
}