/* Animations */
@keyframes pulse {
    0% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.5;
    }
}
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}


/* Style général pour la page */
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Verdana', sans-serif;
    color: #e0e0e0;
    background-color: #202020;
}

/* Conteneur principal */
#app {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden; /* Assure que rien ne dépasse du conteneur */
}

/* Conteneur de jeu (Phaser) */
#game-container {
    width: 100%;
    height: 100%;
    background-color: #000;
    position: relative;
}

/* Conteneur de l'UI */
#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Important : l'UI ne doit pas bloquer les interactions avec le jeu derrière */
}

/* Réactive les événements pour les éléments interactifs dans l'UI */
#ui-container * {
    pointer-events: auto;
}

/* Style de base pour les éléments UI */
.ui-element {
    position: absolute; /* Assure que les éléments peuvent être positionnés précisément */
    box-sizing: border-box; /* Inclut padding et border dans la largeur et la hauteur */
}

/* Centrage par défaut pour les éléments .ui-element */
.ui-element.centered {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Style général pour les panels */
.panel {
    background-color: rgba(34, 34, 34, 0.85);
    border: 2px solid #556b2f;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    color: #e0e0e0;
    max-width: 90%; /* Assure que le panel ne dépasse pas l'écran */
    max-height: 90%; /* Assure que le panel ne dépasse pas l'écran */
    overflow: auto; /* Ajoute une barre de défilement si nécessaire */
}

.panel.popup-style {
    /* Centered fxed */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000; /* Assure que le panel est au-dessus de tout autre élément */
}

/* Style des barres de ressources */
.bar-container {
    background-color: #444;
    border: 1px solid #556b2f;
    border-radius: 5px;
    overflow: hidden;
    width: 100%;
    height: 20px;
    margin: 10px 0;
    position: relative;
}
.bar {
    height: 100%;
    background-color: #6b8e23;
    width: 0%; /* La largeur sera mise à jour dynamiquement */
    transition: width 0.4s ease-in-out; /* Animation de transition fluide */
}
.bar-text {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    font-weight: bold;
    color: #e0e0e0;
}

/* Style pour les menus contextuels */
.context-menu {
    position: absolute;
    background-color: rgba(34, 34, 34, 0.9);
    border: 2px solid #556b2f;
    padding: 10px;
    border-radius: 8px;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    color: #e0e0e0;
}

.context-menu .menu-item {
    margin-bottom: 8px;
    cursor: pointer;
    padding: 10px;
    background-color: #444;
    border-radius: 5px;
    transition: background-color 0.2s;
    width: calc(100% - 20px);
}

.context-menu .menu-item:hover {
    background-color: #556b2f;
}

/* Effet de fondu pour les éléments */
.fade-in {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.fade-in.show {
    opacity: 1;
}

.spinner {
    border: 8px solid rgba(255, 255, 255, 0.2);
    border-left: 8px solid #6b8e23;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}




/**
* Preloader
*/
/* Style pour le préchargeur */
#preloader {
    position: fixed; /* Fixe le préchargeur au centre de l'écran */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(34, 34, 34, 0.9); /* Fond sombre avec opacité */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999; /* Assure que le préchargeur est au-dessus des autres éléments */
    pointer-events: none; /* Ne bloque pas les interactions avec le jeu */
}

#preloader-text {
    text-align: center;
    font-size: 24px;
    color: #e0e0e0;
    margin-bottom: 10px;
    animation: pulse 1.5s infinite; /* Animation de pulsation */
}

/* Animation en continu pour la barre de chargement */
#preloader-bar {
    animation: loading 2s infinite; /* Anime la barre de chargement */
}


/**
* Login
*/
#login {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);

    background-color: rgba(34, 34, 34, 0.85);
    width: 100%;
}
/* Style du logo */
#login .logo {
    display: block;
    width: 200px;
    margin-bottom: 20px;
    text-align: center;
}
#login .logo img {
    width: 100%;
    max-height: 100px; /* Limit height for logo */
    object-fit: contain;
    animation: spin 2s infinite; /* Animation de rotation */
}
#login .logo .logo__title {
    font-size: 24px;
    color: #e0e0e0;
    margin-top: 10px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7); /* Shadow for better readability */
}
#login .logo .logo__subtitle {
    font-size: 16px;
    color: #e0e0e0;
    margin-top: 5px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7); /* Shadow for better readability */
}
/* Style spécifique pour les panels de connexion */
.panel.login {
    width: 300px; /* Largeur fixe pour le panel de login */
}

