/* style.css */

/* Styles de base et mise en page */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    background-color: #f4f4f4;
}
header {
    background-color: #333;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
header .site-name h1 {
    margin: 0;
    font-size: 1.5rem;
}
/* Ciblage du lien d'authentification */
.auth-area a { 
    padding: 0.5rem 1rem;
    background-color: #555;
    color: white;
    border: none;
    cursor: pointer;
    text-decoration: none; 
    display: inline-block;
    margin-left: 10px;
}
/* Le bouton sombre est maintenant dans la nav, j'ai retiré son style d'ici. */

nav {
    background-color: #444;
    position: relative;
    padding: 0 1.5rem;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    /* FIX: Empilement du menu au-dessus du reste du contenu */
    z-index: 1000;
}
.menu-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
}
.main-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex; /* Aligne les éléments horizontalement sur desktop */
    /* Assure que la liste est au même niveau */
    height: 100%;
}
.main-menu li {
    position: relative;
}
.main-menu a {
    display: block;
    padding: 15px 20px;
    text-decoration: none;
    color: white;
    transition: background-color 0.3s;
}

.main-menu a:hover {
    background-color: #555;
}

.submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #555;
	
	min-width: 200px;
    
    /* Z-index pour s'assurer qu'il est au-dessus du contenu */
    z-index: 1000;
	
    list-style: none;
    padding: 0;
    margin: 0;
    border-top: 2px solid #333; /* Séparateur */
}

.dropdown:hover > .submenu {
    display: block;
}

/* RÈGLES DES SOUS-SOUS-MENUS DESKTOP */
.submenu li {
    width: 100%;
}
.submenu .submenu {
    top: 0;
    left: 100%;
    z-index: 1002;
}
.submenu li:hover > .submenu {
    display: block;
}

.submenu a {
    padding: 10px 20px;
    background-color: #555; /* Assure la continuité de la couleur */
}

.submenu a:hover {
    background-color: #666; /* Effet de survol sur les sous-liens */
}

/* Styles du menu hamburger */
.hamburger-menu {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    position: absolute;
    top: 50%;
    right: 1.5rem;
    transform: translateY(-50%);
    z-index: 2;
}
.hamburger-menu .bar {
    width: 25px;
    height: 3px;
    background-color: white;
    margin: 5px 0;
    transition: 0.4s;
}

/* ------------------------------------- */
/* STYLES DES MODALES (AJOUTÉS) */
/* ------------------------------------- */
.modal-dialog {
    display: none; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5); 
    justify-content: center; 
    align-items: center;
    z-index: 1000;
}

.modal-dialog.active {
    display: flex; 
}

.modal-content {
    padding: 2rem;
    border-radius: 5px;
    position: relative;
    background-image: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('images/background_keyboard.jpg');
    background-size: cover;
    background-position: center;
    color: white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    max-width: 450px; 
    width: 90%;
    overflow-x: hidden;
}

.modal-content h2 {
    color: white;
    text-shadow: 1px 1px 2px #333;
}
.modal-content .close-button {
    color: #fff;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background-color: rgba(0,0,0,0.4);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    transition: background-color 0.3s;
}
.modal-content .close-button:hover,
.modal-content .close-button:focus {
    background-color: rgba(0,0,0,0.7);
    color: #fff;
    text-decoration: none;
}


/* STYLES DES ONGLETS DE LA MODALE DE CONNEXION */
.tab-controls {
    display: flex;
    justify-content: space-around;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3); 
    overflow-x: auto;
    white-space: nowrap;
}
.tab-button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 0.75rem 0.5rem;
    cursor: pointer;
    font-weight: bold;
    transition: color 0.3s, border-bottom 0.3s;
    flex-shrink: 0;
    font-size: 0.9rem; 
}
.tab-button:hover {
    color: white;
}
.tab-button.active {
    color: white;
    border-bottom: 3px solid #ff9900; 
}

