/* =========================================
   VARIABLES & THEMES (La Charte Graphique)
   ========================================= */
:root {
    --bg-color: #f0f2f5;
    --container-bg: #ffffff;
    --text-color: #333333;
    --input-bg: #ffffff;
    --input-border: #cccccc;
    
    /* DA : Bleu foncé et coins arrondis */
    --btn-color: #1e3a8a; /* Bleu foncé profond */
    --btn-hover: #152c69; /* Bleu encore plus foncé au survol */
    --radius-bulle: 12px; /* L'arrondi global de l'application */
}

[data-theme="dark"] {
    --bg-color: #0f172a; /* Fond bleu nuit très sombre */
    --container-bg: #1e293b; /* Conteneurs légèrement plus clairs */
    --text-color: #f8fafc;
    --input-bg: #334155;
    --input-border: #475569;
    
    --btn-color: #2563eb; /* Bleu un peu plus vif pour ressortir sur le noir */
    --btn-hover: #1d4ed8;
    --radius-bulle: 12px;
}

/* =========================================
   BASE & RESET
   ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    align-items: stretch; 
}

/* =========================================
   MENU LATÉRAL (SIDEBAR)
   ========================================= */
.sidebar {
    width: 280px;
    background-color: var(--container-bg);
    border-right: 1px solid var(--input-border);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.sidebar h3 {
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: var(--text-color);
    opacity: 0.7;
}

.sidebar ul {
    list-style: none;
}

/* Les boutons du menu sous forme de bulles */
.sidebar ul li a {
    text-decoration: none;
    color: var(--text-color);
    background-color: var(--input-bg);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 15px;
    border-radius: var(--radius-bulle); /* Coins arrondis */
    margin-bottom: 10px;
    border: 1px solid var(--input-border);
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.sidebar ul li a:hover {
    background-color: var(--btn-color);
    color: white;
    transform: translateX(5px); /* Petit effet de glissement sympa */
}

/* Petite bulle de notification (nombre en attente) à côté d'un lien du menu */
.badge-notif {
    background-color: #ff4c4c;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 4px;
}

/* Variante bleue de .badge-notif : commentaires de support non lus (la
   rouge reste pour les annonces non lues) -- pages/support.php, demandé par
   Raf le 2026-07-10. */
.badge-notif-bleu {
    background-color: #1e88e5;
}

/* =========================================
   CONTENU PRINCIPAL
   ========================================= */
.main-content {
    flex: 1;
    padding: 20px 40px;
    display: flex;
    flex-direction: column;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--input-border);
}

.theme-toggle-inline, .logout-btn {
    background: var(--container-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    padding: 8px 15px;
    border-radius: var(--radius-bulle);
    cursor: pointer;
    font-weight: bold;
    text-decoration: none;
    font-size: 0.9rem;
}

.logout-btn {
    color: #ff4c4c;
    border-color: #ff4c4c;
    background: transparent;
}

.logout-btn:hover { background: #ff4c4c; color: white; }

/* =========================================
   SÉLECTEUR DE CYCLE (NOUVEAU)
   ========================================= */
.cycle-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    background-color: var(--container-bg);
    padding: 15px 25px;
    border-radius: var(--radius-bulle);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    margin-bottom: 25px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.cycle-selector input[type="date"] {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-color);
}

.cycle-selector button {
    background-color: var(--btn-color);
    color: white;
    border: none;
    padding: 9px 18px;
    border-radius: var(--radius-bulle);
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}

.cycle-selector button:hover { background-color: var(--btn-hover); }

/* Bouton "Exporter" (Affichage P4) à côté du sélecteur de cycle -- même
   langage visuel que .cycle-selector button (2026-07-08). */
.btn-export-p4 {
    background-color: var(--btn-color);
    color: white;
    border: none;
    padding: 9px 18px;
    border-radius: var(--radius-bulle);
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
    height: fit-content;
}
.btn-export-p4:hover { background-color: var(--btn-hover); }

/* Sélecteur "Affichage" (Par catégorie / Classique) à côté du sélecteur de
   cycle (2026-07-08). */
.select-mode-affichage {
    padding: 9px 12px;
    border-radius: var(--radius-bulle);
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-weight: bold;
    cursor: pointer;
}

/* =========================================
   CALENDRIER (Version Large & Aérée)
   ========================================= */
.calendar-grid {
    width: 100%; /* S'étend jusqu'aux bords de la zone principale */
    max-width: 1400px; /* Évite que ce soit démesuré sur un écran géant */
    margin: 0 auto;
    border-collapse: separate;
    border-spacing: 15px; /* Un peu plus d'espace entre les cases pour un effet grille moderne */
}

.calendar-grid th, .calendar-grid td {
    background-color: var(--container-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-bulle);
    padding: 18px 10px; /* Hauteur +20% (2026-07-21, demandé par Raf) pour des cases plus carrées */
    vertical-align: middle;
    text-align: center;
    width: 14.28%; /* Divise parfaitement la largeur en 7 jours */
    box-shadow: 0 2px 4px rgba(0,0,0,0.02); /* Petite ombre légère sur les cases */
}

.calendar-grid th {
    font-weight: bold;
    font-size: 1.1rem;
    padding: 15px;
    color: var(--btn-color); /* Met les lettres L, M, M en bleu foncé pour le style */
}

/* Jour de repos selon le cycle de la personne connectée (Gestion des
   cycles) -- même rouge léger que .jour-repos-cycle sur Affichage P4. */
.calendar-grid td.jour-repos-cycle {
    background-color: rgba(255, 76, 76, 0.12);
}

/* Le bouton cliquable pour chaque jour */
.date-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto; /* Maintient le bouton parfaitement centré dans sa grande case */
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    background-color: var(--btn-color);
    border-radius: 8px; /* Carré à coins arrondis */
    width: 45px;
    height: 45px;
    /* aspect-ratio + flex-shrink:0 en renfort de width/height : garantit un
       carré même si la case parente (flex .td-content) tentait de
       l'étirer/l'aplatir. Demandé par Raf le 2026-07-21 (boutons pas assez
       carrés). */
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    text-decoration: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.date-btn:hover {
    background-color: var(--btn-hover);
    transform: scale(1.05) translateY(-2px); /* Petit effet de soulèvement sympa au survol */
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Jour de repos (selon le cycle) : bouton gris et plus petit -- reste
   cliquable (avec confirmation, voir planning.php) mais incite moins au clic
   que le bleu habituel. Demandé par Raf le 2026-07-10. */
.date-btn-repos {
    width: 32px;
    height: 32px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    font-size: 0.95rem;
    background-color: #9e9e9e;
    box-shadow: none;
}

.date-btn-repos:hover {
    background-color: #888888;
}

.td-content {
    min-height: auto; 
    display: flex;
    justify-content: center;
}

/* =========================================
   PAGE DE CONNEXION (LOGIN & PREMIÈRE CONNEXION)
   ========================================= */

/* On centre tout sur la page de login */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    background-color: var(--container-bg);
    padding: 40px;
    border-radius: var(--radius-bulle); /* La nouvelle DA arrondie */
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    width: 350px;
}

.login-container h2 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--btn-color); /* Le nouveau bleu foncé */
}

