/* public/style.css */

/* --- Variables CSS (pour la cohérence et la facilité de modification) --- */
:root {
    --bg-color: #38309a; /* Arrière-plan plus clair et neutre */
    --primary-blue: #007bff; /* Bleu principal dynamique */
    --primary-blue-light: #e6f2ff; /* Bleu très clair pour fond discret */
    --primary-blue-dark: #0056b3; /* Bleu plus foncé pour le hover */
    --secondary-green: #28a745; /* Vert vif pour le succès */
    --secondary-green-dark: #218838; /* Vert plus foncé pour le hover */
    --text-color: #343a40; /* Texte principal sombre */
    --light-text-color: #6c757d; /* Texte secondaire */
    --card-bg: #ffffff; /* Fond blanc pur pour les cartes */
    --border-light: #e9ecef; /* Bordure très légère */
    --red-alert: #dc3545; /* Rouge pour les actions d'alerte */
    --red-alert-dark: #c82333;
    --shadow-base: rgba(0, 0, 0, 0.08); /* Ombre de base plus subtile */
    --shadow-hover: rgba(0, 0, 0, 0.15); /* Ombre au survol plus présente */
}

/* --- Styles Généraux --- */
body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.container {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 20px var(--shadow-base);
    width: 100%;
    max-width: 900px;
    box-sizing: border-box;
    transition: all 0.3s ease-in-out;
}

h1, h2, h3 {
    color: var(--text-color);
    text-align: center;
    margin-bottom: 20px;
    font-weight: 700;
}

h1 {
    font-size: 3em;
    padding-bottom: 15px;
    position: relative;
    letter-spacing: 1.5px;
    color: var(--primary-blue);
}

h1::after {
    content: '';
    display: block;
    width: 100px;
    height: 5px;
    background: var(--primary-blue);
    margin: 15px auto 0;
    border-radius: 2px;
}

h2 {
    font-size: 2.2em;
    color: var(--text-color);
    margin-top: 40px;
    margin-bottom: 25px;
    position: relative;
    padding-bottom: 10px;
}

h2::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background: var(--secondary-green);
    margin: 10px auto 0;
    border-radius: 2px;
}

p {
    margin-bottom: 10px;
    color: var(--light-text-color);
    text-align: center;
}

/* --- Logo --- */
.logo-container {
    text-align: center;
    margin-bottom: 40px;
}

.app-logo {
    max-width: 200px;
    height: auto;
    border-radius: 50%;
    box-shadow: 0 6px 15px var(--shadow-base);
    transition: transform 0.3s ease;
}

.app-logo:hover {
    transform: scale(1.05);
}

/* --- Onglets --- */
.tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
    gap: 15px;
}

.tab-button {
    background-color: var(--border-light);
    border: none;
    padding: 16px 30px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--light-text-color);
    transition: all 0.3s ease;
    border-radius: 8px;
    box-shadow: 0 4px 10px var(--shadow-base);
}

.tab-button:hover {
    background-color: var(--primary-blue-dark);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px var(--shadow-hover);
}

.tab-button.active {
    background: var(--primary-blue);
    color: #ffffff;
    box-shadow: 0 4px 10px var(--shadow-hover);
    transform: translateY(0);
    pointer-events: none;
}

.tab-content {
    display: none;
    padding: 25px 0;
}

.tab-content.active {
    display: block;
}

/* --- Sections de Tâches et Scores --- */
.task-section, .scores-section, .history-section {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 6px 15px var(--shadow-base);
    border: 1px solid var(--border-light);
}

.task-list, .scores-list, .history-list {
    margin-top: 25px;
}

/* --- Style des cartes de tâches (Pending/Active) --- */
.task-item {
    border-radius: 12px;
    padding: 18px 25px;
    margin-bottom: 12px;
    transition: all 0.25s ease-in-out;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;

    background: var(--card-bg); /* Fond blanc */
    color: var(--text-color); /* Texte sombre */
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.15); /* Ombre douce, légèrement bleutée */
    border: 1px solid var(--primary-blue-light); /* Bordure très fine et claire */
    cursor: pointer;
}

.task-item:hover:not(.completed) {
    transform: translateY(-5px) scale(1.01);
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.25);
    background-color: var(--primary-blue-light);
}

.task-item h3 {
    margin-top: 0;
    margin-bottom: 8px;
    color: var(--primary-blue);
    font-size: 1.3em;
    font-weight: 700;
}

.task-item p {
    margin-bottom: 6px;
    font-size: 0.95em;
    color: var(--light-text-color);
}

