/* =====================================================
   Stile per Compiti - Versione DSA
   Aggiornato: aggiunto supporto hint, feedback, contatore aiuti
   ===================================================== */

body {
  font-family: Arial, Verdana, sans-serif;
  background: #f5f7fa;
  margin: 0;
  padding: 20px;
  letter-spacing: 0.04em;
  line-height: 1.9;
}

.container {
  width: 95%;
  max-width: 1100px;
  margin: auto;
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* ===== HEADER ===== */
.header {
  text-align: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e8f5e9;
}

.header h1 {
  color: #2e7d32;
  margin-bottom: 10px;
  font-size: 2em;
}

.subtitle {
  font-size: 1.1em;
  color: #666;
  margin-top: 10px;
}

/* ===== HEADER BOX CON LOGHI ===== */
.header-box {
  display: flex !important;
  flex-direction: row !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 15px !important;
  border: 2px dashed #28a745 !important;
  border-radius: 8px !important;
  background-color: white !important;
  margin-bottom: 25px !important;
}

.header-box:hover {
  background-color: #f0fdf4 !important;
  cursor: pointer;
}

.header-box a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-decoration: none;
}

.header-box img {
  max-height: 50px;
}

.header-box img:first-child {
  max-height: 40px;
}

/* ===== TITOLO PAGINA ===== */
.header-title {
  text-align: center;
}

.header-title h1 {
  color: #2e7d32;
  text-transform: uppercase;
}

/* ===== BOX ISTRUZIONI ===== */
.instruction-box {
  background-color: #e8f5e9;
  border-left: 5px solid #2e7d32;
  padding: 15px;
  margin: 20px auto;
  border-radius: 8px;
  font-size: 0.95em;
  color: #1b5e20;
  display: block;
  text-align: left;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  max-width: 90%;
}

/* ===== TESTO ARGOMENTI (corsivo) ===== */
#testo-da-leggere {
  font-style: italic;
}

/* ===== LINK VERSIONE STANDARD ===== */
.link-versione-standard {
  margin-top: 20px;
  text-align: center;
}

.link-versione-standard a {
  color: #2e7d32;
  font-weight: bold;
  text-decoration: none;
  border-bottom: 2px solid #2e7d32;
}

/* ===== SEPARATORE ===== */
.separator {
  border: 0;
  height: 2px;
  background: linear-gradient(to right, transparent, #28a745, transparent);
  margin: 15px 0 25px 0;
}

/* ===== TESTO DEL PROBLEMA ===== */
.problem-text {
  background: #f0f4f8;
  padding: 15px;
  margin: 15px 0;
  border-left: 5px solid #2196f3;
  border-radius: 4px;
}

.problem-text-intro {
  font-size: 1.1em;
  margin-bottom: 20px;
}

/* ===== TITOLI DOMANDA ===== */
.question h2 {
  color: #6a1b9a;
  border-bottom: 2px dashed #ce93d8;
  padding-bottom: 5px;
}

/* ===== STEP E FORMULA BOX ===== */
.step {
  background: #f1f8e9;
  padding: 15px;
  margin: 15px 0;
  border-radius: 8px;
}

.formula-box {
  background: white;
  padding: 15px;
  margin: 15px 0;
  border-left: 4px solid #4caf50;
  border-radius: 4px;
  overflow-x: visible;
}

.result-box {
  background: #e8f5e9;
  padding: 15px;
  border: 2px solid #2e7d32;
  border-radius: 8px;
}

.solution-box {
  background: white;
  padding: 20px;
  margin-top: 20px;
  border-radius: 8px;
  border: 2px solid #4caf50;
}

/* ===== SEZIONI ESPANDIBILI (soluzioni) ===== */
.section {
  margin-bottom: 20px;
}

.section h2 {
  margin: 0;
  padding: 0;
  font-size: 1em;
}

.section-button {
  width: 100%;
  padding: 15px;
  font-size: 1.2em;
  background: #e0f2f1;
  border: 2px solid #80cbc4;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-weight: bold;
  color: #004d40;
  transition: all 0.3s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 77, 64, 0.1);
  margin-top: 6px;
}

.section-button:hover {
  background: #b2dfdb;
  border-color: #4db6ac;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 77, 64, 0.2);
}

.section-button .arrow {
  color: #00796b;
  font-size: 1.2em;
}

.section-button.active {
  background-color: #1e88e5;
  border-color: #1565c0;
  color: white;
}

.section-button.active .arrow {
  color: white;
}