.form-group {
    margin-bottom: 20px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    background-color: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    border-radius: 8px; /* Un peu moins arrondi que les bulles principales */
}

.login-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--btn-color);
    color: white;
    border: none;
    border-radius: var(--radius-bulle); /* La nouvelle DA arrondie */
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.login-btn:hover {
    background-color: var(--btn-hover);
    transform: scale(1.02);
}

/* Bouton flottant pour le changement de thème sur la page de login */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: var(--container-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    padding: 10px 18px;
    border-radius: var(--radius-bulle); /* DA arrondie */
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background-color: var(--input-bg);
    transform: translateY(-2px); /* Petit effet de soulèvement au survol */
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
}

/* =========================================
   DASHBOARD JOURNALIER (dashboard.php)
   ========================================= */

.dashboard-header {
    text-align: center;
    margin-bottom: 40px;
}

.dashboard-header h1 {
    color: #ff4c4c; /* La date en rouge/orange comme sur ton dessin */
    font-size: 2rem;
    border-bottom: 2px solid #ff4c4c;
    display: inline-block;
    padding-bottom: 5px;
}

/* Les 3 grandes sections (Présents, Absents, Congés) */
.dashboard-section {
    background-color: var(--container-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-bulle);
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.dashboard-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--input-border);
    padding-bottom: 10px;
}

/* Conteneur des bulles/cartes */
.cards-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