.task-meta {
    font-weight: 600;
    color: var(--text-color);
}

.task-score {
    font-weight: 800;
    color: var(--secondary-green);
    font-size: 1.1em;
    margin-top: 5px;
}

/* Style des tâches terminées (plus discrètes mais lisibles) */
.task-item.completed {
    background: var(#8b9196);
    color: var(#f4f6f9);
    opacity: 0.8;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
    transform: none;
    cursor: not-allowed;
    border: 1px solid var(--border-light);
    padding: 15px 20px;
    margin-bottom: 10px;
}

.task-item.completed h3,
.task-item.completed p,
.task-item.completed .task-meta,
.task-item.completed .task-score {
    color: inherit;
    font-size: inherit;
}
.task-item.completed .assign-button {
    display: none;
}


/* --- Boutons Généraux (Flat Design) --- */
.flat-button {
    background: var(--primary-blue);
    color: white;
    padding: 14px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.05em;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 4px 10px var(--shadow-base);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.flat-button:hover {
    background: var(--primary-blue-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px var(--shadow-hover);
}

.flat-button:active {
    transform: translateY(0);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Bouton Annuler */
.cancel-button {
    background: var(--light-text-color); /* Gris pour annuler */
}
.cancel-button:hover {
    background: #5a6268; /* Gris plus foncé */
}


/* Bouton spécifique de réinitialisation */
#resetScoresButton {
    background: var(--red-alert);
    display: block;
    margin: 30px auto 0;
}

#resetScoresButton:hover {
    background: var(--red-alert-dark);
}

/* Classe pour cacher les éléments */
.hidden {
    display: none !important;
}

/* --- Champ de saisie du nom (Flat Design) --- */
.name-input-wrapper {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 25px 30px;
    background-color: var(--primary-blue-light);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 123, 255, 0.3);
    border: 1px solid var(--primary-blue);
    width: 90%;
    max-width: 450px;
    
    opacity: 0; 
    visibility: hidden;
    transition: opacity 0.3s ease-out, visibility 0.3s ease-out, transform 0.3s ease-out;

    align-items: center;
    text-align: center;
}

.name-input-wrapper.visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* Overlay pour le fond sombre derrière la pop-up */
.name-input-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.name-input-overlay.visible {
    opacity: 1;
    visibility: visible;
}


.assignee-name-input {
    width: 90%;
    max-width: 300px;
    padding: 12px 15px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 1em;
    background-color: var(--card-bg);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
}

.assignee-name-input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.input-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    justify-content: center;
}

.submit-assignee-name {
    padding: 10px 20px;
    font-size: 1em;
    background: var(--secondary-green);
}

.submit-assignee-name:hover {
    background: var(--secondary-green-dark);
}

/* --- Indicateur de chargement --- */
#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(244, 246, 249, 0.95); /* Fond semi-transparent clair */
    display: flex; /* Utilise flexbox pour centrer le contenu */
    flex-direction: column; /* Contenu en colonne (spinner puis texte) */
    justify-content: center; /* Centre verticalement */
    align-items: center; /* Centre horizontalement */
    z-index: 2000; /* Assurez-vous qu'il est au-dessus de tout */
    color: var(--primary-blue);
    font-size: 1.4em;
    font-weight: 600;
    /* transition: opacity 0.3s ease; Ajout possible pour une transition douce */
}