/* Styles pour les formulaires internes */
.modal-form {
    display: none; 
    flex-direction: column;
    gap: 1rem;
}
.modal-form.active {
    display: flex; 
}
.modal-form input[type="text"],
.modal-form input[type="email"],
.modal-form input[type="password"] {
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box; 
    color: #333; 
}
.modal-form button[type="submit"] {
    padding: 0.75rem;
    background-color: #ff9900; 
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 0.5rem;
}
.modal-form button[type="submit"]:hover {
    background-color: #e68a00;
}

/* Style spécifique pour le CAPTCHA */
.captcha-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background-color: rgba(0,0,0,0.3);
    padding: 0.75rem;
    border-radius: 4px;
}
.captcha-group label {
    font-weight: bold;
}
.modal-form p {
    font-size: 0.9em;
}


/* Styles de la modale d'événement (pour uniformité) */
.event-modal-dialog {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    justify-content: center;
    align-items: center;
}
.event-modal-dialog.active {
    display: flex;
}
.event-modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    position: relative;
    border-radius: 8px;
    text-align: center;
}
.event-modal-content .close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.event-modal-content .close-button:hover,
.event-modal-content .close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}
.ok-button {
    background-color: #4CAF50;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 20px;
}
.ok-button:hover {
    background-color: #45a049;
}
/* ------------------------------------- */
/* FIN DES STYLES DES MODALES */
/* ------------------------------------- */

/* Styles pour la page principale et la barre latérale */
.main-content {
    display: flex;
    min-height: calc(100vh - 100px);
}
.sidebar {
    width: 20%;
    padding: 1.5rem;
    background-color: #eee;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}
.content-area {
    width: 80%;
    padding: 1.5rem;
    background-color: white;
}
/* Styles pour l'administration */
.admin-link {
    display: block;
    text-align: center;
    margin: 1rem 0;
}
.admin-main {
    display: flex;
    width: 100%;
}
.admin-sidebar {
    width: 30%;
}
.admin-content {
    width: 70%;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}
th {
    background-color: #f2f2f2;
}
.admin-menu {
    list-style: none;
    padding: 0;
}
.admin-menu a {
    display: block;
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: #333;
    border-left: 3px solid transparent;
}
.admin-menu a.active {
    border-left: 3px solid #333;
    font-weight: bold;
    background-color: #ddd;
}
.event-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}
.event-form input, .event-form textarea {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.event-table {
    width: 100%;
    border-collapse: collapse;
}
.event-table th, .event-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}
.event-table th {
    background-color: #f2f2f2;
}
.event-table button {
    background-color: #d9534f;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
}
.edit-link {
    background-color: #5bc0de;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 4px;
}
.message {
    padding: 1rem;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-bottom: 1rem;
}
/* Styles du calendrier */
.calendar-container {
    border: 1px solid #ccc;
    padding: 10px;
    margin-top: 15px;
    background-color: #fff;
    border-radius: 5px;
    position: relative;
}
.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9em;
}
.calendar-nav h3 {
    margin: 0;
    font-size: 1.1em;
    white-space: nowrap;
}
.calendar-nav a {
    text-decoration: none;
    color: #333;
    padding: 3px 6px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.8em;
    white-space: nowrap;
}
.calendar-nav a:hover {
    background-color: #e0e0e0;
}
.calendar-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7em;
    table-layout: fixed;
}
.calendar-table th {
    background-color: #e0e0e0;
    text-align: center;
    padding: 3px 0;
    font-size: 0.8em;
}
.calendar-table td {
    text-align: center;
    padding: 2px 0;
    border: 1px solid #eee;
    cursor: pointer;
    height: 25px;
    line-height: 20px;
    position: relative;
}
.calendar-table td.highlighted-date {
    background-color: #ffdddd;
    color: #cc0000;
    font-weight: bold;
}
.calendar-table td.today {
    border: 2px solid #555;
    font-weight: bold;
    background-color: #ffffcc;
}
.calendar-table td.today.highlighted-date {
    background-color: #ffffcc;
    color: #cc0000;
}