.section-content {
  display: none;
  padding: 20px;
  border: 2px solid #e8f5e9;
  border-top: none;
  border-radius: 0 0 8px 8px;
  background: #fafafa;
}

.section-content.active {
  display: block;
}

.arrow {
  transition: transform 0.3s ease;
  font-size: 0.8em;
}

.arrow.rotated {
  transform: rotate(180deg);
}

/* ===== BOTTONE NASCONDI SOLUZIONE ===== */
.btn-nascondi {
  display: block;
  margin: 20px auto 0;
  background-color: #666;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  font-size: 1em;
  transition: background 0.2s;
}

.btn-nascondi:hover {
  background-color: #444;
  color: white;
  border-color: transparent;
  transform: none;
  box-shadow: none;
}

.solution-hide-btn {
  text-align: center;
  margin-top: 20px;
}

/* ===== RIGA BOTTONI (aiuto + soluzione) ===== */
.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0;
}

/* ===== BOTTONE AIUTO (giallo/ambra, stile DSA) ===== */
button.btn-aiuto {
  display: inline-block !important;
  padding: 12px 22px !important;
  margin: 0 !important;
  border-radius: 8px !important;
  font-size: 1em !important;
  font-weight: bold !important;
  text-align: center !important;
  cursor: pointer !important;
  box-sizing: border-box !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
  letter-spacing: 0.03em;
  background-color: #fff9db !important;
  color: #856404 !important;
  border: 2px solid #ffca28 !important;
}

button.btn-aiuto:hover {
  background-color: #ffca28 !important;
  border-color: #ffa000 !important;
  color: #4e342e !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15) !important;
}

/* Bottone aiuto attivo (almeno un hint aperto) */
button.btn-aiuto.is-active {
  background-color: #e3f2fd !important;
  color: #0d47a1 !important;
  border-color: #2196f3 !important;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1) !important;
}

button.btn-aiuto.is-active:hover {
  background-color: #bbdefb !important;
}

/* ===== BOX SUGGERIMENTO (hint) ===== */
.hint {
  background-color: #e3f2fd !important;
  border-left: 5px solid #2196f3 !important;
  margin: 8px 0 !important;
  padding: 15px 18px !important;
  border-radius: 8px !important;
  color: #0d47a1 !important;
  font-size: 1em !important;
  line-height: 1.7 !important;
  display: none;
  overflow-x: auto;
}

.hint strong {
  color: #1565c0 !important;
  display: block;
  margin-bottom: 5px;
}

/* ===== AUDIO BOTTONI ===== */
#btn-audio {
  background-color: #ff9800;
  color: #ffffff;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  font-size: 1em;
}

#btn-audio:hover {
  background-color: #f57c00;
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

#btn-audio:active {
  transform: scale(0.98);
}

.btn-ascolta-domanda {
  background-color: #ff9800;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.6em;
  vertical-align: middle;
  margin-left: 15px;
  cursor: pointer;
  font-weight: normal;
  transition: transform 0.2s;
}

.btn-ascolta-domanda:hover {
  transform: scale(1.1);
  background-color: #f57c00;
}

.btn-ascolta-intro {
  font-size: 0.9em !important;
}

/* ===== TESTO AUDIO NASCOSTO ===== */
.audio-testo {
  display: none;
}

/* ===== BARRA DI AVANZAMENTO FISSA ===== */
#progress-box {
  position: fixed;
  top: 15px;
  right: 15px;
  background: #e8f5e9;
  border-left: 6px solid #2e7d32;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 1.05em;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  white-space: nowrap;
  font-family: Arial, Verdana, sans-serif;
  min-width: 170px;
}

#progress-count {
  font-size: 1.25em;
  font-weight: 700;
  color: #2e7d32;
}

#hint-count {
  font-size: 1.1em;
  font-weight: 700;
  color: #856404;
}

.progress-container {
  width: 100%;
  height: 14px;
  background: #e0e0e0;
  border-radius: 8px;
  margin: 8px 0 0 0;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: #2e7d32;
  transition: width 0.4s ease, background 0.6s ease;
}

.gold-complete {
  background: linear-gradient(270deg, #ffd700, #ffec8b, #ffd700, #ffec8b) !important;
  background-size: 400% 400%;
  animation: goldShine 2s ease infinite;
}

@keyframes goldShine {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ===== BOX FEEDBACK FINALE ===== */
#feedback-box {
  margin: 30px 10px 10px;
  padding: 20px 25px;
  background: #f5f5f5;
  border-radius: 10px;
  border-left: 5px solid #2e7d32;
  text-align: center;
  font-size: 1.05em;
  line-height: 1.8;
}

#feedback-box strong {
  color: #2e7d32;
}

