/* --- VARIABILI --- */
:root {
    --primary-color: #0056b3;
    --secondary-color: #28a745;
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-color: #333;
    --border-radius: 12px;
}

/* --- BASE --- */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.main-test-wrapper {
    background-color: var(--card-bg);
    max-width: 1000px;
    width: 100%;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    box-sizing: border-box;
}

/* --- HEADER --- */
.header-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #eee;
    padding: 10px 0;
    margin-bottom: 10px;
    background-color: white;
}

.header-box img {
    max-height: 40px;
    width: auto;
}

h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 10px;
}

.instruction-text {
    background: #e7f3ff;
    padding: 15px;
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
    font-size: 0.95rem;
    margin-bottom: 25px;
}

/* --- DOMANDE --- */
.question {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.question:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 86, 179, 0.2);
}

label {
    display: block;
    background: #f8f9fa;
    padding: 12px;
    margin: 8px 0;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.2s;
    word-wrap: break-word; 
    overflow-wrap: break-word;
}

label:hover {
    background: #e9ecef;
}

input[type="radio"] {
    margin-right: 10px;
    transform: scale(1.2);
}

/* --- SOLUZIONI --- */
.solution {
    display: none; /* Parte sempre chiusa per permettere il reset */
    margin-top: 15px;
    padding: 15px;
    background: #fff9db;
    border-left: 4px solid #fcc419;
    border-radius: 4px;
    font-size: 0.9rem;
}

.solution ol {
    line-height: 1.6;
}

/* --- BOTTONI GENERALI --- */
button {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* --- BOTTONE SPIEGAZIONE (Grigio di base) --- */
.btn-secondary, .solution-btn, .solution-toggle-btn {
    background-color: #6c757d;
    color: white !important;
    transition: all 0.3s ease;
    display: inline-block;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
}

.btn-secondary:hover, .solution-btn:hover, .solution-toggle-btn:hover {
    background-color: #495057;
}

/* Stato quando la soluzione è aperta (Rosso) */
.btn-active {
    background-color: #d9534f !important; 
    border-color: #d43f3a !important;
    color: white !important;
}

.btn-active:hover {
    background-color: #c9302c !important;
}

/* --- FOOTER E NAVIGAZIONE --- */
.footer-container {
    margin-top: 20px;
    width: 100%;
    text-align: center;
}

.footer-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.btn-verify { background-color: #28a745; color: white; }
.btn-verify:hover { background-color: #218838; }

.btn-reset { background-color: #333333; color: white; }
.btn-reset:hover { background-color: #1a1a1a; box-shadow: 0 4px 8px rgba(0,0,0,0.2); }

.btn-print { background-color: #6f42c1; color: white; }
.btn-print:hover { background-color: #5a32a3; }

.btn-theory { background-color: #007bff; color: white; }
.btn-theory:hover { background-color: #0056b3; }

.btn-dsa-version { background-color: #fd7e14; color: white; }
.btn-dsa-version:hover { background-color: #e67e00; transform: translateY(-2px); }

.btn-index { background-color: #800020; color: white; }
.btn-index:hover { background-color: #600018; transform: translateY(-2px); }

.results {
    background-color: #e9ecef;
    padding: 15px;
    border-radius: 5px;
    margin-top: 20px;
}

.correct { color: green; }
.incorrect { color: red; }

/* --- RESPONSIVE --- */
@media (min-width: 600px) {
    button { width: auto; padding: 10px 20px; }
}

@media (max-width: 768px) {
    .main-test-wrapper { max-width: 100%; padding: 15px; margin: 0; border-radius: 8px; }
    body { padding: 5px; }
    h1 { font-size: 1.5rem; }
    .instruction-text { padding: 12px; font-size: 0.9rem; }
    .question { padding: 15px; }
    label { padding: 10px; font-size: 0.95rem; }
    .header-box img { max-height: 30px; }
    .solution { padding: 12px; font-size: 0.85rem; }
}

/* --- STAMPA --- */
@media print {
    .solution { display: block !important; visibility: visible !important; opacity: 1 !important; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    button, .footer-buttons, .header-box, input[type="radio"], hr { display: none !important; }
    .question { page-break-inside: avoid; border: none !important; border-bottom: 1px solid #ddd !important; margin-bottom: 30px !important; padding-bottom: 20px !important; }
    img { max-width: 100% !important; height: auto !important; page-break-inside: avoid; }
    body { background: white !important; }
    .main-test-wrapper { box-shadow: none !important; padding: 0 !important; width: 100% !important; }
    .solution { background: #fffef5 !important; border-left: 3px solid #999 !important; }
    .footer-container { display: none !important; }
}
/* STATO NORMALE: Arancione coerente con il tuo stile */
.btn-dsa {
    background-color: #ff9800 !important;
    color: white !important;
    border: 2px solid #ff9800 !important; /* Bordo presente per evitare scatti in hover */
    border-radius: 8px !important;        /* Identico a tutti gli altri bottoni del tuo CSS */
    padding: 10px 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

/* STATO HOVER: Inversione (Bianco con bordo e testo arancione) */
.btn-dsa:hover {
    background-color: #ffffff !important;
    color: #ff9800 !important;
    border-color: #ff9800 !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15) !important;
    transform: translateY(-2px); /* Coerente con l'effetto degli altri tuoi bottoni */
}
/* --- STILE TIMER --- */
#timer-container {
    position: fixed;
    top: 15px;
    right: 15px;
    background-color: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 50px; /* Forma a pillola molto moderna */
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.1rem;
    font-weight: bold;
    z-index: 9999;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border: 2px solid #555;
    transition: all 0.3s ease;
}

/* Stato di allerta (ultimi 5 minuti) */
.timer-warning {
    background-color: #d9534f !important;
    border-color: #c9302c !important;
    animation: pulse-timer 1s infinite;
}

@keyframes pulse-timer {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Nascondi il timer durante la stampa */
@media print {
    #timer-container { display: none !important; }
}

/* Adattamento per mobile */
@media (max-width: 768px) {
    #timer-container {
        position: static; /* Torna nel flusso normale per non coprire il testo */
        margin: 10px auto;
        display: table;
        font-size: 0.9rem;
    }
}