/* Design d'une carte (ex: 400A, Stage, Maladie) */
.patrol-card {
    background-color: var(--bg-color);
    border: 2px solid var(--btn-color); /* Bordure bleue foncée comme la DA */
    border-radius: var(--radius-bulle);
    /* Élargi le 2026-07-10 (250px -> 300px) : la mention horaire (ex: 🕐 DA)
       suivie d'une note (ex: "15h38") repassait sinon à la ligne au milieu,
       demandé par Raf. */
    width: 300px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    overflow: hidden; /* Important pour cacher le sport au début */
}

.patrol-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

.patrol-card-header {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--btn-color);
    margin-bottom: 15px;
    border-bottom: 1px dashed var(--input-border);
    padding-bottom: 8px;
}

.person-list {
    list-style-type: none;
    margin-bottom: 10px;
}

.person-list li {
    padding: 3px 0;
    font-size: 0.95rem;
}

.person-list li::before {
    content: "• ";
    color: var(--btn-color);
    font-weight: bold;
}

/* Icône 🕐 à côté de son propre nom dans Présents (dashboard) : ouvre la
   demande de variation horaire en libre-service. Demandé par Raf le
   2026-07-10. */
.horloge-variation-icone {
    cursor: pointer;
    margin-left: 5px;
    opacity: 0.7;
}

.horloge-variation-icone:hover {
    opacity: 1;
}

/* Les petites mentions PR, DA, TIR -- agrandies le 2026-07-10 (0.75rem ->
   0.85rem, padding 2px 6px -> 3px 8px) pour une meilleure lisibilité,
   remonté par Raf. */
.mention-badge {
    display: inline-block;
    font-size: 0.85rem;
    background-color: #ff9800;
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    margin-left: 5px;
    white-space: nowrap;
}

/* Petite coche verte "confirmée" après une mention horaire (dashboard),
   demandé par Raf le 2026-07-10. */
.mention-badge-confirmee {
    color: #c8ffc8;
    font-weight: bold;
}

/* La bulle "Note" libre, à part de la mention horaire -- agrandie en même
   temps que .mention-badge (2026-07-10). */
.note-badge {
    display: inline-block;
    font-size: 0.85rem;
    background-color: var(--input-border);
    color: var(--text-color);
    padding: 3px 8px;
    border-radius: 4px;
    margin-left: 5px;
    font-style: italic;
    white-space: nowrap;
}

/* Bulle "sous-libellé" (dashboard) : le type précis de congé/maladie dans
   Absents, ou la sous-catégorie (ex: SQY, Arme, GAV) dans Présents --
   remplace l'ancien affichage entre parenthèses pour plus de lisibilité
   (Raf, 2026-07-08), sur le même principe que .mention-badge / .note-badge. */
.sous-libelle-badge {
    font-size: 0.75rem;
    background-color: var(--input-border);
    color: var(--text-color);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 5px;
    font-weight: bold;
}

/* ========== SECTION SPORT (Masquée par défaut) ========== */
.sport-section {
    display: none; /* Masqué de base */
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid var(--input-border);
    background-color: var(--container-bg);
    border-radius: 8px;
    padding: 10px;
}

/* La classe qui sera ajoutée en JS lors du clic */
.patrol-card.active .sport-section {
    display: block;
    animation: fadeIn 0.3s ease;
}

.sport-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.sport-slot-btn {
    flex: 1 1 45%;
    padding: 5px;
    background-color: var(--input-bg);
    border: 1px solid var(--btn-color);
    color: var(--text-color);
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
}

