/* ==========================================================================
   1. Variables et Styles de Base (Root & Body)
   ========================================================================== */
   :root {
    --primary-color: #232d4b; /* Bleu foncé Septeo */
    --secondary-color: #3a3a3a; /* Texte principal */
    --accent-color: #ff6b2c; /* Orange Septeo */
    --background-light: #f5f6fa; /* Fond général très clair */
    --container-bg: #fff; /* Fond des blocs */
    --border-color: #e5e7ef; /* Gris clair */
    --success-color: #28a745;
    --error-color: #dc3545;
    --locked-color: #6c757d;    /* Gris pour les modules verrouillés */

    --font-family: 'Inter', 'Lexend', Arial, sans-serif;
    --border-radius: 10px;
    --box-shadow: 0 4px 12px rgba(35, 45, 75, 0.06);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-light);
    color: var(--secondary-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}


/* ==========================================================================
   2. Typographie
   ========================================================================== */
h1, h2, h3, h4 {
    line-height: 1.3;
    margin-bottom: 0.75em;
    font-weight: 600;
    color: var(--primary-color);
    font-family: 'Lexend', 'Inter', Arial, sans-serif;
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; color: var(--primary-color); }
h3 { font-size: 1.25rem; }
p { margin-bottom: 1rem; }
a { color: var(--primary-color); text-decoration: none; }
a:hover { text-decoration: underline; }


/* ==========================================================================
   3. Composants et Utilitaires
   ========================================================================== */
button, input[type="submit"] {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    background-color: var(--accent-color);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    text-align: center;
    box-shadow: 0 2px 8px rgba(255, 107, 44, 0.08);
}

button:hover, input[type="submit"]:hover {
    background-color: #e55a1c;
    transform: translateY(-2px);
}

.cta-button {
    background-color: var(--accent-color);
}
.cta-button:hover {
    background-color: #d35400;
}

input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="email"], textarea, select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    margin-bottom: 1rem;
    background: #fff;
    color: var(--primary-color);
    transition: border 0.2s;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent-color);
    outline: none;
}

.feedback {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--border-radius);
    font-weight: 500;
}
.feedback.success {
    background-color: #e9fde9;
    border-left: 5px solid var(--success-color);
    color: var(--success-color);
}
.feedback.error {
    background-color: #fde9e9;
    border-left: 5px solid var(--error-color);
    color: var(--error-color);
}


/* ==========================================================================
   4. Styles des Pages Spécifiques
   ========================================================================== */

/* --- Page de Connexion (index.php) --- */
.login-container {
    max-width: 450px;
    margin: auto;
    padding: 2.5rem;
    background: var(--container-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    text-align: center;
}
.login-container h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}
.login-container p {
    color: #6c757d;
    margin-bottom: 1.5rem;
}
.login-container form input {
    text-align: center;
}
.error-message {
    color: var(--error-color);
    margin-top: 1rem;
    font-weight: 500;
}

/* --- Tableaux de Bord (Manager & Participant) --- */
header {
    width: 100%;
    background: var(--primary-color);
    padding: 1.5rem;
    color: white;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
header h1 {
    margin: 0;
    font-size: 1.5rem;
}

main.manager-dashboard, main.participant-dashboard {
    width: 100%;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

main section {
    background: var(--container-bg);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 2rem;
}

/* --- Tableau de bord Manager --- */
#participant-creator form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}
#participant-creator form input {
    flex-grow: 1;
    margin-bottom: 0;
}
#participant-creator form button {
    flex-shrink: 0;
}
#new-code-display {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #e9f5ff;
    border: 1px solid #b3d7ff;
    border-radius: var(--border-radius);
    font-weight: bold;
    text-align: center;
}

#participant-list table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}
#participant-list th, #participant-list td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}
#participant-list thead tr {
    background-color: #f8f9fa;
}
#participant-list tbody tr:hover {
    background-color: #f1f3f5;
}

/* --- Tableau de bord Participant --- */
.progress-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 1rem;
}
.module-box {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: 600;
    transition: all 0.2s ease;
    background: var(--container-bg);
}
.module-box .module-id {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}
.module-box .module-status {
    font-size: 0.8rem;
    text-transform: uppercase;
}
.module-box.locked {
    background-color: #e9ecef;
    color: var(--locked-color);
    border-color: #ced4da;
}
.module-box.completed {
    background-color: #e9fde9;
    color: var(--success-color);
    border-color: var(--success-color);
}
.module-box.current {
    background-color: #e9f5ff;
    color: var(--primary-color);
    border-color: var(--primary-color);
    border-width: 2px;
    transform: scale(1.05);
}

main.participant-dashboard .cta-button {
    display: block;
    width: fit-content;
    margin: 2rem auto 0;
}

/* --- Lecteur de Module (player.php) --- */
body.player-body {
    background-color: #e9ecef;
}
.player-container {
    max-width: 900px;
    width: 100%;
    margin: 2rem auto;
    background: var(--container-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
}
.player-header {
    padding: 1rem 1.5rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
}
.player-header h3 {
    color: #6c757d;
    font-size: 0.9rem;
    margin: 0;
}
.player-header h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin: 0;
}