.spinner {
    border: 6px solid rgba(0, 123, 255, 0.2); /* Couleur de bordure semi-transparente */
    border-left-color: var(--primary-blue); /* Couleur de bordure du côté gauche (c'est ce qui tourne) */
    border-radius: 50%; /* Rend le spinner rond */
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite; /* Animation de rotation */
    margin-bottom: 15px; /* Espace entre le spinner et le texte */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Styles du Podium (Flat Design) --- */
.current-podium-section {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 35px;
    box-shadow: 0 6px 15px var(--shadow-base);
    text-align: center;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.current-podium-section h2 {
    color: var(--primary-blue);
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 2.5em;
    font-weight: 700;
}

.podium-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.podium-list li {
    font-size: 1.3em;
    padding: 18px 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    box-shadow: 0 4px 10px var(--shadow-base);
    transition: all 0.2s ease-in-out;
    position: relative;
    overflow: hidden;
    color: white;
}

.podium-list li:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 15px var(--shadow-hover);
}

/* Styles pour les médailles avec émojis stylisés */
.podium-list li::before {
    font-size: 2.5em;
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.podium-list li.gold {
    background: #FFD700;
    color: var(--text-color);
}
.podium-list li.gold::before { content: '🥇'; }

.podium-list li.silver {
    background: #C0C0C0;
    color: var(--text-color);
}
.podium-list li.silver::before { content: '🥈'; }

.podium-list li.bronze {
    background: #CD7F32;
    color: white;
}
.podium-list li.bronze::before { content: '🥉'; }

.podium-list li .player-name {
    flex-grow: 1;
    text-align: left;
    margin-left: 60px;
    color: inherit;
}

.podium-list li .player-score {
    text-align: right;
    margin-left: 15px;
    color: inherit;
    font-size: 1.2em;
    opacity: 0.9;
}


.full-scores-button {
    background: var(--secondary-green);
    margin-top: 25px;
    padding: 14px 30px;
    font-size: 1.1em;
    border-radius: 10px;
}

.full-scores-button:hover {
    background: var(--secondary-green-dark);
}

/* --- Liste complète des scores (dans l'onglet Scores) --- */
.scores-full-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.scores-full-list li {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 15px 25px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px var(--shadow-base);
    transition: all 0.15s ease-in-out;
    border: 1px solid var(--border-light);
}

.scores-full-list li:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 10px var(--shadow-hover);
}

.scores-full-list li strong {
    color: var(--text-color);
    font-weight: 600;
    font-size: 1.05em;
}
.scores-full-list li span {
    color: var(--primary-blue);
    font-weight: 600;
    font-size: 1.05em;
}

/* --- Liste historique du podium --- */
.podium-history-list {
    list-style: none;
    padding: 0;
    margin-top: 20px;
}

.history-item {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 20px 25px;
    margin-bottom: 25px;
    box-shadow: 0 4px 10px var(--shadow-base);
    transition: all 0.2s ease-in-out;
    border: 1px solid var(--border-light);
}

.history-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px var(--shadow-hover);
}

.history-item h3 {
    text-align: center;
    font-size: 1.8em;
    color: var(--text-color);
    margin-top: 0;
    margin-bottom: 15px;
}

.podium-history-list li {
    font-size: 1em;
    padding: 10px 20px;
    margin-bottom: 8px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    background-color: #f8f9fa;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e3e6;
}

.podium-history-list li::before {
    font-size: 1.8em;
    margin-right: 12px;
    text-shadow: 0.5px 0.5px 1px rgba(0,0,0,0.2);
}

/* Couleurs spécifiques pour l'historique */
.podium-history-list li.gold { background: rgba(255, 215, 0, 0.1); }
.podium-history-list li.gold::before { content: '🥇'; }

.podium-history-list li.silver { background: rgba(192, 192, 192, 0.1); }
.podium-history-list li.silver::before { content: '🥈'; }

.podium-history-list li.bronze { background: rgba(205, 127, 50, 0.1); }
.podium-history-list li.bronze::before { content: '🥉'; }


/* --- Messages d'info/erreur --- */
.loading-message, .info-message, .error-message {
    text-align: center;
    padding: 18px;
    border-radius: 10px;
    margin-top: 25px;
    font-weight: 600;
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 8px var(--shadow-base);
}

.loading-message {
    color: var(--primary-blue);
    background-color: #e6f2ff;
}

.info-message {
    color: var(--light-text-color);
    background-color: #f8f9fa;
}

.error-message {
    color: var(--red-alert);
    background-color: #ffe6e6;
    border-color: var(--red-alert);
}