.sport-slot-btn:hover {
    background-color: var(--btn-color);
    color: white;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   BULLE D'APERÇU LIBELLÉ (réutilisée hors gestion_libelles.php)
   ========================================= */
.apercu-bulle {
    display: inline-block;
    padding: 5px 15px;
    border-radius: var(--radius-bulle);
    font-weight: bold;
}

/* =========================================
   BLOC CONGÉS DU JOUR (dashboard.php)
   ========================================= */
.conges-columns {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.conges-col {
    flex: 1 1 250px;
    background-color: var(--bg-color);
    border-radius: var(--radius-bulle);
    padding: 15px;
    min-height: 60px;
}

.conges-col h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    opacity: 0.8;
}

.conge-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 8px;
    background-color: var(--container-bg);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.conge-item-validee {
    border-left: 4px solid #ffee00;
    background-color: rgba(255, 238, 0, 0.12);
}

.conge-check-valide {
    color: #4CAF50;
    font-weight: bold;
    flex-shrink: 0;
}

/* Coche admin "Valider pro" (👮📆) et emoji lecture-seule (👮) -- congé
   validé sur le logiciel pro, indépendant de la validation admin ci-dessus.
   Voir actions/conges_valider_pro_process.php. Demandé par Raf le 2026-07-10. */
.conge-valider-pro-label {
    display: flex;
    align-items: center;
    gap: 3px;
    font-weight: normal;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.9em;
}

.conge-icone-pro {
    flex-shrink: 0;
    cursor: help;
}

.conge-ordre {
    font-weight: bold;
    opacity: 0.7;
}

.conge-type {
    font-weight: bold;
    color: var(--btn-color);
}

.conge-hors-quota {
    border-left: 4px solid #ff4c4c;
    background-color: rgba(255, 76, 76, 0.1);
    opacity: 0.85;
}

.conge-badge-hors-quota {
    font-size: 0.7rem;
    background-color: #ff4c4c;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

/* Bulles ajoutées après la coche verte (dashboard, congés validés) pour voir
   d'un coup d'oeil si un congé est validé pro (bleu, même couleur que
   --btn-color) et/ou prévisionnel (orange, même couleur que le texte
   prévisionnel sur l'Affichage P4) -- demandé par Raf le 2026-07-24. Le
   groupe .conge-icones a une largeur minimale fixe pour que le nom
   (.conge-nom) commence toujours à la même position, qu'il y ait 0, 1 ou 2
   bulles avant lui (sinon les lignes n'étaient plus alignées entre elles).
   Ajusté le 2026-07-24 (2e retour de Raf) : couleur bleue au lieu de jaune,
   et texte "✅ Pro" au lieu de "Pro". */
.conge-icones {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    min-width: 160px;
}

.conge-nom {
    flex: 1 1 auto;
    text-align: left;
}

.conge-badge-pro {
    font-size: 0.7rem;
    background-color: var(--btn-color);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    flex-shrink: 0;
    white-space: nowrap;
}

.conge-badge-previsionnel {
    font-size: 0.7rem;
    background-color: #e65100;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    flex-shrink: 0;
    white-space: nowrap;
}

.conge-badge-previ {
    font-size: 0.7rem;
    background-color: #e65100;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

.conge-cancel-btn {
    width: 20px;
    height: 20px;
    line-height: 18px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background-color: #ff4c4c;
    color: white;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
}

.conge-cancel-btn:hover {
    background-color: #d63c3c;
}

/* =========================================
   GESTION CONGÉS EN BULLES (gestion_conges.php)
   Vue "plusieurs jours à la fois" : une bulle = un jour, complète le
   dashboard (qui ne montre qu'un jour) pour administrer une période entière
   d'un coup.
   ========================================= */
.conges-jours-grille {
    display: grid;
    /* Assez large pour qu'une ligne (nom, ordre, type, badge prévi, bouton -)
       tienne sans retour à la ligne même avec un nom composé (ex: Beaulieu-Denis).
       Élargi le 2026-07-10 pour la coche "Valider pro" 👮📆 ajoutée sur les
       lignes validées, demandé par Raf. */
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 15px;
}

.jour-bulle {
    background-color: var(--container-bg);
    border-radius: var(--radius-bulle);
    padding: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.jour-bulle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--input-border);
}

.jour-bulle-date {
    font-weight: bold;
}

.jour-bulle-quota {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    opacity: 0.85;
}

.jour-bulle h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.6;
    margin: 8px 0 4px;
}

/* "Demandées" mis en évidence quand il y a au moins une demande en attente ce jour-là */
.jour-bulle h4.demandees-en-attente {
    opacity: 1;
    color: #ff4c4c;
}

.jour-bulle .conge-item {
    font-size: 0.8rem;
    padding: 5px 8px;
    flex-wrap: wrap;
    gap: 6px;
}

.jour-bulle-vide {
    font-size: 0.8rem;
    opacity: 0.5;
    margin: 2px 0;
}

.conge-valider-btn,
.conge-refuser-btn {
    width: 22px;
    height: 22px;
    line-height: 20px;
    padding: 0;
    border-radius: 50%;
    border: none;
    color: white;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
}

.conge-valider-btn {
    background-color: #4CAF50;
}

.conge-valider-btn:hover {
    background-color: #3d8b40;
}

/* Variante "toute la période / ce jour seulement" pour une demande de congé
   multi-jours (voir gestion_conges.php) : même vert, mais pas circulaire
   pour laisser la place au texte. */
.conge-valider-btn-multi {
    width: auto;
    height: 22px;
    line-height: 20px;
    padding: 0 8px;
    border-radius: 11px;
    border: none;
    background-color: #4CAF50;
    color: white;
    font-weight: bold;
    font-size: 0.7rem;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
}

.conge-valider-btn-multi:hover {
    background-color: #3d8b40;
}

/* Variante "toute la période / ce jour seulement" du refus, même principe
   que .conge-valider-btn-multi. */
.conge-refuser-btn-multi {
    width: auto;
    height: 22px;
    line-height: 20px;
    padding: 0 8px;
    border-radius: 11px;
    border: none;
    background-color: #ff4c4c;
    color: white;
    font-weight: bold;
    font-size: 0.7rem;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
}

.conge-refuser-btn-multi:hover {
    background-color: #d93c3c;
}

.conge-refuser-btn {
    background-color: #ff4c4c;
}

.conge-refuser-btn:hover {
    background-color: #d63c3c;
}

.conge-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* =========================================
   PLANNING PAR PERSONNE (planning_personne.php)
   ========================================= */
.grille-personne-wrapper {
    overflow-x: auto;
    background-color: var(--container-bg);
    border-radius: var(--radius-bulle);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    padding: 10px;
}

.grille-personne {
    border-collapse: collapse;
    width: 100%;
}

.grille-personne th, .grille-personne td {
    border: 1px solid var(--input-border);
    padding: 6px 8px;
    text-align: center;
    font-size: 0.8rem;
    white-space: nowrap;
    /* Même hauteur que .cellule-demi (case coupée en diagonale) pour que
       toutes les lignes soient de la même épaisseur, avec ou sans "/". */
    height: 42px;
}

.grille-personne th {
    background-color: var(--bg-color);
    color: var(--btn-color);
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Colonne "Personne" figée au scroll horizontal */
.grille-personne .col-nom {
    position: sticky;
    left: 0;
    z-index: 3;
    background-color: var(--container-bg);
    text-align: left;
    font-weight: bold;
    white-space: nowrap;
}

.grille-personne th.col-nom {
    z-index: 4;
    background-color: var(--bg-color);
}

/* Jour de repos selon un cycle de travail (Gestion des cycles) : sur les
   lignes, le cycle de CETTE personne ; sur l'en-tête, le cycle de la
   personne connectée (voir jourEstTravaillePourCycle() / planning_personne.php). */
.grille-personne th.jour-repos-cycle,
.grille-personne td.jour-repos-cycle {
    background-color: rgba(255, 76, 76, 0.12);
}

/* Case réduite de moitié (min-width 55px -> 27px, padding horizontal
   réduit) sur un jour non travaillé : économise de la place et montre
   visuellement qu'il n'y a normalement rien ce jour-là. Demandé par Raf le
   2026-07-10. */
.grille-personne td.jour-repos-cycle {
    min-width: 27px;
    padding-left: 3px;
    padding-right: 3px;
}

.grille-personne .cellule-jour {
    min-width: 55px;
    font-weight: 600;
}

/* Petit repère "il y a une note" sur une case complète (jamais sur une case
   coupée en diagonale "/", pas assez de place) -- le texte de la note
   s'affiche au survol (title). */
.note-icone-cellule {
    cursor: help;
    font-size: 0.75em;
}

/* Petite coche verte "congé validé par l'admin" (statut='Validé'), affichée
   à côté du libellé du congé -- indépendante du surlignage jaune qui, lui,
   suit valide_pro (voir styleCelluleConge()), demandé par Raf le 2026-07-10. */
.conge-icone-validee {
    color: #2e7d32;
    font-weight: bold;
    font-size: 0.85em;
    margin-left: 2px;
}

.grille-personne .cellule-editable {
    cursor: pointer;
    transition: outline 0.15s ease;
}

/* Surlignage pendant la sélection multi-jours par glissement (voir script
   planning_personne.php, mousedown/mouseenter/mouseup sur [data-p4-cellule]),
   demandé par Raf le 2026-07-10. */
.cellule-p4-en-selection {
    outline: 2px solid var(--btn-color);
    outline-offset: -2px;
}

.grille-personne .cellule-editable:hover {
    outline: 2px solid var(--btn-color);
    outline-offset: -2px;
}

/* Cellule divisée matin / après-midi ("système du /"), aussi bien pour un
   vrai découpage demi_jour que pour une variation horaire (PR/DA) affichée
   en demi-case décorative sur une ligne 'journee' unique.
   Remplissage ET ligne de séparation viennent du MÊME gradient (--c-matin /
   --c-aprem posés en style inline par cellule) : comme la case n'est pas
   forcément carrée, un clip-path (qui suit les proportions de la boîte) et
   un gradient à angle fixe (135deg, toujours à 45°) ne tombent pas
   exactement sur la même diagonale si on les dessine séparément -- d'où le
   décalage. En les générant tous les deux via un seul gradient, ligne et
   couleurs sont toujours parfaitement alignées, quelle que soit la forme
   de la cellule. */
.grille-personne .cellule-demi {
    position: relative;
    padding: 0;
    min-width: 55px;
    height: 42px;
    background: linear-gradient(
        135deg,
        var(--c-matin, var(--container-bg)) 0%,
        var(--c-matin, var(--container-bg)) calc(50% - 1px),
        var(--input-border) calc(50% - 1px),
        var(--input-border) calc(50% + 1px),
        var(--c-aprem, var(--container-bg)) calc(50% + 1px),
        var(--c-aprem, var(--container-bg)) 100%
    );
}

/* Les triangles ne servent plus qu'au texte et aux zones de clic : le
   clip-path reste utile pour que le clic sur un vrai découpage matin/aprem
   cible la bonne moitié, mais il n'y a plus de couleur de fond dessus (elle
   vient du gradient du parent ci-dessus). */
.demi-triangle {
    position: absolute;
    inset: 0;
    display: flex;
    font-size: 0.65rem;
    font-weight: bold;
    line-height: 1.1;
    background: transparent;
}

.demi-matin {
    clip-path: polygon(0 0, 100% 0, 0 100%);
    align-items: flex-start;
    justify-content: flex-start;
    padding: 2px 0 0 3px;
}

.demi-apresmidi {
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0 3px 2px 0;
}

.ligne-groupe-grade td {
    background-color: var(--bg-color);
    color: var(--btn-color);
    font-weight: bold;
    text-align: left;
    position: sticky;
    left: 0;
}

.conges-col-demander {
    flex: 0 0 70px;
    display: flex;
    border: 2px dashed #ff9800;
    border-radius: var(--radius-bulle);
    background: transparent;
    overflow: hidden;
}

.conge-demander-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    margin: 0;
    padding: 0;
    font-size: 2rem;
    line-height: 1;
    font-weight: bold;
    color: #ff9800;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.conge-demander-btn:hover {
    background-color: rgba(255, 152, 0, 0.15);
}

/* Champ d'édition de l'ordre (admin uniquement) */
.conge-ordre-input {
    width: 45px;
    text-align: center;
    font-weight: bold;
    background-color: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    border-radius: 5px;
    padding: 2px 4px;
}

/* =========================================
   BLOC SPORT DU JOUR (autonome, dashboard.php)
   ========================================= */
.sport-slots-standalone {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sport-slots-standalone .sport-slot-btn {
    flex: 1 1 20%;
    min-width: 120px;
    padding: 12px 8px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.sport-slot-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sport-slot-inscrit {
    background-color: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

/* Nom de l'utilisateur connecté, dans toutes les listes du dashboard */
.me {
    font-weight: 800;
    text-decoration: underline;
}

/* =========================================
   CRÉNEAUX SPORT DÉROULANTS (<details>)
   ========================================= */
.sport-slot-details {
    flex: 1 1 22%;
    min-width: 160px;
    background-color: var(--input-bg);
    border: 1px solid var(--btn-color);
    border-radius: 8px;
    padding: 8px 10px;
}

.sport-slot-details summary {
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    list-style: none;
}

.sport-slot-details summary::-webkit-details-marker { display: none; }

.sport-slot-details .person-list {
    margin: 10px 0;
    font-size: 0.85rem;
}

.sport-slot-details .sport-join-btn {
    width: 100%;
    padding: 6px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    background-color: var(--btn-color);
    color: white;
}

.sport-slot-details .sport-join-btn.inscrit {
    background-color: #ff4c4c;
}

.sport-slot-details .sport-join-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* =========================================
   MODALES (édition libellé, demande de congé...)
   ========================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.open { display: flex; }

.modal-box {
    background-color: var(--container-bg);
    padding: 25px;
    border-radius: var(--radius-bulle);
    width: 420px;
    max-width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal-box h3 {
    margin-bottom: 18px;
    color: var(--btn-color);
}

.modal-box .form-row > div { margin-bottom: 14px; }

/* Petit choix "Assignation ou Congé ?" au clic sur une case vide de
   l'affichage P4 (voir #modal-choix-type, planning_personne.php). Deux
   grandes options en carte plutôt que deux boutons texte, plus lisible et
   plus agréable à cliquer -- amélioré le 2026-07-10 suite au retour de Raf. */
.choix-type-box {
    width: 340px;
    text-align: center;
}

.choix-type-titre {
    font-size: 1.05rem;
}

.choix-type-options {
    display: flex;
    gap: 12px;
    margin-top: 5px;
}

.choix-type-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 10px;
    border-radius: var(--radius-bulle);
    border: 2px solid var(--input-border);
    background-color: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.choix-type-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

.choix-type-btn-assignation:hover {
    border-color: var(--btn-color);
}

.choix-type-btn-conge:hover {
    border-color: #2e7d32;
}

.choix-type-icone {
    font-size: 1.8rem;
}

.choix-type-label {
    font-weight: bold;
    font-size: 0.9rem;
}

.modal-box label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.85rem;
    opacity: 0.8;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

.modal-actions button, .modal-actions .btn-cancel {
    padding: 9px 18px;
    border-radius: var(--radius-bulle);
    border: none;
    cursor: pointer;
    font-weight: bold;
}

.modal-actions .btn-cancel {
    background: transparent;
    border: 1px solid var(--input-border);
    color: var(--text-color);
}

.modal-actions .btn-confirm {
    background-color: var(--btn-color);
    color: white;
}

.modal-actions .btn-delete-modal {
    background-color: #ff4c4c;
    color: white;
}

.modal-actions .btn-delete-modal:hover {
    background-color: #d63c3c;
}

/* =========================================
   CLOCHE DE NOTIFICATIONS (à côté de "Appli P4")
   ========================================= */
.titre-sidebar-cloche {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 20px;
    position: relative;
}

.titre-sidebar-cloche h2 {
    margin-bottom: 0;
}

.bouton-cloche-notif {
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 4px;
    border-radius: 50%;
}

.bouton-cloche-notif:hover {
    background-color: var(--input-bg);
}

/* Réutilise .badge-notif (rond rouge, voir plus haut) positionné en bas à
   droite de la cloche, comme demandé par Raf le 2026-07-30. */
.bouton-cloche-notif .badge-notif {
    position: absolute;
    bottom: -2px;
    right: -4px;
    font-size: 0.65rem;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
}

.dropdown-notifications {
    display: none;
    position: absolute;
    top: 100%;
    /* Centrée sur la cloche, la liste débordait à moitié hors de l'écran
       (sidebar de 280px, liste de 320px). Décalée pour que son MILIEU tombe
       pile sur le trait de séparation sidebar/contenu (280px) au lieu du
       milieu de la sidebar -- demandé par Raf le 2026-07-30. -180px = calcul
       fixe pour une sidebar de 280px (padding 20px) + une liste de 320px ;
       à recalculer si l'une de ces deux largeurs change. */
    right: -180px;
    width: 320px;
    max-width: 90vw;
    background-color: var(--container-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-bulle);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 1000;
    margin-top: 8px;
}

.dropdown-notifications.open {
    display: block;
}

.dropdown-notifications-liste {
    max-height: 360px;
    overflow-y: auto;
    padding: 8px;
}

.dropdown-notifications-vide {
    padding: 16px;
    text-align: center;
    opacity: 0.6;
    font-size: 0.9rem;
}

.item-notification {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-decoration: none;
    color: var(--text-color);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 4px;
}

.item-notification:hover {
    background-color: var(--input-bg);
}

.item-notification-non-lue {
    background-color: rgba(30, 58, 138, 0.08);
    font-weight: 600;
}

.item-notification-message {
    font-size: 0.85rem;
}

.item-notification-date {
    font-size: 0.7rem;
    opacity: 0.6;
}

.dropdown-notifications form {
    border-top: 1px solid var(--input-border);
    padding: 8px;
}

.btn-tout-lu {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 8px;
    background-color: var(--btn-color);
    color: white;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.85rem;
}