.module-content {
    padding: 2rem;
}
.activity-container {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}
.activity-container hr {
    margin-bottom: 2rem;
}

.player-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
}
#next-module {
    background-color: var(--success-color);
}
#next-module:hover {
    background-color: #218838;
}


/* ==========================================================================
   5. Design Responsive
   ========================================================================== */
@media (max-width: 768px) {
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.5rem; }

    .login-container {
        width: 90%;
        padding: 1.5rem;
    }

    #participant-creator form {
        flex-direction: column;
    }
    #participant-creator form input, #participant-creator form button {
        width: 100%;
    }

    /* Rend le tableau scrollable horizontalement sur petits écrans */
    #participant-list {
        overflow-x: auto;
    }
    
    .player-container {
        margin: 1rem auto;
        border-radius: 0;
        box-shadow: none;
    }
    
    .module-content {
        padding: 1.5rem;
    }
}

/* ==========================================================================
   6. Styles pour les améliorations du Dashboard Manager
   ========================================================================== */

/* --- Styles pour le tri des colonnes --- */
thead th[data-sort] {
    cursor: pointer;
    position: relative;
    user-select: none;
}
thead th[data-sort] span {
    display: inline-block;
    width: 16px;
    height: 16px;
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
}
thead th[data-sort].sorted-asc span::after {
    content: '▲';
    font-size: 10px;
}
thead th[data-sort].sorted-desc span::after {
    content: '▼';
    font-size: 10px;
}

/* --- Styles pour les contrôles de filtre --- */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.filter-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

/* --- Styles pour la modale de détails --- */
.modal {
    display: none; /* Cachée par défaut */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6); /* Fond noir semi-transparent */
    animation: fadeIn 0.3s;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 2rem;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    animation: slideIn 0.3s;
}
@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 28px;
    font-weight: bold;
}
.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#modal-body ul {
    list-style-type: none;
    padding: 0;
}
#modal-body li {
    padding: 8px;
    border-bottom: 1px solid #eee;
}
#modal-body li:last-child {
    border-bottom: none;
}
.table-wrapper {
    overflow-x: auto;
}

/* --- Styles pour le bouton d'archivage --- */
.archive-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: #a0a0a0;
    padding: 5px;
    transition: color 0.2s, transform 0.2s;
}
.archive-btn:hover {
    color: var(--error-color);
    transform: scale(1.2);
}

/* ==========================================================================
   7. Styles pour les contrôles de formulaire modernes (Radio & Checkbox)
   ========================================================================== */

/* --- Conteneur commun pour les deux types --- */
.custom-control {
    display: block;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 1rem;
    user-select: none;
    line-height: 25px; /* Aligne le texte avec le bouton personnalisé */
}

/* On masque l'input d'origine */
.custom-control input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* --- Style pour la fausse checkbox (le "checkmark") --- */
.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 25px;
    width: 25px;
    background-color: #eee;
    border: 1px solid #ccc;
    border-radius: 5px;
    transition: background-color 0.2s;
}

/* Au survol, on change légèrement le fond */
.custom-control:hover input ~ .checkmark {
    background-color: #ccc;
}

/* Quand la checkbox est cochée, on change le fond en bleu */
.custom-control input:checked ~ .checkmark {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

/* On crée le "V" de validation (initialement masqué) */
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

/* On affiche le "V" quand la checkbox est cochée */
.custom-control input:checked ~ .checkmark:after {
    display: block;
}

/* On dessine le "V" avec des bordures */
.custom-control .checkmark:after {
    left: 9px;
    top: 5px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

/* --- Style pour le faux bouton radio (le "radiomark") --- */
.radiomark {
    position: absolute;
    top: 0;
    left: 0;
    height: 25px;
    width: 25px;
    background-color: #eee;
    border: 1px solid #ccc;
    border-radius: 50%; /* La seule différence majeure : c'est un cercle */
    transition: background-color 0.2s;
}

.custom-control:hover input ~ .radiomark {
    background-color: #ccc;
}

.custom-control input:checked ~ .radiomark {
    background-color: #fff;
    border-color: var(--primary-color);
}

.radiomark:after {
    content: "";
    position: absolute;
    display: none;
}

.custom-control input:checked ~ .radiomark:after {
    display: block;
}

/* On dessine le point central du bouton radio */
.custom-control .radiomark:after {
    top: 5px;
    left: 5px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--primary-color);
}

.main-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 70vh;
    padding: 0 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.side-container {
    flex: 1;
    padding: 2rem;
    background-color: #f5f5f5;
    border-radius: 8px;
    margin: 0 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.left-container {
    text-align: right;
}

.right-container {
    text-align: left;
}

.login-container {
    flex: 2;
    max-width: 400px;
    margin: 0 2rem;
}

footer.site-footer {
    background: var(--primary-color);
    color: #fff;
    border-top: none;
}
.footer-content, .footer-info, .footer-message, .footer-copyright {
    color: #fff;
}
.footer-contact {
    color: #ff6b2c;
}
.footer-contact:hover {
    color: #fff;
    text-decoration: underline;
}

/* Séparateurs, bordures, etc. */
hr, .footer-separator {
    border-color: var(--border-color);
    background: var(--border-color);
}