/* --- Styles Généraux et Réinitialisations --- */
body {
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; /* Police moderne et lisible */
    background-color: #0A0A0A; /* Noir très profond pour le fond principal de l'app */
    margin: 0;
    padding: 0;
    color: #E0E0E0; /* Blanc cassé pour le texte par défaut sur fond sombre */
    line-height: 1.6;
    -webkit-font-smoothing: antialiased; /* Lissage des polices */
    -moz-osx-font-smoothing: grayscale; /* Idem pour Firefox */
    display: flex; /* Utilise flexbox pour centrer le contenu verticalement si nécessaire */
    flex-direction: column;
    min-height: 100vh; /* S'assure que le corps prend au moins toute la hauteur de la vue */
    overflow-x: hidden; /* Empêche le défilement horizontal */
}

*, *::before, *::after {
    box-sizing: border-box;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    border: none;
    cursor: pointer;
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
}

input, textarea {
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    background-color: #1A1A1A; /* Fond sombre pour les inputs */
    color: #E0E0E0; /* Texte blanc cassé pour les inputs */
}
input::placeholder, textarea::placeholder {
    color: #909090; /* Couleur du placeholder */
}

/* --- Top-Right Buttons (Profil, Partage, Notification) --- */
.top-right-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin: 20px 25px 0 0;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 1000;
}

.icon-btn {
    background: linear-gradient(to bottom right, #1A1A1A, #0A0A0A);
    border: 1px solid #282828;
    padding: 12px;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}

.icon-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);
    background: linear-gradient(to bottom right, #2E8B57, #246B44);
}
.icon-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4) inset;
}

.icon-btn img {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1); /* Makes icons white */
    transition: filter 0.3s ease;
}
.icon-btn:hover img {
    filter: none; /* Reset filter on hover if background becomes colored */
}

/* --- Main Chat Container --- */
#chat {
    flex-grow: 1;
    max-width: 700px;
    margin: 30px auto 20px auto; /* Adjusted bottom margin for game info */
    padding: 25px;
    background: linear-gradient(135deg, #1C1C1E 0%, #111111 100%);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid #282828;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    gap: 15px;
    scroll-behavior: smooth; /* Smooth scrolling for new messages */
}

/* --- Message Styles --- */
.message {
    margin: 0;
    padding: 12px 15px;
    border-radius: 18px;
    max-width: 85%;
    display: flex;
    align-items: flex-start; /* Align content to the top */
    font-size: 1.05em;
    word-wrap: break-word;
}

.ia {
    background-color: #282828;
    color: #E0E0E0;
    border-top-left-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    align-self: flex-start; /* Ensure IA messages are on the left */
}

.user {
    background-color: #2E8B57; /* Kinema+ Green */
    color: #FFFFFF;
    justify-content: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    align-self: flex-end; /* Ensure user messages are on the right */
}

.message img {
    width: 35px;
    height: 35px;
    margin-right: 10px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #555555;
    flex-shrink: 0;
}

.message .message-content {
    flex-grow: 1; /* Allows the content to take available space */
}

/* Ensure user messages have avatar space on the left if needed, but not showing avatar for user */
.user .message-content {
    margin-right: 0; /* No right margin if avatar is not there */
    margin-left: auto; /* Push content to left if it's a right-aligned message */
}

/* --- Game Info (Scores and Timer) --- */
.game-info {
    max-width: 700px;
    margin: 10px auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 25px;
    font-weight: 600;
    font-size: 1.1em;
    color: #F8F8F8;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

#scores {
    flex-grow: 1;
    text-align: left;
}

#timer {
    text-align: right;
    color: #F8F8F8;
}

#timer span, #scores span {
    color: #2E8B57; /* Highlight with Kinema+ Green */
    font-weight: 700;
}


/* --- Start Button --- */
#start-btn {
    display: block;
    margin: 20px auto 30px auto; /* Adjusted margins */
    background-color: #2E8B57;
    color: #fff;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.2em;
    font-weight: 700;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}
#start-btn:hover {
    background-color: #246B44;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}
#start-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5) inset;
}

/* --- Input Area --- */
#input-area {
    max-width: 700px;
    margin: 20px auto 90px auto; /* Adjusted bottom margin for bottom nav */
    display: flex;
    gap: 10px;
    padding: 10px;
    background-color: #1A1A1A;
    border-radius: 12px;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid #282828;
    width: 95%; /* Ensure it's not too wide on small screens */
    display: none; /* Hidden by default, shown by JS */
}