/* AJUSTEMENTS POUR LA RESPONSIVITÉ */
@media (max-width: 768px) {
    .hamburger-menu {
        display: block;
    }
    nav {
        padding: 10px 1.5rem;
        height: auto;
    }
    .menu-container {
        display: none;
        flex-direction: column;
        width: 100%;
        background-color: #444;
        position: absolute;
        top: 100%;
        left: 0;
        z-index: 1;
    }
    .menu-container.active {
        display: flex;
    }
    .main-menu {
        flex-direction: column;
        width: 100%;
        padding-top: 1rem;
    }
    .main-menu li {
        width: 100%;
    }
    .main-menu a, .main-menu button { /* Ciblage du bouton mode-toggle pour mobile */
        padding: 1rem 2rem;
    }

    /* DÉBUT DE LA LOGIQUE POUR L'ACCORDÉON MOBILE */
    .submenu {
        position: static;
        display: none;
        background-color: #555;
    }
    .dropdown.active .submenu {
        display: block;
    }
    /* FIN DE LA LOGIQUE POUR L'ACCORDÉON MOBILE */

    .main-content {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        padding: 1rem;
        order: 2;
        box-shadow: none;
    }
    .content-area {
        width: 100%;
        padding: 1.5rem;
        order: 1;
    }
    .calendar-table {
        font-size: 0.8em;
    }
    .calendar-table td {
        padding: 5px 0;
        height: auto;
    }
    #calendar-wrapper {
        order: 2;
    }
    #sidebar-content {
        order: 1;
    }
    .admin-main {
        flex-direction: column;
    }
    .admin-sidebar, .admin-content {
        width: 100%;
    }
}
@media (max-width: 480px) {
    /* Réajustement des onglets sur très petit écran */
    .tab-controls {
        flex-wrap: wrap; 
        justify-content: center;
    }
    .tab-button {
        width: 45%; 
        margin: 5px 2%;
        padding: 0.5rem 0.25rem;
        font-size: 0.8em;
    }
}

/* --- Styles pour le pied de page --- */
footer {
    background-color: #333;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    position: relative;
    bottom: 0;
    width: 100%;
}
footer p {
    margin: 0;
    font-size: 0.9em;
}
/* Styles pour le mode sombre */
body.dark-mode footer {
    background-color: #1a1a1a;
    color: #f0f0f0;
}
/* --- Nouveaux styles pour le mode sombre --- */
body.dark-mode {
    background-color: #2c2c2c;
    color: #f0f0f0;
}
body.dark-mode header {
    background-color: #1a1a1a;
}
body.dark-mode header .site-name h1 {
    color: #f0f0f0;
}
/* Assurez-vous que les liens sont corrects en dark mode */
body.dark-mode .auth-area a {
    background-color: #333;
    color: #f0f0f0;
}
body.dark-mode nav {
    background-color: #222;
}
body.dark-mode .main-menu a, body.dark-mode .main-menu button {
    color: #f0f0f0;
    background-color: transparent; /* Bouton mode sombre dans la nav */
}
body.dark-mode .main-menu li:hover > a, body.dark-mode .main-menu li:hover > button {
    background-color: #333;
}
body.dark-mode .submenu {
    background-color: #333;
}
body.dark-mode .submenu li a {
    color: #f0f0f0;
}
body.dark-mode .sidebar {
    background-color: #383838;
    color: #f0f0f0;
    border: 1px solid #555;
}
body.dark-mode .content-area {
    background-color: #444;
}
/* Styles de modale en dark mode (mise à jour) */
body.dark-mode .modal-content {
    background-color: #383838;
    background-image: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('images/background_keyboard.jpg');
    color: #f0f0f0;
}
body.dark-mode .modal-form input[type="text"],
body.dark-mode .modal-form input[type="email"],
body.dark-mode .modal-form input[type="password"] {
    background-color: #555;
    color: white;
    border: 1px solid #777;
}

