/* --- DESIGN SYSTEM SACRAFAMIGLIA --- */
:root {
    --primary: #1a365d;
    --accent: #3182ce;
    --success: #38a169;
    --danger: #e53e3e;
    --warning: #d69e2e;
    --bg-main: #f7fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    --text: #2d3748;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg-main); color: var(--text); margin: 0; padding-bottom: 60px; }

/* --- HEADER --- */
.school-header { background: var(--white); padding: 20px 40px; border-bottom: 5px solid var(--primary); box-shadow: var(--shadow-sm); }
.header-content { max-width: 1200px; margin: auto; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 20px; }
.school-name { font-weight: 900; font-size: 1.5rem; color: var(--primary); letter-spacing: -0.5px; }
.school-type { font-size: 0.8rem; text-transform: uppercase; color: #718096; font-weight: bold; }

/* STUDENT LOGIN AREA */
.student-area { display: flex; align-items: center; gap: 10px; }
.student-area input, .student-area select { padding: 10px 15px; border: 2px solid var(--border); border-radius: 10px; font-weight: 500; font-family: inherit; }
.btn-login { background: var(--primary); color: white; border: none; padding: 10px 25px; border-radius: 10px; font-weight: 800; cursor: pointer; transition: 0.3s; }
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.btn-logout { background: #fee2e2; color: var(--danger); border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; }

/* --- LAYOUT CONTENUTI --- */
.main-container { max-width: 1000px; margin: 40px auto; padding: 0 20px; }
.mission-briefing { text-align: center; margin-bottom: 50px; }
.mission-briefing h1 { font-size: 2.5rem; color: var(--primary); margin-bottom: 10px; }

.activity-section { background: var(--white); padding: 35px; border-radius: 25px; margin-bottom: 40px; box-shadow: var(--shadow-md); border: 1px solid #edf2f7; }
.section-title { font-size: 1.6rem; color: var(--primary); border-left: 6px solid var(--accent); padding-left: 20px; margin-bottom: 30px; }
.instruction { font-size: 0.95rem; color: #718096; font-style: italic; margin-bottom: 20px; }

/* --- INPUTS E TEXTAREA ELEGANTI --- */
.custom-field {
    width: 100%; padding: 15px 18px; border: 2px solid var(--border); border-radius: 12px;
    font-size: 1rem; background: #f8fafc; transition: all 0.3s ease; margin-bottom: 12px;
}
.custom-field:focus { border-color: var(--accent); background: white; outline: none; box-shadow: 0 0 0 4px rgba(49, 130, 206, 0.1); }

.custom-textarea {
    width: 100%; min-height: 180px; padding: 20px; border: 2px solid var(--border); border-radius: 18px;
    font-size: 1.1rem; line-height: 1.7; background: #f8fafc; transition: all 0.3s; resize: vertical;
}
.custom-textarea:focus { border-color: var(--success); background: white; outline: none; box-shadow: 0 0 0 4px rgba(56, 161, 105, 0.1); }

/* --- 1. VIDEO VIEW --- */
.split-view { display: flex; gap: 30px; flex-wrap: wrap; }
.video-wrapper { flex: 1.5; min-width: 320px; border-radius: 15px; overflow: hidden; background: #000; height: 300px; }
.video-wrapper iframe { width: 100%; height: 100%; border: none; }
.evidence-log { flex: 1; min-width: 280px; }

/* --- 2. ALGORITMO GRID --- */
.info-box { background: #ebf8ff; padding: 15px; border-radius: 12px; border-left: 5px solid var(--accent); margin-bottom: 25px; }
.algorithm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.algo-card { border: 1px solid #f1f5f9; padding: 25px; border-radius: 20px; text-align: center; transition: 0.3s; }
.algo-card:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: var(--shadow-sm); }
.algo-icon { font-size: 3rem; margin-bottom: 15px; display: block; }
.algo-text { font-size: 0.85rem; color: #4a5568; margin-bottom: 15px; min-height: 45px; display: block; }
.algo-card.special { border: 2px solid var(--danger); background: #fff5f5; }

/* --- 3. MATTONCINI MAGICI --- */
.focus-activity { border: 2px solid var(--accent); background: #f0f9ff; }
.audio-box { text-align: center; margin-bottom: 25px; }
.audio-box audio { width: 100%; max-width: 500px; }
.magic-bricks-container { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.magic-brick {
    background: #e2e8f0; color: #94a3b8; padding: 10px 22px; border-radius: 50px;
    font-weight: 800; font-size: 0.9rem; transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.magic-brick.active { background: var(--success); color: white; transform: scale(1.1); box-shadow: 0 4px 15px rgba(56, 161, 105, 0.4); }

/* --- 4. SEMAFORO (DRAG & DROP) --- */
.word-bank { background: #f1f5f9; padding: 25px; border-radius: 20px; border: 2px dashed #cbd5e0; display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 30px; }
.draggable-item {
    background: white; padding: 10px 20px; border-radius: 50px; cursor: grab;
    border: 1px solid #cbd5e0; font-weight: 700; font-size: 0.85rem; box-shadow: var(--shadow-sm);
}
.draggable-item:active { cursor: grabbing; }

.traffic-light-grid { display: flex; gap: 20px; min-height: 400px; flex-wrap: wrap; }
.light-col { flex: 1; min-width: 250px; padding: 25px; border-radius: 25px; display: flex; flex-direction: column; text-align: center; }
.light-col b { font-size: 1.1rem; margin-bottom: 15px; display: block; }
.drop-zone { flex-grow: 1; border: 2px dashed rgba(0,0,0,0.1); border-radius: 15px; padding: 15px; display: flex; flex-direction: column; gap: 10px; }

.red { background: #fff5f5; border: 2px solid #fecaca; color: #9b2c2c; }
.yellow { background: #fffbeb; border: 2px solid #fef3c7; color: #975a16; }
.green { background: #f0fdf4; border: 2px solid #dcfce7; color: #22543d; }

/* FEEDBACK VERIFICA */
.correct-item { border: 3px solid var(--success) !important; box-shadow: 0 0 10px var(--success) !important; }
.wrong-item { border: 3px solid var(--danger) !important; box-shadow: 0 0 10px var(--danger) !important; }

/* CONTROLLI */
.control-btns { display: flex; justify-content: center; gap: 15px; margin-top: 30px; }
.btn-check { background: var(--accent); color: white; border: none; padding: 15px 30px; border-radius: 12px; font-weight: bold; cursor: pointer; transition: 0.2s; }
.btn-reset { background: #718096; color: white; border: none; padding: 15px 30px; border-radius: 12px; font-weight: bold; cursor: pointer; }

/* --- FINAL ACTIONS --- */
.final-export { text-align: center; margin: 80px 0; }
.btn-pdf {
    background: linear-gradient(135deg, var(--danger) 0%, #b91c1c 100%);
    color: white; border: none; padding: 22px 60px; border-radius: 100px;
    font-weight: 900; font-size: 1.3rem; cursor: pointer; transition: 0.3s;
    box-shadow: 0 10px 25px rgba(229, 62, 62, 0.4);
}
.btn-pdf:hover { transform: scale(1.05); }

/* --- STAMPA --- */
@media print {
    body { background: white; }
    .btn-pdf, .student-area, .word-bank, .control-btns, iframe, audio, .btn-logout, .instruction { display: none !important; }
    .activity-section { box-shadow: none; border: 1px solid #eee; break-inside: avoid; margin-bottom: 20px; }
    .main-container { margin: 0; width: 100%; max-width: 100%; }
    .custom-field, .custom-textarea { border: 1px solid #ccc; background: white; }
}