/* === 1. IMPORTATION ET VARIABLES === */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');

:root {
    /* Police */
    --font-main: 'Poppins', sans-serif;
    
    /* Thème Clair (Défaut) */
    --bg-color: linear-gradient(180deg, #e6f7ff 0%, #ffffff 40%);
    --bg-static: #f8f9fa; /* Pour le dark mode */
    --card-bg: #ffffff;
    --text-color: #212529;
    --text-color-light: #5f6368;
    --border-color: #dee2e6;
    --accent-color: #3498db;
    --accent-color-hover: #2980b9;
    --green-color: #2ecc71;
    --green-color-hover: #27ae60;
    --red-color: #e74c3c;
    --orange-color: #e67e22;
    --orange-color-hover: #d35400;
    --canvas-border: #000;
    --shadow: 0 4px 12px rgba(0, 87, 131, 0.08);

    /* Thème Sombre */
    --bg-color-dark: linear-gradient(180deg, #0f2027 0%, #203a43 100%);
    --bg-static-dark: #121212;
    --card-bg-dark: #1e1e1e;
    --text-color-dark: #e0e0e0;
    --text-color-light-dark: #9e9e9e;
    --border-color-dark: #424242;
    --canvas-border-dark: #fff;
    --shadow-dark: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body { 
    font-family: var(--font-main); 
    display: grid; 
    place-items: center; 
    background: var(--bg-color);
    background-attachment: fixed; /* Le dégradé reste fixe */
    color: var(--text-color);
    margin: 0; 
    padding: 20px; 
    min-height: 95vh; 
    transition: background 0.3s, color 0.3s;
}

/* === 2. THÈME SOMBRE === */
body.dark-mode {
    --bg-color: var(--bg-color-dark);
    --bg-static: var(--bg-static-dark);
    --card-bg: var(--card-bg-dark);
    --text-color: var(--text-color-dark);
    --text-color-light: var(--text-color-light-dark);
    --border-color: var(--border-color-dark);
    --canvas-border: var(--canvas-border-dark);
    --shadow: var(--shadow-dark);
}

/* === 3. ÉLÉMENTS COMMUNS (Boutons, Inputs, Cartes) === */
h2, h3 {
    font-weight: 700;
    color: var(--text-color);
}
p {
    color: var(--text-color-light);
}
hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
}

/* Cartes génériques (lobby, jeu, etc.) */
.card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow);
    text-align: center;
    border: 1px solid var(--border-color);
    transition: background 0.3s, border-color 0.3s;
    width: 100%;
    max-width: 600px;
    box-sizing: border-box; /* Important */
}

/* Boutons génériques */
button {
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
}
button:disabled {
    background: #95a5a6 !important;
    cursor: not-allowed !important;
}

/* Inputs génériques */
input[type="text"] {
    font-family: var(--font-main);
    font-size: 1.1rem;
    padding: 10px 15px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: var(--bg-static);
    color: var(--text-color);
    text-align: center;
    box-sizing: border-box;
    width: 100%;
    max-width: 300px;
    margin-bottom: 15px;
}
input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

/* === 4. BOUTON DARK MODE === */
#darkModeToggle {
    position: fixed;
    top: 20px;
    right: 20px;
    font-size: 1.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    padding: 0;
    display: grid;
    place-items: center;
    box-shadow: var(--shadow);
    z-index: 100;
}
body.dark-mode #darkModeToggle::before { content: '☀️'; }
body:not(.dark-mode) #darkModeToggle::before { content: '🌙'; }

/* === 5. STYLES SPÉCIFIQUES === */

/* --- LOBBY --- */
#lobby #inputNickname {
    width: 100%;
    max-width: 300px;
}
#lobby #inputRoomCode {
    text-transform: uppercase;
    width: 150px;
    margin: 10px;
}
#btnCreate {
    background: var(--green-color);
    color: #fff;
}
#btnCreate:hover { background: var(--green-color-hover); }
#btnJoin {
    background: var(--accent-color);
    color: #fff;
}
#btnJoin:hover { background: var(--accent-color-hover); }

/* --- JEU (Conteneur principal) --- */
#game { display: none; }
#gameInfo {
    font-size: 1.2rem;
    background: var(--card-bg);
    padding: 10px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    font-weight: 600;
}
#gameInfo span {
    font-weight: 700;
    color: var(--red-color);
    user-select: all;
}

/* --- Zone d'attente --- */
#waitingArea {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}
#playerList {
    list-style-type: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}
#playerList li {
    background: var(--bg-static);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 600;
    border: 1px solid var(--border-color);
}
#btnStartGame {
    background: var(--orange-color);
    color: white;
    padding: 15px 30px;
    font-size: 1.2rem;
}
#btnStartGame:hover { background: var(--orange-color-hover); }

/* --- Zones de Tâche (Prompt, Describe) --- */
#promptArea, #describeArea {
    display: none;
    text-align: center;
    margin-top: 20px;
    width: 100%;
}
#promptArea input, #describeArea input {
    width: 100%;
    max-width: 450px;
}
#promptArea button, #describeArea button, #btnSubmitDrawing {
    background: var(--green-color);
    color: white;
    margin-top: 10px;
}
#promptArea button:hover, #describeArea button:hover, #btnSubmitDrawing:hover {
    background: var(--green-color-hover);
}
#describeArea img {
    display: block;
    max-width: 500px;
    width: 100%;
    border: 2px solid var(--canvas-border);
    border-radius: 8px;
    margin: 10px auto;
    background: #fff; /* Fond blanc pour les dessins transparents */
}

