/* RESET E BASE */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f7fafc;
    color: #2d3748;
    line-height: 1.6;
}
a { text-decoration: none; }

/* LAYOUT CONTAINER */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 15px;
}
.intro-text { text-align: center; margin-bottom: 30px; }
.intro-text h1 { font-size: 2.5rem; color: #2b6cb0; margin-bottom: 10px; }

/* HEADER SCUOLA */
.school-header {
    background-color: #2d3748;
    color: white;
    padding: 15px 0;
}
.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    display: flex; justify-content: space-between; align-items: center;
}
.school-type { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; opacity: 0.8; }
.school-name { font-size: 1.5rem; font-weight: bold; }

/* AREA STUDENTE */
.student-area input {
    padding: 8px 12px; border-radius: 6px; border: none; outline: none; font-size: 0.9rem;
}
.btn-login {
    background-color: #48bb78; color: white; border: none; padding: 8px 15px;
    border-radius: 6px; cursor: pointer; font-weight: bold; margin-left: 5px;
}
.greeting { font-size: 1.1rem; }
.highlight-name { font-weight: bold; color: #63b3ed; }
.btn-logout {
    background-color: transparent; border: 1px solid #718096; color: #cbd5e0;
    padding: 4px 8px; border-radius: 4px; font-size: 0.7rem; margin-left: 10px; cursor: pointer;
}
.btn-logout:hover { background-color: #e53e3e; border-color: #e53e3e; color: white; }

/* NAVIGAZIONE */
.main-navigation {
    background-color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: sticky; top: 0; z-index: 1000;
    padding: 10px 0; border-bottom: 1px solid #e2e8f0;
}
.nav-container {
    display: flex; justify-content: center; gap: 10px; padding: 0 15px;
    max-width: 1200px; margin: 0 auto; overflow-x: auto;
    scrollbar-width: none; /* Firefox */
}
.nav-container::-webkit-scrollbar { display: none; } /* Chrome */

.nav-btn {
    display: flex; flex-direction: column; align-items: center;
    color: #4a5568; padding: 8px 12px; border-radius: 12px;
    transition: all 0.2s ease; min-width: 70px; border: 2px solid transparent;
}
.nav-btn .icon { font-size: 1.5rem; margin-bottom: 4px; }
.nav-btn .label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.nav-btn:active { transform: scale(0.95); }

/* COLORI NAVIGAZIONE (Active & Hover) */
.btn-home:hover, .btn-home.active { background: #f7fafc; border-color: #cbd5e0; color: #2d3748; }
.btn-italiano:hover, .btn-italiano.active { background: #fff5f5; border-color: #fc8181; color: #c53030; }
.btn-storia:hover, .btn-storia.active { background: #fffff0; border-color: #f6e05e; color: #b7791f; }
.btn-geografia:hover, .btn-geografia.active { background: #ebf8ff; border-color: #63b3ed; color: #2b6cb0; }
.btn-scienze:hover, .btn-scienze.active { background: #f0fff4; border-color: #68d391; color: #2f855a; }
.btn-tecnologia:hover, .btn-tecnologia.active { background: #edf2f7; border-color: #a0aec0; color: #4a5568; }
.btn-arte:hover, .btn-arte.active { background: #faf5ff; border-color: #d6bcfa; color: #805ad5; }
.btn-musica:hover, .btn-musica.active { background: #ebf4ff; border-color: #7f9cf5; color: #4c51bf; }
.btn-edfisica:hover, .btn-edfisica.active { background: #e6fffa; border-color: #4fd1c5; color: #285e61; }

/* MAPPA INTERATTIVA */
.interactive-map-container {
    position: relative; width: 100%; max-width: 1200px; margin: 20px auto;
}
.main-map-image {
    width: 100%; height: auto; display: block; border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.hotspot { position: absolute; cursor: pointer; z-index: 10; }
/* Per debuggare le aree, togli il commento alla riga sotto: */
/* .hotspot { background-color: rgba(255, 0, 0, 0.3); border: 1px solid red; } */

.link-spot:hover { background-color: rgba(255, 255, 255, 0.3); border-top: 4px solid #fff; }

/* TOOLTIPS E FEEDBACK */
.info-spot .tooltip {
    visibility: hidden; width: 220px; background-color: #2d3748; color: #fff;
    text-align: center; border-radius: 6px; padding: 12px;
    position: absolute; z-index: 100; bottom: 100%; left: 50%;
    transform: translateX(-50%); opacity: 0; transition: opacity 0.3s;
    font-size: 0.9rem; pointer-events: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.info-spot .tooltip::after {
    content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px;
    border-width: 5px; border-style: solid; border-color: #2d3748 transparent transparent transparent;
}
.info-spot:hover .tooltip { visibility: visible; opacity: 1; }

.feedback-msg {
    position: absolute; top: 18%; left: 42%;
    background-color: #48bb78; color: white; padding: 5px 15px;
    border-radius: 20px; font-size: 0.9rem; font-weight: bold;
    opacity: 0; transition: opacity 0.5s; box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* MOBILE RESPONSIVE */
@media (max-width: 600px) {
    .header-content { flex-direction: column; gap: 10px; text-align: center; }
    .intro-text h1 { font-size: 1.8rem; }
    /* Nascondiamo i tooltip su mobile perché danno fastidio al touch */
    .info-spot .tooltip { display: none; }
}
/* --- LAYOUT WORKSPACE (Materie) --- */
.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 50% e 50% */
    gap: 30px;
    margin-top: 20px;
}

/* Colonna Sinistra (Input) */
.card-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    border-left: 5px solid #cbd5e0; /* Colore default */
}

/* Colori specifici per Italiano */
.btn-italiano.active, .nav-btn.btn-italiano:hover { border-color: #fc8181; }
/* Bordo colorato per le card di italiano */
body:has(.btn-italiano.active) .card-section { border-left-color: #fc8181; }

.card-section h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #2d3748;
}

.card-section label {
    display: block;
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: #4a5568;
}

.card-section input, .card-section textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-family: inherit;
    margin-bottom: 10px;
}

.card-section textarea { resize: vertical; }

.tip-box {
    font-size: 0.8rem;
    color: #718096;
    background-color: #edf2f7;
    padding: 8px;
    border-radius: 5px;
    margin-top: 5px;
}

/* Colonna Destra (Anteprima Sticky) */
.preview-column {
    position: relative;
}

.sticky-preview {
    position: sticky;
    top: 100px; /* Non copre il menu */
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 10px 15px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
}

.paper-sheet {
    background-color: #fffbf0; /* Colore carta */
    padding: 20px;
    min-height: 300px;
    border: 1px solid #dcdcdc;
    margin: 15px 0;
    font-family: 'Georgia', serif; /* Font più "letterario" per il discorso */
    line-height: 1.8;
}

.placeholder-text {
    color: #a0aec0;
    font-style: italic;
}

.btn-pdf {
    width: 100%;
    background-color: #e53e3e; /* Rosso PDF */
    color: white;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
}
.btn-pdf:hover { background-color: #c53030; }

/* Mobile: Colonna unica */
@media (max-width: 768px) {
    .workspace-grid { grid-template-columns: 1fr; }
    .sticky-preview { position: static; }
}
/* --- LAYOUT MAPPA MENTALE --- */
.workspace-grid-map {
    display: grid;
    grid-template-columns: 35% 65%; /* Meno spazio all'input, più alla mappa */
    gap: 20px;
    margin-top: 20px;
}

/* Colonna Sinistra: Input più compatti */
.central-node-card {
    border-left: 5px solid #2d3748;
    background-color: #e2e8f0;
}

/* Colonna Destra: Visualizzazione */
.visual-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sticky-map-container {
    background: white;
    border-radius: 15px;
    padding: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid #cbd5e0;
}

.map-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
}

/* Flashcards Container */
.flashcards-container {
    background-color: transparent;
}

.instruction-text {
    font-size: 0.85rem;
    color: #718096;
    margin-bottom: 10px;
    font-style: italic;
}

.flashcard {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    border-left: 4px solid #cbd5e0;
    display: flex;
    gap: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

.flashcard:hover {
    transform: translateX(5px); /* Leggero movimento all'hover */
    border-left-color: #4a5568;
}

.card-icon {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    opacity: 0.7;
}

.card-content h4 {
    margin: 0 0 5px 0;
    color: #2d3748;
    font-size: 1rem;
}

.card-content p {
    margin: 0;
    font-size: 0.9rem;
    color: #4a5568;
    line-height: 1.4;
}

/* Responsività */
@media (max-width: 900px) {
    .workspace-grid-map { grid-template-columns: 1fr; }
}

/* Stile per la stampa (PDF) */
@media print {
    .school-header, .main-navigation, .input-column, .btn-pdf { display: none; }
    .workspace-grid-map { display: block; }
    .visual-column { width: 100%; }
    .sticky-map-container { border: none; box-shadow: none; }
}
/* Aggiungi nel blocco .student-area */
#class-input {
    padding: 8px;
    border-radius: 6px;
    border: none;
    margin-left: 5px;
    font-size: 0.9rem;
    cursor: pointer;
}
/* =========================================
   STILE PER IL SELETTORE CLASSE (HEADER)
   ========================================= */
#class-input {
    padding: 8px;
    border-radius: 6px;
    border: none;
    margin-left: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    background-color: #fff;
    color: #2d3748;
}

/* =========================================
   STILE PER IL WIDGET AI (TUTOR)
   ========================================= */
#ai-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000; /* Molto alto per stare sopra a tutto */
    font-family: 'Segoe UI', sans-serif;
}

/* Il bottone galleggiante */
#ai-toggle-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#ai-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

/* La finestra della chat */
#ai-chat-window {
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 80px; /* Sopra il bottone */
    right: 0;
    border: 1px solid #e2e8f0;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Testata Chat */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Area Messaggi */
.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f7fafc;
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    line-height: 1.4;
    word-wrap: break-word;
}

.bot-msg {
    background-color: #e2e8f0;
    color: #2d3748;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.user-msg {
    background-color: #764ba2;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

/* Area Controlli (Input) */
.chat-controls {
    padding: 10px;
    border-top: 1px solid #e2e8f0;
    background: white;
}

.action-btn {
    width: 100%;
    background-color: #ed8936; /* Arancione azione */
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 10px;
    font-weight: bold;
    transition: background 0.2s;
}
.action-btn:hover { background-color: #dd6b20; }

.input-group {
    display: flex;
    gap: 8px;
}

.input-group input {
    flex: 1;
    padding: 10px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    outline: none;
}
.input-group input:focus { border-color: #764ba2; }

.input-group button {
    background: #764ba2;
    color: white;
    border: none;
    padding: 0 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
}

/* Responsive per cellulari */
@media (max-width: 480px) {
    #ai-chat-window {
        width: 90vw; /* Quasi tutto lo schermo */
        right: 5vw;
        height: 60vh;
    }
}