#input-area input[type="text"] {
    flex-grow: 1;
    padding: 12px 15px;
    border-radius: 25px;
    border: 1px solid #333333;
    background-color: #0A0A0A;
    color: #E0E0E0;
    font-size: 1em;
    box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.2);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#input-area input[type="text"]:focus {
    outline: none;
    border-color: #2E8B57;
    box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(46, 139, 87, 0.3);
}

#input-area button {
    padding: 12px 20px;
    background-color: #2E8B57;
    color: #fff;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

#input-area button:hover {
    background-color: #246B44;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}
#input-area button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4) inset;
    background-color: #1A5432;
}

/* --- Bottom Navigation --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #111111;
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    z-index: 999;
    box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.4);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-top: 1px solid #282828;
}

.bottom-nav .nav-item {
    color: #888888;
    text-align: center;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
    padding: 8px 5px;
    border-radius: 12px;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
    flex-grow: 1;
    max-width: 90px;
}

.bottom-nav .nav-item img {
    filter: invert(70%);
    margin-bottom: 5px;
    width: 26px;
    height: 26px;
    transition: filter 0.3s ease;
}

.bottom-nav .nav-item span {
    font-size: 0.9em;
    font-weight: 500;
}

.bottom-nav .nav-item:hover {
    background-color: #1A1A1A;
    color: #E0E0E0;
    transform: translateY(-3px);
}
.bottom-nav .nav-item:hover img {
    filter: invert(100%);
}

.bottom-nav .nav-item.active {
    background-color: #2E8B57;
    color: #fff;
    transform: translateY(-5px);
    box-shadow: 0 -5px 15px rgba(46, 139, 87, 0.3);
}
.bottom-nav .nav-item.active img {
    filter: invert(0%) brightness(100%);
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .top-right-buttons {
        gap: 10px;
        margin: 15px 15px 0 0;
    }
    .icon-btn {
        width: 40px;
        height: 40px;
        padding: 8px;
    }
    .icon-btn img {
        width: 20px;
        height: 20px;
    }

    #chat {
        max-width: 95%;
        margin-top: 20px;
        padding: 15px;
        border-radius: 10px;
    }
    .message {
        padding: 10px 12px;
        border-radius: 15px;
        max-width: 90%;
        font-size: 1em;
    }
    .message img {
        width: 30px;
        height: 30px;
    }
    .game-info {
        max-width: 95%;
        padding: 8px 15px;
        font-size: 1em;
    }
    #start-btn {
        padding: 12px 25px;
        font-size: 1.1em;
        border-radius: 25px;
        margin: 20px auto;
    }
    #input-area {
        max-width: 95%;
        margin-top: 15px;
        padding: 8px;
        border-radius: 10px;
    }
    #input-area input[type="text"] {
        padding: 10px 12px;
        font-size: 0.95em;
        border-radius: 20px;
    }
    #input-area button {
        padding: 10px 15px;
        font-size: 1em;
        border-radius: 20px;
    }
    .bottom-nav .nav-item {
        font-size: 10px;
        padding: 6px 3px;
    }
    .bottom-nav .nav-item img {
        width: 22px;
        height: 22px;
    }
}

@media (max-width: 480px) {
    .top-right-buttons {
        gap: 8px;
        margin: 10px 10px 0 0;
    }
    .icon-btn {
        width: 35px;
        height: 35px;
        padding: 6px;
    }
    .icon-btn img {
        width: 18px;
        height: 18px;
    }

    #chat {
        max-width: 100%;
        margin-left: 10px;
        margin-right: 10px;
        padding: 10px;
        border-radius: 8px;
    }
    .message {
        padding: 8px 10px;
        border-radius: 12px;
        max-width: 95%;
        font-size: 0.95em;
    }
    .message img {
        width: 25px;
        height: 25px;
        margin-right: 8px;
    }
    .game-info {
        max-width: 100%;
        margin-left: 10px;
        margin-right: 10px;
        padding: 6px 10px;
        font-size: 0.9em;
    }
    #start-btn {
        padding: 10px 20px;
        font-size: 1em;
        border-radius: 20px;
        margin: 15px auto;
    }
    #input-area {
        max-width: 100%;
        margin-left: 10px;
        margin-right: 10px;
        padding: 6px;
        border-radius: 8px;
    }
    #input-area input[type="text"] {
        padding: 8px 10px;
        font-size: 0.9em;
        border-radius: 18px;
    }
    #input-area button {
        padding: 8px 12px;
        font-size: 0.9em;
        border-radius: 18px;
    }
    .bottom-nav .nav-item {
        font-size: 9px;
        padding: 5px 2px;
    }
    .bottom-nav .nav-item img {
        width: 18px;
        height: 18px;
    }
}
