* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  transition: background 0.5s ease;
}

body.dark-mode {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #f0f0f0;
}

.header {
  text-align: center;
  padding: 60px 20px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: background 0.5s ease;
  position: relative;
}

body.dark-mode .header {
  background: rgba(26, 26, 46, 0.95);
  color: #f0f0f0;
}

.slideshow-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
}

.slideshow-background img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.5s ease-in-out;
}

.slideshow-background img.active {
  opacity: 0.3;
}

body.dark-mode .slideshow-background img.active {
  opacity: 0.2;
}

.header-content {
  position: relative;
  z-index: 1;
}

.profile-img {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
  border: 5px solid #9666ea;
  margin-bottom: 20px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.3);
  transition: border 0.5s ease;
  margin-left: auto;
  margin-right: auto;
}

body.dark-mode .profile-img {
  border: 5px solid #667eea;
}

.header h1 {
  font-size: 2.5em;
  color: #9666ea;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

body.dark-mode .header h1 {
  color: #667eea;
}

.header p {
  font-size: 1.2em;
  color: #666;
  text-shadow: 1px 1px 2px rgba(255,255,255,0.5);
}

body.dark-mode .header p {
  color: #f0f0f0;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
}

.section {
  background: white;
  padding: 40px;
  margin-bottom: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  opacity: 0;
  transform: translateY(50px);
  transition: all 0.8s ease;
}

body.dark-mode .section {
  background: #1a1a2e;
  color: #f0f0f0;
  box-shadow: 0 4px 6px rgba(0,0,0,0.5);
}

.section.visible {
  opacity: 1;
  transform: translateY(0);
}

.section h2 {
  color: #9666ea;
  font-size: 2em;
  margin-bottom: 20px;
  border-bottom: 3px solid #9666ea;
  padding-bottom: 10px;
}

body.dark-mode .section h2 {
  color: #9666ea;
}

.section p {
  font-size: 1.1em;
  color: #555;
  margin-bottom: 15px;
  text-align: justify;
}

body.dark-mode .section p {
  color: #f0f0f0;
}

.github-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin: 20px 0;
}

.github-stats img {
  max-width: 45%;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  transition: transform 0.3s ease;
}

.github-stats img:hover {
  transform: scale(1.02);
}

.footer {
  background: rgba(255, 255, 255, 0.95);
  padding: 40px 20px;
  text-align: center;
  margin-top: 40px;
  transition: background 0.5s ease;
}

body.dark-mode .footer {
  background: #1a1a2e;
  color: #f0f0f0;
}

.footer h3 {
  color: #667eea;
  margin-bottom: 20px;
  font-size: 1.5em;
}

body.dark-mode .footer h3 {
  color: #667eea;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 30px;
  flex-wrap: wrap;
}

.social-links a {
  color: #667eea;
  text-decoration: none;
  font-size: 1.1em;
  padding: 10px 20px;
  border: 2px solid #667eea;
  border-radius: 5px;
  transition: all 0.3s ease;
}

body.dark-mode .social-links a {
  color: #667eea;
  border-color: #667eea;
}

.social-links a:hover {
  background: #667eea;
  color: white;
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

body.dark-mode .social-links a:hover {
  background: #667eea;
  color: #1a1a2e;
}

.dark-mode-btn {
  padding: 10px 20px;
  font-size: 1em;
  border: 2px solid #667eea;
  border-radius: 5px;
  background: #667eea;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.dark-mode-btn:hover {
  background: #764ba2;
  border-color: #764ba2;
  transform: translateY(-2px);
}

/* --- Nuovi Stili per lo Switch Lingua e Action Bar (MODIFICATI) --- */
.action-bar { /* Nuovo wrapper per i bottoni, ora gestisce il layout verticale per tutti gli schermi */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px; /* Spazio verticale tra i due elementi */
}

.language-switch {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  padding: 5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  /* margin-left: 15px; Rimosso per allineamento centrale verticale */
  align-items: center;
  transition: background 0.5s ease;
}

body.dark-mode .language-switch {
  background: rgba(26, 26, 46, 0.8);
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.language-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 5px;
  transition: background 0.3s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 2px;
}

.language-btn:hover {
  background: rgba(102, 126, 234, 0.1); /* Leggero hover per entrambi i temi */
}

.language-btn.active {
  background: #667eea;
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.4);
  transform: translateY(-1px);
}

.language-btn.active img {
  filter: drop-shadow(0 0 1px #fff); /* Effetto bandiera selezionata */
}

.language-btn img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

body.dark-mode .language-btn.active {
  background: #667eea;
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.6);
}
/* --- Fine Nuovi Stili per lo Switch Lingua --- */

/* --- Stili per il Carosello Certificati --- */

.certificate-carousel-container {
    position: relative;
    max-width: 800px; /* Larghezza massima in base alle immagini 800x566 */
    margin: 30px auto 10px auto;
    overflow: hidden; /* Nasconde le slide non attive */
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    /* Assicura che la box shadow funzioni bene anche in dark mode */
    background: #000; 
}

body.dark-mode .certificate-carousel-container {
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
}

.certificate-carousel {
    position: relative;
    min-height: 300px; /* ← NUOVO: evita che il contenitore diventi alto 0px */
}

.carousel-slide {
    display: none;
    position: absolute; /* ← NUOVO: le slide si sovrappongono */
    top: 0;
    left: 0;
    opacity: 0; /* ← NUOVO: per l'effetto fade */
}

.carousel-slide.active {
    display: block;
    position: relative; /* ← NUOVO: quella attiva occupa spazio normale */
    opacity: 1; /* ← NUOVO: completamente visibile */
}

.carousel-slide img {
    width: 100%;
    height: auto; /* Mantiene l'aspetto ratio 800x566 */
    display: block;
    max-height: 566px; /* Limite massimo per l'altezza originale dell'immagine */
}

/* Stili per le frecce di navigazione (prev/next) */
.prev, .next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px 12px;
    margin-top: -28px; /* Centra verticalmente */
    color: white;
    font-weight: bold;
    font-size: 30px;
    transition: 0.6s ease;
    border-radius: 3px;
    user-select: none;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.next {
    right: 0;
    border-radius: 3px 0 0 3px;
}

.prev {
    left: 0;
    border-radius: 0 3px 3px 0;
}

.prev:hover, .next:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

/* --- Media Queries --- */

@media (max-width: 768px) {
  .header h1 {
    font-size: 2em;
  }
  
  .section {
    padding: 25px;
  }

  .section h2 {
    font-size: 1.5em;
  }

  .github-stats img {
    max-width: 100%;
  }
}

/* Responsive design per le frecce su schermi piccoli */
@media only screen and (max-width: 600px) {
  .prev, .next {
    font-size: 20px;
    padding: 10px 8px;
    margin-top: -15px;
  }
}