:root {
    --primary: #4a90e2;
    --bg: #f5f7fa;
    --text: #333;
    --white: #ffffff;
    --secondary: #6c757d;
    --success: #2ecc71;
    --admin-dark: #2c3e50;
}

body {
    font-family: 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    margin: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    color: var(--text);
}

#app {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Sur l'écran élèves, on élargit pour utiliser toute la largeur disponible */
#app.wide-students {
    max-width: 900px;
    height: 100vh;
    overflow: hidden;
    justify-content: center;
}

#app.wide-students #screen-students {
    height: 100%;
    overflow: hidden;
    justify-content: center;
}

#app.wide-students .list {
    overflow: hidden;
    align-content: center;
    justify-content: center;
}

/* --- Navigation & Écrans --- */
.screen {
    display: none;
    flex-direction: column;
    width: 100%;
    align-items: center; 
    text-align: center;
    animation: fadeIn 0.4s ease;
    position: relative; /* Pour positionner l'engrenage par rapport à la section */
}

.screen.active {
    display: flex;
}

h1 { color: var(--primary); font-size: 2.5rem; margin-bottom: 0.5rem; }
h2 { color: var(--text); margin: 15px 0; font-size: 1.5rem; }

/* --- Inputs & Boutons --- */
input[type="text"] {
    width: 100%;
    max-width: 280px;
    padding: 15px;
    font-size: 1.2rem;
    border: 2px solid #ddd;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 20px;
    text-transform: uppercase;
    box-sizing: border-box;
}

button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s;
}

button:active { transform: scale(0.95); }

.btn-secondary {
    background: var(--secondary);
    padding: 10px 20px;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* --- Bouton Admin (Gestion des cartes) --- */
.btn-admin {
    width: 100%;
    background-color: var(--admin-dark);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 12px;
    font-weight: bold;
    margin-bottom: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* --- Grilles (Classes & Élèves) --- */
.grid, .list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    width: 100%;
    margin-top: 10px;
}

.card-class, .student-tile {
    background: var(--white);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    cursor: pointer;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    transition: transform 0.2s, background 0.2s;
    box-sizing: border-box;
}

.student-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #eee;
}

.student-avatar svg {
    width: 70%;
    height: 70%;
    display: block;
}

/* --- Overlays (Général) --- */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(30, 39, 46, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

/* --- Clavier Numérique Admin --- */
.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
}

.num-btn {
    padding: 20px;
    font-size: 1.4rem;
    font-weight: bold;
    border: none;
    border-radius: 12px;
    background: #f1f2f6;
    cursor: pointer;
    transition: all 0.2s;
}

.num-btn:active {
    background: #dfe6e9;
    transform: scale(0.9);
}

#adminCodeDisplay {
    font-size: 2.5rem;
    letter-spacing: 8px;
    margin: 20px 0;
    min-height: 1.2em;
    border-bottom: 2px solid #ccc;
    font-family: monospace;
    color: var(--primary);
}

/* --- Style de la carte d'authentification --- */
.auth-card {
    background: white;
    width: 90%;
    max-width: 360px;
    border-radius: 25px;
    padding: 50px 20px 25px 20px;
    position: relative;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Avatar dans l'auth */
.auth-avatar-wrapper {
    position: absolute;
    top: -45px; 
    left: 50%;
    transform: translateX(-50%);
    width: 90px; 
    height: 90px;
}

.auth-avatar-circle {
    width: 100%; height: 100%;
    border-radius: 50%;
    border: 5px solid white;
    background: #bdc3c7;
    display: flex; 
    align-items: center; 
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* --- Picto Grid (Élèves) --- */
.picto-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 20px 0;
    width: 100%;
}

.picto-btn {
    font-size: 1.5rem;
    padding: 10px;
    background: #f1f2f6;
    border: none;
    border-radius: 12px;
    cursor: pointer;
}

.code-display {
    font-size: 1.5rem;
    min-height: 50px;
    width: 100%;
    background: #f1f2f6;
    border-radius: 12px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    letter-spacing: 10px;
    margin-bottom: 10px;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.error-shake {
    animation: shake 0.4s ease-in-out;
    border-color: #ff7675 !important;
    color: #ff7675 !important;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

/* --- Custom Coloris Style --- */
.clr-field {
    display: block;
    width: 65px;
    height: 65px;
    border-radius: 50%;
}

.clr-field button {
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    border: 3px solid #ccc !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
    padding: 0;
}

.clr-field input { display: none; }

/* Container de mission spécifique pour les tuiles de l'index */
.student-mission-preview {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(0,0,0,0.05);
}

.mini-box-index {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.65rem;
    font-weight: 900;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* La classe qui sera ajoutée à la tuile */
.student-tile.mission-complete {
    background: linear-gradient(135deg, #bdc3c7 0%, #ffffff 50%, #bdc3c7 100%) !important;
    border: 2px solid #ecf0f1 !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2), inset 0 0 10px rgba(255,255,255,0.5) !important;
    position: relative;
    overflow: hidden;
}

/* L'effet de brillance (le reflet qui passe) */
.student-tile.mission-complete::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to bottom right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0) 40%,
        rgba(255, 255, 255, 0.8) 50%,
        rgba(255, 255, 255, 0) 60%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(-45deg);
    animation: shine-silver 3s infinite;
}

@keyframes shine-silver {
    0% { transform: translateX(-100%) translateY(-100%) rotate(-45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(-45deg); }
}

/* Optionnel : Ajuster le nom de l'élève pour qu'il ressorte sur l'argent */
.student-tile.mission-complete .student-name {
    color: #2c3e50 !important;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.5);
    font-weight: 800;
}