/* --- Zone de Tâche (Dessin) --- */
#drawTaskArea {
    display: none;
    background: var(--card-bg);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 2px dashed var(--accent-color);
}
#drawTaskArea p {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 5px 0 0 0;
}

/* --- CANVAS & CONTRÔLES (v11) --- */
#canvas-container {
    background: #fff; /* Canvas toujours blanc */
    border: 2px solid var(--canvas-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    width: 500px; /* Taille fixe */
    height: 500px; /* Taille fixe */
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}
#drawCanvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 6px;
    cursor: crosshair; /* Curseur de dessin */
}

#controls {
    display: none; /* Caché par défaut */
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}
.controls-section {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}
.controls-section h4 {
    width: 100%;
    text-align: center;
    margin: 0 0 5px 0;
    font-weight: 600;
    color: var(--text-color-light);
}

/* Outils (Crayon, Seau) */
.tool-btn {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    padding: 0;
    background: var(--bg-static);
    color: var(--text-color);
    border: 2px solid var(--border-color);
}
.tool-btn.active { /* Bouton actif */
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color-hover);
}

/* Taille Pinceau */
.size-btn {
    background: var(--bg-static);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    width: 40px;
    height: 40px;
    padding: 0;
    display: grid;
    place-items: center;
}
.size-btn span {
    display: block;
    background: var(--text-color);
    border-radius: 50%;
}
.size-btn[data-size="2"] span { width: 4px; height: 4px; }
.size-btn[data-size="5"] span { width: 8px; height: 8px; }
.size-btn[data-size="10"] span { width: 14px; height: 14px; }
.size-btn[data-size="20"] span { width: 20px; height: 20px; }
.size-btn.active { /* Taille active */
    background: var(--accent-color);
    border-color: var(--accent-color-hover);
}
.size-btn.active span { background: #fff; }

/* Palette de couleurs */
#color-palette {
    max-width: 320px; /* (8 * 30px) + (7 * 8px) */
}
.color-btn {
    width: 30px;
    height: 30px;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    padding: 0;
    outline: 0;
    transition: all 0.1s ease;
}
.color-btn.active { /* Couleur active */
    transform: scale(1.2);
    border: 3px solid var(--accent-color);
}

/* === 6. ZONE DE RÉVÉLATION (v10) === */
#revealArea {
    display: none; /* Caché par défaut */
    width: 100%;
    text-align: center;
}
#revealHeader {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 10px;
    background: var(--card-bg);
    padding: 10px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}
#revealContent {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
    min-height: 400px;
    /* C'est notre "chat" */
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto; /* Si le chat est long */
    max-height: 60vh;
    border: 1px solid var(--border-color);
}
/* Style pour chaque étape du "chat" */
.reveal-step {
    padding: 10px 15px;
    border-radius: 10px;
    text-align: left;
    max-width: 80%;
    word-wrap: break-word;
}
.reveal-prompt, .reveal-description {
    background: var(--bg-static);
    border: 1px solid var(--border-color);
    align-self: flex-start;
    color: var(--text-color);
}
.reveal-drawing {
    background: none;
    padding: 0;
    align-self: center; /* Les dessins sont centrés */
    width: 100%;
    max-width: 400px;
}
.reveal-drawing img {
    width: 100%;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: #fff; /* Fond blanc */
}
.reveal-author {
    font-size: 0.9rem;
    color: var(--text-color-light);
    font-weight: 600;
    margin-bottom: 5px;
    text-align: left;
}
#revealControls {
    display: none; /* Caché, sauf pour le host */
    margin-top: 20px;
}
#revealControls button {
    background: var(--accent-color);
    color: #fff;
    border: none;
    padding: 12px 20px;
    font-size: 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    margin: 0 10px;
}
#revealControls button:hover {
    background: var(--accent-color-hover);
}

/* === 8. NOUVEAU (v13) : LIENS SOCIAUX ET FOOTER === */

/* --- Liens Sociaux sur le côté --- */
#social-links {
    position: fixed;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}
#social-links a {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    box-shadow: var(--shadow);
    font-size: 1.5rem;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s ease;
}
#social-links a:hover {
    background: var(--accent-color);
    color: #fff;
    transform: scale(1.1);
}

/* --- Footer --- */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    padding: 15px 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    color: var(--text-color-light);
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.05);
}
body.dark-mode footer {
    box-shadow: 0 -2px 5px rgba(0,0,0,0.2);
}

/* === 9. NOUVEAU (v13) : RESPONSIVE DESIGN === */
@media (max-width: 900px) {
    /* Cacher les liens sociaux sur les petits écrans */
    #social-links {
        display: none;
    }
    
    .card {
        padding: 1.5rem;
        width: 95%;
    }
    #game {
        max-width: 95%;
        padding: 1rem;
    }
    /* Le canvas doit s'adapter */
    #canvas-container {
        width: 100%;
        height: auto; /* Dégage la hauteur fixe */
        aspect-ratio: 1 / 1; /* Le garde carré */
    }
    #controls {
        max-width: 100%;
    }
    #color-palette {
        max-width: 100%;
    }
}