#feedback-message {
  margin-top: 8px;
  font-weight: bold;
  color: #444;
}

/* ===== GRAFICI ===== */
.graph img {
  display: block;
  margin: 0 auto 10px auto;
  max-width: 95%;
  height: auto;
}

.graph-container {
  background-color: white;
  border: 1px solid #c8e6c9;
  border-radius: 12px;
  padding: 20px;
  margin: 20px auto;
  max-width: 600px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.graph-container img {
  max-width: 70%;
  height: auto;
  border-radius: 8px;
}

.graph-caption {
  font-size: 0.95em;
  font-style: italic;
  color: #555;
  margin-top: 15px;
  border-top: 1px solid #eee;
  padding-top: 10px;
  display: block;
}

/* ===== TABELLE ===== */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 20px 0;
  background-color: #ffffff;
}

table th {
  background-color: #e8f5e9;
  color: #2e7d32;
  font-weight: bold;
}

table td, table th {
  padding: 12px;
  border: 2px solid #ccd1d9 !important;
  text-align: center;
}

table tr:nth-child(even) {
  background-color: #fcfdfc;
}

.table-scroll {
  overflow-x: auto;
}

.table-small {
  font-size: 0.85em;
}

/* ===== NAVIGAZIONE FOOTER ===== */
.nav-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.nav-buttons-secondary {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.btn-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 260px;
  height: 45px;
  padding: 12px 24px;
  background: white;
  color: #2e7d32;
  border: 2px solid #2e7d32;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.95em;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  box-sizing: border-box;
}

.btn-nav:hover {
  background: #2e7d32;
  color: white;
  transform: translateY(-2px);
}

.btn-nav-bordeaux {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 260px;
  height: 45px;
  padding: 12px 24px;
  background: white;
  color: #7b1f2e;
  border: 2px solid #7b1f2e;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.95em;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  box-sizing: border-box;
}

.btn-nav-bordeaux:hover {
  background: #7b1f2e;
  color: white;
  transform: translateY(-2px);
}

.btn-stampa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 260px;
  height: 45px;
  background-color: white;
  color: #9c27b0;
  text-decoration: none;
  border: 2px solid #9c27b0;
  border-radius: 8px;
  font-size: 0.95em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  box-sizing: border-box;
}

.btn-stampa:hover {
  background-color: #9c27b0;
  color: white;
  transform: translateY(-2px);
}

.btn-valida {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 260px;
  height: 45px;
  background-color: white;
  color: #0277bd;
  text-decoration: none;
  border: 2px solid #0277bd;
  border-radius: 8px;
  font-size: 0.85em;
  font-weight: bold;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.btn-valida:hover {
  background-color: #0277bd;
  color: white;
  transform: translateY(-2px);
}

/* ===== FOCUS ACCESSIBILITÀ ===== */
button:focus, a:focus {
  outline: 3px solid #ff9800;
  outline-offset: 2px;
}

/* ===== FOOTER HR ===== */
footer hr {
  opacity: 0.3;
  margin-top: 30px;
}

/* ===== STAMPA ===== */
@media print {
  body { background: white; padding: 0; }
  .container { max-width: 100%; box-shadow: none; border: none; }
  .section-button { background: white !important; border: 1px solid #ccc !important; }
  .arrow, .nav-buttons, .nav-buttons-secondary { display: none !important; }
  .section-content { display: block !important; border: none !important; }
  .section { page-break-inside: avoid; margin-bottom: 30px; }
  .step, .formula-box, .solution-box { page-break-inside: avoid; border: 1px solid #eee !important; }
  #progress-box { display: none !important; }
  .btn-nascondi, .btn-aiuto, .controls { display: none !important; }
  .hint { display: none !important; }
  #feedback-box { display: block !important; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #progress-box {
    font-size: 11px;
    padding: 4px 8px;
    top: 4px;
    right: 4px;
    max-width: 155px;
    min-width: unset;
  }
  #progress-count { font-size: 13px; }
  #hint-count { font-size: 12px; }
  .progress-container {
    height: 8px;
    margin: 4px 0 0 0;
  }
  .header-box {
    flex-direction: column !important;
    gap: 15px !important;
  }
  .btn-nav, .btn-stampa, .btn-valida, .btn-nav-bordeaux {
    width: 100%;
  }
  .controls {
    flex-direction: column;
  }
  .controls button {
    width: 100%;
  }
}
