/* ==========================================================================
   1. RESET & REGOLE GENERALI (da stile_v3.css)
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: Verdana, Arial, sans-serif;
  background-color: #f5f5f5;
}

/* ==========================================================================
   2. TOPBAR & STRUTTURA NUOVA (V4)
   ========================================================================== */
.topbar {
  background: #0f3557;
  color: white;
  font-size: .9rem;
}

.topbar .container {
  max-width: 1200px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  padding: 8px 20px;
}

/* Header stile V4 (Nuovo standard di layout) */
.header {
  background: white;
  border-bottom: 1px solid #ddd;
}

.header-content {
  max-width: 1200px;
  margin: auto;
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 20px;
}

.logo {
  width: 95px;
}

.titoli h1 {
  margin: 0;
  color: #1f4e79;
  font-size: 2rem;
}

.sottotitolo {
  margin-top: 8px;
  color: #555;
  line-height: 1.6;
}

/* Vecchio header (V3) mantenuto per retrocompatibilità se usato in alcune pagine */
header {
  background-color: #f2f2f2;
  padding: 20px;
  display: flex;
  align-items: center;
}

header img {
  height: 100px;
  margin-right: 20px;
}

header h1 {
  margin: 0;
  font-size: 22px;
  color: #0056b3;
}

header p {
  margin: 3px 0;
  font-size: 13px;
}

/* Quick Links (V4) */
.quick-links {
  display: flex;
  gap: 10px;
}

/* ==========================================================================
   3. NAVIGAZIONE (da stile_v3.css)
   ========================================================================== */
nav {
  background-color: #0080c0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
}

nav ul li {
  padding: 15px 20px;
}

nav ul li a {
  color: white;
  text-decoration: none;
  font-weight: bold;
}

nav ul li:hover {
  background-color: #6495ed;
}

/* ==========================================================================
   4. LAYOUT MAIN CORPO PAGINA (da stile_v3.css)
   ========================================================================== */
main {
  display: flex;
  max-width: 1200px;
  margin: auto;
  padding: 20px;
}

aside {
  width: 25%;
  padding: 15px;
  background-color: #ffffff;
}

aside h2 {
  color: #5e86c1;
  border-bottom: 2px solid #5e86c1;
  padding-bottom: 5px;
}

aside ul {
  list-style: none;
  padding: 0;
}

aside ul li {
  margin: 8px 0;
}

aside ul li a {
  text-decoration: none;
  color: #0080c0;
  font-weight: bold;
}

aside ul li a:hover {
  text-decoration: underline;
}

section {
  width: 75%;
  padding: 20px;
  background-color: #ffffff;
  margin-left: 20px;
}

section h2 {
  color: #5e86c1;
}

video {
  max-width: 100%;
  margin: 15px 0;
}

/* Componenti e utility minori */
.immagine-pagina {
  display: block;
  margin: auto;
  max-width: 300px;
}

.durata {
  background: #ccccff;
  padding: 6px;
  width: 150px;
  font-weight: bold;
}

.note {
  font-size: 0.9em;
  margin-top: 10px;
}

#topBtn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #004080;
  color: white;
  border: none;
  padding: 10px 15px;
  font-size: 20px;
  cursor: pointer;
  border-radius: 5px;
  display: none;
}

/* ==========================================================================
   5. COMPONENTI HOME E SEZIONI (Unione V3 + V4)
   ========================================================================== */

/* Avvisi Generici */
.avviso {
  font-size: 15px;
  line-height: 1.4;
  background-color: #ffebcc;
  padding: 15px;
  border: 1px solid #ffa500;
  border-left: 6px solid #ff8c00;
  border-radius: 6px;
  margin-bottom: 15px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: transform 0.2s;
}

.avviso:hover {
  transform: translateX(5px);
}

.avviso h3 {
  margin-bottom: 8px;
  margin-top: 0;
  font-size: 18px;
  color: #cc6600;
}

.avviso-warning {
  background-color: #fff4f4;
  padding: 10px;
  border-left: 4px solid #c0392b;
  margin-top: 10px;
}

.download-link,
.avviso a {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 15px;
  background-color: #007bff;
  color: white;
  text-decoration: none;
  border-radius: 5px;
}

.download-link:hover,
.avviso a:hover {
  background-color: #0056b3;
}

/* Sezioni griglia Home (V4) */
.servizi,
.offerta,
.avvisi-home {
  max-width: 1200px;
  margin: 50px auto;
}

.servizi h2,
.offerta h2,
.avvisi-home h2 {
  text-align: center;
  color: #1f4e79;
  font-size: 2rem;
  margin-bottom: 30px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 25px;
}

.card-servizio,
.card-corso {
  background: #ffffff;
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  text-decoration: none;
  color: #333;
  box-shadow: 0 5px 18px rgba(0,0,0,.08);
  transition: .25s;
}

.card-servizio:hover,
.card-corso:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 30px rgba(0,0,0,.15);
}

.icona {
  font-size: 3rem;
  margin-bottom: 15px;
}

