/* Stili base per l'intera applicazione */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #f7f7fb 0%, #ffffff 40%);
    color: #333;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.page {
    max-width: 900px;
    width: 100%;
    margin: 20px auto;
}

/* Stile Card */
.card {
    background: #ffffff;
    border: 1px solid #e6e6e6;
    border-radius: 16px;
    padding: 22px 28px 28px;
    margin-bottom: 24px;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .08);
    position: relative;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 8px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    background: linear-gradient(90deg, #e91e63, #40aefd);
}

.card-title-header {
    text-align: center;
    margin-bottom: 24px;
}

.card-title-header h1 {
    font-size: 2.2rem;
    color: #990000;
    margin: 0;
}

.card-title-header h2 {
    font-size: 1.5rem;
    color: #000;
    margin: 4px 0 0 0;
    font-weight: 600;
}

.card h2 {
    font-size: 1.4rem;
    color: #990000;
    margin: 0 0 18px 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 12px;
}

/* Stile per le righe di informazioni e azioni (menu/lettura) */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    font-size: 1.1rem;
}

.info-item {
    display: flex;
    gap: 8px;
}

.info-item .label {
    font-weight: 700;
    color: #555;
}

.info-item .value {
    font-weight: 600;
    color: #000;
}

.action-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.action-row:last-child {
    border-bottom: none;
}

.action-row .description {
    flex: 1;
    padding-right: 16px;
}

.action-row .description .title {
    font-weight: 700;
    font-size: 1rem;
    color: #111;
}

.action-row .description .subtitle {
    font-style: italic;
    font-size: 0.9rem;
    color: #666;
}

/* Stile Pulsanti */
button, input[type="submit"] {
    border: 0;
    border-radius: 12px;
    padding: 11px 22px;
    cursor: pointer;
    background: #40aefd;
    color: #fff;
    font-weight: 700;
    letter-spacing: .2px;
    font-size: 1rem;
    box-shadow: 0 6px 14px rgba(31, 111, 235, .48);
    transition: transform .05s ease, box-shadow .2s ease, filter .12s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

button:hover, input[type="submit"]:hover {
    filter: brightness(1.05);
    background: #5db9ff;
    box-shadow: 0 8px 18px rgba(31, 111, 235, 0.55), inset 0 1px 0 rgba(255, 255, 255, .65);
    transform: translateY(-1px);
}

button:active, input[type="submit"]:active {
    transform: translateY(1px);
    box-shadow: 0 3px 8px rgba(31, 111, 235, 0.25) inset;
}

button.exit-btn, input.exit-btn {
    background: #6c757d;
    box-shadow: 0 6px 14px rgba(108, 117, 125, .48);
}

button.exit-btn:hover, input.exit-btn:hover {
    background: #868e96;
    box-shadow: 0 8px 18px rgba(108, 117, 125, 0.55), inset 0 1px 0 rgba(255, 255, 255, .65);
}

.home-btn {
    background: #40aefd;
    box-shadow: 0 6px 14px rgba(31, 111, 235, .48);
}
.home-btn:hover {
    background: #5db9ff;
    box-shadow: 0 8px 18px rgba(31, 111, 235, 0.55), inset 0 1px 0 rgba(255, 255, 255, .65);
}

.exit-container {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

/* ============================================= */
/* STILI PER LA PAGINA DI LOGIN (user.php) */
/* ============================================= */
.login-card {
    max-width: 450px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus {
    outline: none;
    border-color: #40aefd;
    box-shadow: 0 0 0 3px rgba(64, 174, 253, 0.3);
}

.form-actions {
    margin-top: 24px;
}

.form-actions button {
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
}

/* ============================================= */
/* STILI PER LA PAGINA DI QUESTIONARIO (questionario.php) */
/* ============================================= */
.questionario-header {
    text-align: center;
    margin-bottom: 20px;
}
.page.questionario-page {
    max-width: 1200px; 
}
.alunno-card {
    padding: 20px;
    margin-bottom: 30px;
    border: 1px solid #ddd;
    border-radius: 12px;
}
.alunno-header {
    font-size: 1.5rem;
    color: #990000;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    font-weight: 700;
}
.domande-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}
.domanda-colonna {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
}
.domanda-colonna h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #111;
    margin: 0 0 10px 0;
    line-height: 1.3;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}
.checkbox-list {
    padding-top: 5px;
}
.checkbox-label {
    display: block;
    margin: 4px 0;
    font-size: 0.9rem;
    font-weight: 400;
    color: #333;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    flex-shrink: 0;
}
.commento-sezione {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
}
.commento-sezione label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
}
.commento-sezione input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
}
.submit-container {
    text-align: center;
    margin: 40px 0;
}
.submit-container button {
    padding: 14px 30px;
    font-size: 1.2rem;
    font-weight: 700;
}


/* ============================================= */
/* STILI PER LA PAGINA VISUALIZZATORE (visualizzatore.php) */
/* ============================================= */
.visualizer-layout {
    display: flex;
    gap: 10px; 
    padding: 10px; 
    max-width: 1700px; 
    margin: 0 auto;
}
.data-column {
    flex-shrink: 0;
    width: 650px; 
    display: flex;
    flex-direction: column;
    gap: 8px; 
}
.chart-column {
    flex-grow: 1;
    min-width: 700px;
}