/* Styles pour les éléments du formulaire de connexion */
.login__header {
    margin-bottom: 15px;
}

.login__title {
    font-size: 24px;
    margin: 0;
}

.login__form {
    display: flex;
    flex-direction: column;
}

/* Style de base pour les champs de saisie */
.login__form-input {
    width: 100%;
    padding: 10px; /* Ajustez le padding pour que le texte ne touche pas les bords */
    border: 1px solid #555;
    border-radius: 5px;
    background-color: #333;
    color: #e0e0e0;
    box-sizing: border-box; /* Assure que le padding est inclus dans la largeur totale */
    font-size: 16px; /* Ajustez la taille de la police pour la lisibilité */
}

/* Style pour les labels des champs de saisie */
.login__form-label {
    display: block; /* Assure que le label occupe toute la largeur disponible */
    margin-bottom: 5px; /* Espacement entre le label et le champ de saisie */
    font-size: 14px; /* Taille de police pour le label */
    color: #e0e0e0; /* Couleur du texte du label */
}

/* Style pour les groupes de formulaires */
.login__form-group {
    margin-bottom: 15px; /* Espacement entre les groupes de formulaires */
}


.login__form-button {
    background-color: #6b8e23;
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s, transform 0.2s;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.login__form-button:hover {
    background-color: #556b2f;
    transform: translateY(-2px);
}

.login__form-button:active {
    background-color: #4b7a1b;
    transform: translateY(1px);
}



/* Conteneur principal ajouté par Ui */
#main-menu {
    display: flex; /* Utilise flexbox pour aligner les enfants horizontalement */
    width: 100%;
    height: 100%;
}

/* Menu principal */
.menu-container {
    width: 250px; /* Largeur fixe du menu */
    background-color: #2c2c2c;
    border-right: 2px solid #555;
    height: 100vh; /* Prend toute la hauteur de la fenêtre */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-sizing: border-box;
}
.menu-container footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 10px;
    text-align: center;
    color: #e0e0e0;
    font-size: 14px;
}
.menu-container footer p {
    margin: 0;
}
.menu-container footer a {
    color: #e0e0e0;
    text-decoration: none;
    font-weight: bold;
}
.menu-container footer a:hover {
    text-decoration: underline;
}
.menu-container img.logo {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 250px;
    height: auto;
    vertical-align: middle;
    margin-right: 5px;
}

/* Style des éléments du menu */
.menu-item {
    width: 100%; /* Prend toute la largeur du menu */
    margin: 10px 0;
}

.menu-item .menu-item-text {
    width: 100%;
    padding: 15px;
    background-color: #333;
    border: 2px solid #555;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.menu-item:hover .menu-item-text {
    background-color: #6b8e23;
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
}

.menu-item:active .menu-item-text {
    background-color: #556b2f;
    transform: translateY(1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

/* Contenu d'animation */
.animation-container {
    flex: 1; /* Prend l'espace restant après le menu */
    padding: 20px;
    color: #e0e0e0;
    background-color: #202020;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden; /* Évite les débordements */
}

/* Styles pour l'animation CSS */
.animation-item {
    width: 50px;
    height: 50px;
    background-color: #6b8e23;
    border-radius: 50%;
    margin: 0 10px;
    animation: pulse 1.5s infinite ease-in-out;
}


/** LOADER **/
#loader {
    position: fixed; /* Fixe le loader au-dessus du jeu */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8); /* Fond sombre avec opacité */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000; /* Assure que le loader est au-dessus de tout autre élément */
    opacity: 0; /* Par défaut, le loader est invisible */
    transition: opacity 0.3s ease-in-out; /* Transition pour l'effet de fondu */
}

/* Contenu du loader */
.loader-content {
    text-align: center;
    background-color: rgba(34, 34, 34, 0.9); /* Fond légèrement opaque pour le contenu */
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7); /* Ombre pour le contenu */
    color: #e0e0e0; /* Couleur du texte */
}

/* Style pour le titre du loader */
.loader-content h1 {
    font-size: 28px;
    margin: 0 0 10px;
    font-weight: bold;
    color: #e0e0e0;
}

/* Style pour le message du loader */
.loader-content p {
    font-size: 18px;
    margin: 0;
    color: #e0e0e0;
}

/* Pour s'assurer que le transition est bien appliquée même en ajoutant des classes dynamiquement */
#loader.show {
    opacity: 1 !important; /* Utilise !important pour forcer l'application du style */
}