.card-servizio h3,
.card-corso h3 {
  color: #0056b3;
  margin-bottom: 15px;
}

.card-servizio p,
.card-corso p {
  line-height: 1.6;
  font-size: 15px;
}

/* Missione e Identità (V4) */
.missione {
  background: linear-gradient(90deg, #eef5ff, #ffffff);
  padding: 60px 20px;
  text-align: center;
}

.missione h2 {
  color: #1f4e79;
  font-size: 2.2rem;
}

.missione p {
  max-width: 900px;
  margin: auto;
  font-size: 1.15rem;
  line-height: 1.8;
  color: #555;
}

.identita {
  background: white;
  padding: 60px 30px;
  text-align: center;
}

.identita p {
  max-width: 900px;
  margin: auto;
  line-height: 1.9;
  font-size: 18px;
}

/* I Numeri della Scuola (V4) */
.numeri {
  background: #1f4e79;
  color: white;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 50px 20px;
}

.numero {
  text-align: center;
}

.numero span {
  font-size: 3rem;
  font-weight: bold;
  display: block;
}

.numero p {
  margin-top: 10px;
}

/* TABELLE (V3) */
table {
  width: 100%;
  border-collapse: collapse;
}

td, th {
  border: 1px solid #ccc;
  padding: 6px;
  text-align: center;
}

tr:nth-child(even) {
  background-color: #eee;
}

/* ==========================================================================
   6. SLIDER IMMAGINI (Risolto conflitto V3 - unificate transizioni fluide)
   ========================================================================== */
.slider {
  width: 100%;
  position: relative;
  overflow: hidden;
  height: 500px; /* Uniformato sulla versione più recente */
}

.slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1s ease-in-out;
  z-index: 1;
}

.slide.active {
  opacity: 1;
  position: relative;
  z-index: 2;
}

.slide img {
  width: 100%;
  height: 500px;
  object-fit: cover;
  display: block;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.1); 
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.caption {
  position: absolute;
  bottom: 40px;
  left: 40px;
  color: #fff;
  background: rgba(0,0,0,0.5);
  padding: 15px 20px;
  border-radius: 5px;
  z-index: 4;
}

.caption h2 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  color: white;
}

.caption p {
  font-size: 1.2rem;
}

.prev, .next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 2rem;
  padding: 10px;
  cursor: pointer;
  user-select: none;
  background: rgba(0,0,0,0.4);
  z-index: 5;
}

.prev { left: 20px; }
.next { right: 20px; }

.dots {
  position: absolute;
  bottom: 15px;
  width: 100%;
  text-align: center;
  z-index: 5;
}

.dot {
  height: 12px;
  width: 12px;
  margin: 0 5px;
  display: inline-block;
  background-color: rgba(255,255,255,0.5);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.3s;
}

.dot.active, .dot:hover {
  background-color: #fff;
}

/* ==========================================================================
   7. GALLERIA FOTOGRAFICA & LIGHTBOX (da stile_v3.css)
   ========================================================================== */
.galleria {
  max-width: 1200px;
  margin: auto;
}

.galleria h2 {
  text-align: center;
  margin-bottom: 30px;
}

.griglia-galleria {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
}

.griglia-galleria img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
}

.griglia-galleria img:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 18px rgba(0,0,0,0.3);
}

#lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#lightbox img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
}

/* ==========================================================================
   8. FOOTER (Risolto conflitto: Scelta la variante V4 più moderna)
   ========================================================================== */
footer {
  background: #12395b;
  color: white;
  padding: 40px;
  text-align: center;
  margin-top: 70px;
  font-size: 13px;
}

footer p {
  margin: 6px;
}

/* ==========================================================================
   9. RESPONSIVE DESIGN & MEDIA QUERIES (Ordinate decrescenti per breakpoint)
   ========================================================================== */

/* --- TABLET / DISPOSITIVI MEDI (sotto i 1024px) --- */
@media (max-width: 1024px) {
  .slide img {
    height: 350px;
  }

  .caption h2 {
    font-size: 2rem;
  }

  .griglia-galleria {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- DISPOSITIVI SOTTO I 900px --- */
@media (max-width: 900px) {
  main {
    flex-direction: column;
  }

  aside, section {
    width: 100%;
    margin: 0;
  }

  nav ul {
    flex-direction: column;
  }

  nav ul li {
    text-align: center;
  }

  .galleria {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- SMARTPHONE (sotto i 768px) --- */
@media (max-width: 768px) {
  .slide img {
    height: 250px;
  }

  .caption h2 {
    font-size: 1.5rem;
  }

  .griglia-galleria {
    grid-template-columns: 1fr;
  }
}

/* --- SMARTPHONE PICCOLI (sotto i 600px) --- */
@media (max-width: 600px) {
  .griglia-galleria {
    grid-template-columns: 1fr;
  }

  .griglia-galleria img {
    height: 250px;
  }

  .galleria {
    grid-template-columns: 1fr;
  }

  .galleria img {
    height: 250px;
  }
}