/* Override padding per le card in questa colonna */
.data-column .card {
    padding: 15px 20px; 
    margin-bottom: 0; 
}
.chart-column .card {
    padding: 20px;
    display: block; 
    min-height: 700px;
}

/* Layout Dati Classe (finalissima) */
#data-classe-grid {
    font-size: 0.95rem;
    display: grid;
    grid-template-columns: auto 1fr auto auto; 
    gap: 5px 10px;
    padding-top: 0px; 
}
#data-classe-grid .label {
    grid-column: 1 / 2;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}
#data-classe-grid .value {
    grid-column: 2 / 5;
    font-weight: 700;
    color: #000;
    white-space: nowrap;
}
#data-classe-grid .row-class {
    grid-row: 2;
}
#data-classe-grid .col-as {
    grid-column: 3 / 4;
    font-weight: 600;
    color: #555;
}
#data-classe-grid .value-as {
    grid-column: 4 / 5;
    font-weight: 700;
    color: #000;
}
.dati-classe-header {
    font-weight: 700;
    color: #990000;
    font-size: 1.2rem;
    grid-column: 1 / 5;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: none;
}


/* Domanda e Periodo Card (ottimizzata e compattata) */
.question-controls {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    gap: 5px 10px; 
    align-items: center;
    font-size: 0.95rem;
    grid-template-areas: 
        "dom-label q-controls period-label period-btn"
        "domanda-text domanda-text domanda-text domanda-text";
}
.question-controls .domanda-control {
    grid-area: q-controls;
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: flex-start;
}
.question-controls .label-control {
    grid-area: dom-label;
    font-weight: 700;
    color: #990000;
    font-size: 1rem;
    align-self: center;
    white-space: nowrap;
}
.question-controls .periodo-label {
     grid-area: period-label;
     white-space: nowrap;
     font-weight: 600;
     color: #555;
}
.question-controls .periodo-btn {
    grid-area: period-btn;
    min-width: 120px;
}
.question-controls .domanda-text {
    grid-area: domanda-text;
    font-size: 1rem; 
    margin-bottom: 0;
    font-weight: 700;
    color: #000;
    line-height: 1.2;
}

/* CARD UNIFICATA 3 (Protagonista + Statistiche + Commenti) */
.alunno-header {
    font-size: 1.5rem;
    color: #990000;
    margin-bottom: 0;
    font-weight: 700;
    flex-grow: 1; 
    line-height: 1.2;
    margin-right: 15px;
}
/* Controlli Protagonista compattati con il nome */
#protagonista-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}
#protagonista-controls .title {
    display: none; 
}
#protagonista-controls .alunno-name {
    font-size: 1.5rem;
    color: #990000;
    font-weight: 700;
    line-height: 1.2;
    margin-right: 15px;
}
#protagonista-controls .alunno-title {
    /* Stile per la dicitura "PROTAGONISTA:" */
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    margin-right: 5px;
    white-space: nowrap;
}
#protagonista-controls .buttons {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}
#protagonista-controls .buttons button {
    width: 50px;
    padding: 8px 12px;
}


/* Statistiche Scelte (COMPATTAMENTO) */
.stats-table-compact {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem; 
    line-height: 1.4; 
    margin-top: 5px;
}
.stats-table-compact td {
    padding: 2px 4px;
    white-space: nowrap;
    text-align: left;
}
.stats-table-compact .stat-label {
    font-weight: 600;
    text-align: right;
    padding-right: 5px;
}
.stats-table-compact .period-label-col {
    font-weight: 700;
    color: #333;
    text-align: left;
    padding-right: 15px;
    padding-top: 5px;
    width: 120px;
}

/* Commenti (integrati sulla stessa riga) */
.comment-area {
    font-size: 0.85rem; 
    line-height: 1.3;
    margin-top: 5px;
    padding-top: 5px;
}
.comment-area .comment-row {
    display: flex;
    align-items: baseline;
    margin-top: 5px;
}
.comment-area .label {
    font-weight: 700;
    color: #333;
    white-space: nowrap;
    margin-right: 10px;
    flex-shrink: 0;
    font-style: italic; 
}
.comment-area .comment-box {
    background: #f7f7f7;
    padding: 5px 8px;
    border-radius: 4px;
    flex-grow: 1;
    width: 100%;
}


/* Controlli Diagramma (Pulsanti Centralità e Visualizza affiancati) */
.diagram-controls-card {
     display: flex;
     gap: 15px;
     align-items: center;
     padding: 15px 20px;
     margin-bottom: 0;
}
.diagram-controls-card button {
     flex-grow: 1;
     width: auto;
}

/* Legenda Alunni */
.alunni-list {
    font-size: 0.85rem; 
    line-height: 1.4;
    display: flex;
    gap: 20px;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid #ddd;
}
.alunni-list > div {
     flex: 1;
}

/* Canvas/Diagramma */
#myCanvas {
    display: block;
    border: none !important; 
    margin: 0 auto;
}