body.dark-mode .calendar-container {
    background-color: #383838;
    border: 1px solid #555;
}
body.dark-mode .calendar-nav a {
    color: #f0f0f0;
    border: 1px solid #555;
}
body.dark-mode .calendar-nav h3 {
    color: #f0f0f0;
}
body.dark-mode .calendar-table th {
    background-color: #555;
    color: #f0f0f0;
}
body.dark-mode .calendar-table td {
    border: 1px solid #555;
}
body.dark-mode .calendar-table td.highlighted-date {
    background-color: #442222;
    color: #ffcccc;
}
body.dark-mode .calendar-table td.today {
    border: 2px solid #888;
    background-color: #333;
}
body.dark-mode .calendar-table td.today.highlighted-date {
    background-color: #553333;
    color: #ffcccc;
}
body.dark-mode .event-modal-content {
    background-color: #383838;
}
body.dark-mode .event-modal-content .close-button {
    color: #f0f0f0;
}
body.dark-mode .event-modal-content .close-button:hover {
    color: #fff;
}
body.dark-mode .ok-button {
    background-color: #4CAF50;
    color: white;
}
body.dark-mode .ok-button:hover {
    background-color: #45a049;
}
/* Styles ajoutés pour les boutons "Modifier" et "Annuler" */
.edit-btn {
    background-color: #5cb85c;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.cancel-btn {
    background-color: #f0ad4e;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
}


/* --- Styles pour le bouton "Retour" --- */
header .back-button {
    background-color: #6c757d !important;
    color: #ffffff !important;
    padding: 0.5rem 1rem !important;
    border: 1px solid #5a6268 !important;
    border-radius: 4px !important;
    text-decoration: none !important;
    display: inline-block !important;
    /* Rétabli la marge car le bouton Sombre n'est plus ici */
    margin-right: 10px; 
}

header .back-button:hover {
    background-color: #5a6268 !important;
    color: #ffffff !important;
}

/* Adaptation Dark Mode du bouton "Retour" */
body.dark-mode header .back-button {
    background-color: #495057 !important;
    color: #f0f0f0 !important;
    border-color: #343a40 !important;
}

body.dark-mode header .back-button:hover {
    background-color: #343a40 !important;
}

/* --- DÉBUT DES CORRECTIONS DE LA LISTE DES ÉVÉNEMENTS --- */

/* 1. Cibler le titre "Liste des Événements" (supposé être un h2 dans la sidebar) */
.sidebar h2 { 
    /* Réduit l'espace au-dessus du titre (espace avec le trait) */
    margin-top: 0.5rem; 
    /* Réduit l'espace en dessous du titre (espace bizarre en mode clair) */
    margin-bottom: 0.5rem; 
    /* Diminue la taille du texte pour le forcer sur 1 ligne */
    font-size: 1.2rem; 
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis; 
}

/* 2. Correction de l'espace sous le titre et décalage de l'arborescence (mode clair) */
/* Cible le conteneur principal de la liste des événements */
.event-list-tree {
    /* Retire la marge supérieure par défaut de la <ul> */
    margin-top: 0; 
    /* Retire le padding par défaut qui décale le premier niveau (l'année) */
    padding-left: 0;
    padding-top: 0;
    list-style: none; /* Supprime les puces par défaut */
}

/* 3. Rapproche les niveaux inférieurs (Mois et Jour) en réduisant le padding */
/* Cible les <ul> internes */
.event-list-tree ul {
    /* Réduit le décalage intérieur des sous-niveaux pour gagner de l'espace */
    padding-left: 15px; 
    margin-top: 0;
}

/* 4. Assurer que le premier élément (l'année) n'a pas de marge/padding supplémentaire */
.event-list-tree > .year-item {
    margin-top: 0;
    padding-top: 0;
}

/* 5. Changer la couleur du LIEN de l'événement (le texte violet) en mode sombre */
body.dark-mode .event-list-tree a {
    /* Vert clair (#98FB98) pour la lisibilité sur fond sombre */
    color: #98FB98; 
}

/*
 * Règle pour redimensionner automatiquement les images insérées
 * par Summernote dans les événements.
 */
.event-desc-content img {
    /* Assure que l'image ne dépasse jamais 100% de la largeur du conteneur parent */
    max-width: 100%;
    /* Permet à la hauteur de s'ajuster proportionnellement à la largeur */
    height: auto;
    /* Assure que les images sont traitées comme des blocs pour l'alignement */
    display: block; 
    /* Ajout d'une petite marge pour séparer l'image du texte environnant */
    margin: 10px 0; 
}
/* --- FIN DES CORRECTIONS DE LA LISTE DES ÉVÉNEMENTS --- */