/* Stili Targa d'Obbligo PSR - pagina Aiuti e Contributi (responsive) */
.bando-container {
  font-family: Arial, sans-serif;
  border: 1px solid #000000;
  width: 100%;
  max-width: 900px;
  margin: 1.25rem auto;
  padding: clamp(0.75rem, 2.5vw, 1rem);
  background-color: #ffffff;
  box-sizing: border-box;
  overflow-x: hidden;
}

.bando-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
  gap: clamp(0.5rem, 2vw, 1rem);
  align-items: center;
  border-bottom: 3px solid #5b9bd5;
  padding-bottom: clamp(0.75rem, 2vw, 1rem);
  margin-bottom: clamp(0.75rem, 2vw, 1rem);
}

.header-logo {
  text-align: center;
  min-width: 0;
}

.header-logo img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: clamp(52px, 12vw, 90px);
  margin: 0 auto;
  object-fit: contain;
}

.bando-main {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.75rem, 2.5vw, 1.25rem);
  align-items: stretch;
}

.bando-sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.25rem);
  flex: 0 0 150px;
  width: 150px;
  min-width: 0;
}

.sidebar-logo {
  text-align: center;
  width: 100%;
}

.sidebar-logo img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

.logo-gal img,
.sidebar-logo:first-child img {
  max-height: clamp(90px, 22vw, 160px);
}

.logo-leader img,
.sidebar-logo:nth-child(2) img {
  max-height: clamp(70px, 16vw, 120px);
}

.logo-regione img {
  max-height: clamp(80px, 18vw, 110px);
}

.bando-content {
  flex: 1 1 0;
  min-width: min(100%, 280px);
  border: 1px solid #000000;
  padding: clamp(0.875rem, 2.5vw, 1.25rem);
  color: #000000;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bando-content h2 {
  font-size: clamp(1rem, 2.8vw, 1.3rem);
  font-weight: bold;
  margin-top: 0;
  margin-bottom: 0.35rem;
  color: #000000;
  line-height: 1.25;
}

.bando-content h3 {
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  font-weight: bold;
  margin-top: 0;
  margin-bottom: 0.35rem;
  color: #000000;
  line-height: 1.3;
}

.bando-pal {
  font-size: clamp(0.95rem, 2.2vw, 1.1rem);
  font-weight: bold;
  margin-bottom: clamp(0.75rem, 2vw, 1.25rem);
  line-height: 1.35;
}

.bando-operazione {
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  line-height: 1.5;
  margin-bottom: clamp(1rem, 2.5vw, 1.5rem);
  text-align: left;
  hyphens: auto;
}

.bando-details {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  line-height: 1.6;
}

.bando-details p {
  margin: 0.25rem 0;
}

.bando-atto {
  margin-top: 0.875rem !important;
}

.bando-content a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Tablet: header su due righe, sidebar affiancata al testo se c'è spazio */
@media (max-width: 900px) {
  .bando-header {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .logo-ue {
    grid-column: 1 / -1;
  }

  .logo-ue img {
    max-height: clamp(56px, 10vw, 80px);
  }
}

/* Mobile: contenuto prima, loghi sotto in griglia */
@media (max-width: 768px) {
  .bando-container {
    margin: 0.75rem auto;
    border-left: none;
    border-right: none;
  }

  .bando-main {
    flex-direction: column;
  }

  .bando-content {
    order: 1;
    width: 100%;
  }

  .bando-sidebar {
    order: 2;
    flex: 1 1 100%;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem 1.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid #e0e0e0;
  }

  .sidebar-logo {
    flex: 1 1 calc(33.333% - 1rem);
    max-width: 140px;
    margin-bottom: 0;
  }

  .logo-regione {
    flex: 1 1 100%;
    max-width: 220px;
  }
}

/* Smartphone stretto */
@media (max-width: 520px) {
  .bando-header {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .logo-ue {
    grid-column: auto;
  }

  .header-logo img {
    max-height: clamp(48px, 14vw, 72px);
  }

  .bando-sidebar {
    gap: 0.75rem;
  }

  .sidebar-logo {
    flex: 1 1 calc(50% - 0.75rem);
    max-width: 160px;
  }

  .sidebar-logo:nth-child(2) {
    flex: 1 1 calc(50% - 0.75rem);
  }

  .logo-regione {
    flex: 1 1 100%;
    max-width: 200px;
  }

  .bando-operazione {
    text-align: left;
  }
}

/* Schermi molto piccoli */
@media (max-width: 380px) {
  .bando-container {
    padding: 0.625rem;
  }

  .bando-content {
    padding: 0.75rem;
  }

  .sidebar-logo {
    flex: 1 1 100%;
    max-width: 180px;
  }
}