/* --- Styles de la Popup de validation personnalisée --- */
.alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.alert-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.alert-box {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    text-align: center;
    max-width: 400px;
    width: 90%;
    position: relative;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.alert-overlay.visible .alert-box {
    transform: translateY(0);
    opacity: 1;
}

.close-alert {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.8em;
    color: var(--light-text-color);
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-alert:hover {
    color: var(--text-color);
}

.alert-icon {
    font-size: 4em;
    margin-bottom: 15px;
    line-height: 1;
    animation: bounceIn 0.8s forwards;
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}


.alert-box h3 {
    color: var(--primary-blue);
    font-size: 1.8em;
    margin-bottom: 10px;
}

.alert-box p {
    font-size: 1.1em;
    color: var(--text-color);
    margin-bottom: 25px;
}

.alert-button {
    background-color: var(--secondary-green);
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.05em;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 4px 10px var(--shadow-base);
}

.alert-button:hover {
    background-color: var(--secondary-green-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px var(--shadow-hover);
}


/* --- Responsive Design --- */
@media (max-width: 768px) {
    body {
        padding: 15px; /* Réduire le padding du body */
    }
    .container {
        padding: 20px; /* Réduire le padding du conteneur principal */
        border-radius: 10px;
    }
    h1 {
        font-size: 2.2em; /* Réduire légèrement la taille du titre */
    }
    h2 {
        font-size: 1.8em; /* Réduire la taille des sous-titres */
    }
    .app-logo {
        max-width: 130px; /* Réduire la taille du logo */
    }
    .tabs {
        flex-wrap: wrap;
        gap: 8px; /* Réduire l'espace entre les boutons d'onglet */
    }
    .tab-button {
        padding: 10px 18px; /* Réduire le padding des boutons d'onglet */
        font-size: 0.95em; /* Réduire la taille de la police */
        border-radius: 6px;
    }
    .task-item, .scores-full-list li, .history-item, .podium-list li {
        padding: 12px 18px; /* Réduire le padding des éléments de liste */
        border-radius: 8px;
    }
    .task-item h3 {
        font-size: 1.1em; /* Réduire la taille du titre de la tâche */
    }
    .task-item p {
        font-size: 0.9em; /* Réduire la taille du texte de la tâche */
    }
    .task-score {
        font-size: 1em; /* Réduire la taille du score */
    }
    .podium-list li {
        max-width: 98%; /* Utiliser plus de largeur disponible */
        font-size: 1.1em; /* Réduire la taille de la police du podium */
        padding-left: 45px; /* Ajuster le padding pour l'icône */
    }
    .podium-list li::before {
        font-size: 2em; /* Réduire la taille de l'icône de médaille */
        left: 10px; /* Ajuster la position de l'icône */
    }
    .podium-list li .player-name {
        margin-left: 35px;
    }
    .name-input-wrapper {
        padding: 20px 25px; /* Ajuster le padding pour le mobile */
        max-width: 350px; /* Réduire la largeur max */
    }
    .assignee-name-input {
        width: 95%; /* Utiliser plus de largeur pour l'input */
    }
    .alert-box {
        padding: 20px;
        border-radius: 10px;
    }
    .alert-icon {
        font-size: 3em;
    }
    .alert-box h3 {
        font-size: 1.5em;
    }
    .alert-box p {
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px; /* Encore moins de padding pour les très petits écrans */
    }
    .container {
        padding: 15px; /* Encore moins de padding */
        border-radius: 8px;
    }
    h1 {
        font-size: 1.8em;
    }
    h1::after {
        width: 70px; /* Réduire la ligne sous le titre */
        height: 4px;
    }
    h2 {
        font-size: 1.6em;
        margin-bottom: 20px; /* Ajuster les marges */
    }
    h2::after {
        width: 40px;
        height: 2px;
    }
    .app-logo {
        max-width: 100px;
        margin-bottom: 30px;
    }
    .tabs {
        flex-direction: column; /* Les onglets en colonne */
        gap: 8px;
        margin-bottom: 25px;
    }
    .tab-button {
        width: 100%; /* Les boutons d'onglet prennent toute la largeur */
        padding: 10px 15px;
        font-size: 0.9em;
    }
    .task-item {
        padding: 10px 15px; /* Plus compact */
        margin-bottom: 8px;
    }
    .task-item h3 {
        font-size: 1em; /* Très compact */
        margin-bottom: 5px;
    }
    .task-item p {
        font-size: 0.85em; /* Très compact */
        margin-bottom: 4px;
    }
    .task-score {
        font-size: 0.9em;
        margin-top: 3px;
    }
    .flat-button {
        padding: 10px 18px; /* Réduire la taille des boutons */
        font-size: 0.95em;
    }
    .podium-list li {
        font-size: 1em;
        padding: 10px 15px;
        padding-left: 40px;
    }
    .podium-list li::before {
        font-size: 1.8em;
        left: 8px;
    }
    .podium-list li .player-name {
        margin-left: 30px;
    }
    .name-input-wrapper {
        padding: 18px 20px;
        max-width: 95%; /* Presque toute la largeur sur mobile */
    }
    .assignee-name-input {
        padding: 10px 12px;
        font-size: 0.9em;
    }
    .submit-assignee-name, .cancel-button {
        padding: 8px 15px;
        font-size: 0.9em;
    }
    .input-buttons {
        flex-direction: column; /* Boutons en colonne sur très petit écran */
        gap: 8px;
        width: 100%;
        align-items: center;
    }
    .input-buttons .flat-button {
        width: 80%; /* Occuper plus de place */
    }
    .alert-box {
        padding: 15px;
    }
    .alert-icon {
        font-size: 2.5em;
    }
    .alert-box h3 {
        font-size: 1.2em;
    }
    .alert-box p {
        font-size: 0.9em;
    }
}