/* Style pour le conteneur des stats */
.panel.stats {
    display: flex;
    gap: 20px;
    padding: 10px 20px;
    background-color: rgba(34, 34, 34, 0.85); /* Conserve le style global des panels */
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); /* Ombre pour donner de la profondeur */
    align-items: center;
}

/* Style pour chaque élément de stats */
.stats-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background-color: rgba(50, 50, 50, 0.9); /* Un fond plus sombre pour un contraste agréable */
    border: 2px solid #556b2f; /* Garde la cohérence avec les autres panels */
    border-radius: 10px;
    width: 80px; /* Largeur fixe pour uniformité */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); /* Légère ombre pour un effet "carte" */
}

/* Style pour le titre (image) des stats */
.stats-item-title img {
    width: 40px;
    height: auto;
    margin-bottom: 5px; /* Espace entre l'image et la valeur */
}

/* Style pour la valeur des stats */
.stats-item-value {
    font-size: 18px;
    font-weight: bold;
    color: #e0e0e0; /* Garder le texte clair pour le contraste */
    text-align: center;
}

/* Ajouter une animation pour un effet visuel */
.stats-item-value.updated {
    animation: pop 0.3s ease;
}

/* Animation "pop" pour mettre en avant un changement de stats */
@keyframes pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}



/* Conteneur principal des actions */
#main-actions {
    position: absolute;
    bottom: 20px;
    left: 20px;
}

/* Conteneur des actions placé en bas à gauche */
.panel.action-container {
    display: flex;
    flex-direction: row;
    gap: 10px;
    padding: 10px;
    background-color: rgba(34, 34, 34, 0.85); /* Fond cohérent avec ton style */
    border: 2px solid #556b2f;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Style des boutons carrés */
.action-button {
    background-color: #444;
    padding: 10px;
    border: 2px solid #556b2f;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

/* Style des icônes */
.action-button img {
    width: 32px;
    height: 32px;
}

/* Effets au survol des boutons */
.action-button:hover {
    background-color: #6b8e23;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
}

/* Effet d'activation au clic */
.action-button:active {
    background-color: #556b2f;
    transform: translateY(1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

/* Adaptation responsive pour écrans plus petits */
@media (max-width: 768px) {
    .panel.action-container {
        gap: 8px;
        padding: 8px;
    }
    .action-button {
        width: 45px;
        height: 45px;
        padding: 8px;
    }
    .action-button img {
        width: 28px;
        height: 28px;
    }
}



/* Conteneur principal du panneau des priorités */
#taskPriorities {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
}

/* Style interne du panneau des priorités */
#taskPriorities .priorities-panel {
    width: 300px;
    background-color: rgba(34, 34, 34, 0.85);
    border: 2px solid #556b2f;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    color: #e0e0e0;
}

/* Titre du panneau */
.priorities-panel .panel-title {
    margin: 0 0 15px;
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    color: #e0e0e0;
}

/* Style pour chaque ligne de priorité */
.priority-item {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

/* Label de la priorité */
.priority-label {
    flex: 1;
    font-size: 16px;
}

.priorities-panel .priority-quantity {
    font-size: 14px;
    color: #b0b0b0; /* Couleur plus claire pour la quantité */
    margin-left: 5px;
    background-color: #444; /* Fond sombre pour la quantité */
    padding: 2px 5px;
    border-radius: 5px;
}

/* Curseur pour ajuster la priorité */
.priority-slider {
    width: 100px;
    margin: 0 10px;
}

/* Valeur de la priorité affichée à droite */
.priority-value {
    width: 40px;
    text-align: right;
    font-size: 16px;
}

/* Style pour les curseurs */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: #6b8e23;
    border-radius: 5px;
    outline: none;
    opacity: 0.9;
    transition: opacity 0.2s;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #556b2f;
    cursor: pointer;
    border-radius: 50%;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #556b2f;
    cursor: pointer;
    border-radius: 50%;
}


/* Pheromone */
#pheromones {
    position: absolute;
    bottom: 120px;
    left: 150px;
}
#pheromones .panel.pheromone-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    background-color: rgba(34, 34, 34, 0.85); /* Fond cohérent avec ton style */
    border: 2px solid #556b2f;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
#pheromones .panel .action-button {
    width: 40px;
    height: 40px;
    padding: 5px;
}



/* Build menu */
#build-menu {
    position: absolute;
    bottom: 120px;
    left: 30px;
}
#build-menu .panel.build-menu-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    background-color: rgba(34, 34, 34, 0.85); /* Fond cohérent avec ton style */
    border: 2px solid #556b2f;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}
#build-menu .panel .action-button {
    width: 40px;
    height: 40px;
    padding: 5px;
}