/* style.css - Theme Discord (Dark Mode) - Version Checkbox Repas & Popup Info */

:root {
    /* --- Palette Discord Officielle --- */
    --discord-bg: #313338;         /* Fond principal */
    --discord-sidebar: #2b2d31;    /* Fond des cartes */
    --discord-element: #1e1f22;    /* Fond des inputs */
    --discord-blurple: #5865F2;    /* Couleur principale */
    --discord-blurple-dark: #4752c4;
    
    --discord-green: #23a559;      /* Succès */
    --discord-red: #da373c;        /* Erreur/Manque */
    --discord-yellow: #f0b232;     /* Attention/Weekend */
    
    --text-normal: #dbdee1;        /* Texte principal (Blanc cassé) */
    --text-muted: #949ba4;         /* Texte secondaire (Gris) */
    --text-header: #f2f3f5;        /* Titres (Blanc brillant) */
    
    --border-color: #1e1f22;       /* Bordures très sombres */
    
    /* --- Formes --- */
    --radius-lg: 8px;              /* Discord utilise des coins moins ronds que le mobile */
    --radius-md: 4px;
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.2);
    --shadow-float: 0 8px 16px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'GG Sans', 'Poppins', sans-serif; /* GG Sans est la font Discord, sinon Poppins */
    background-color: var(--discord-bg);
    color: var(--text-normal);
    line-height: 1.6;
    padding-bottom: 120px;
}

/* --- Scrollbar style Discord --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background-color: var(--discord-sidebar); }
::-webkit-scrollbar-thumb { background-color: #1a1b1e; border-radius: 4px; }

/* --- Layout Principal --- */
.container {
    max-width: 1000px;
    margin: -40px auto 0;
    padding: 0 20px;
    position: relative;
    z-index: 10;
}

/* --- Header --- */
.header {
    background-color: var(--discord-element); /* En-tête sombre style barre serveur */
    padding: 60px 20px 80px;
    text-align: center;
    border-bottom: 2px solid #111214;
}

.header-content .logo {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    color: var(--discord-blurple);
}

.header h1 {
    font-weight: 800;
    color: var(--text-header);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Cartes et Sections --- */
.card, section {
    background: var(--discord-sidebar);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 20px;
    margin-bottom: 16px;
    border: none; /* Pas de bordure claire */
}

.top-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
@media (min-width: 768px) {
    .top-grid { grid-template-columns: 1fr 2fr; }
}

h2 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-bottom: none;
}
h2 i { color: var(--discord-blurple); }

.section-title {
    margin-top: 10px;
    padding-left: 0;
    border-left: none;
    color: var(--text-header);
    font-size: 1.1rem;
}

/* --- Formulaires (Inputs Sombres) --- */
.semaine-grid-header {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.form-group {
    position: relative;
    margin-bottom: 15px;
}

input[type="text"], 
input[type="number"], 
input[type="date"], 
input[type="password"], 
select, 
textarea {
    width: 100%;
    padding: 10px;
    border: none; /* Discord n'a pas de bordures sur les inputs */
    background-color: var(--discord-element);
    color: var(--text-normal);
    border-radius: 4px; /* Coins un peu plus carrés */
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    outline: none;
}

/* Focus state */
input:focus, select:focus, textarea:focus {
    background-color: var(--discord-element);
    box-shadow: 0 0 0 2px var(--discord-blurple); /* Outline bleu focus */
}

/* Label flottant adapté au fond sombre */
.floating-label label {
    position: absolute;
    top: -10px;
    left: 10px;
    background: var(--discord-sidebar); /* Doit matcher la couleur de la carte */
    padding: 0 6px;
    font-size: 0.75rem;
    color: var(--discord-blurple);
    font-weight: 600;
    border-radius: 4px;
}

/* --- Accordéon Jour --- */
.jour-section {
    background: var(--discord-sidebar);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    overflow: hidden;
    border: 1px solid #1e1f22; /* Légère séparation */
}

.toggle-header {
    padding: 12px 20px;
    background: var(--discord-sidebar);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--text-header);
    transition: background 0.2s;
}
.toggle-header:hover { background-color: rgba(79, 84, 92, 0.16); }

/* --- Badges de Statut (Couleurs Discord) --- */
.total-jour-display {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #ffffff !important; /* Texte blanc forcé pour le contraste */
}

/* Utilisation des couleurs vives Discord */
.vert { background-color: var(--discord-green); }
.rouge { background-color: var(--discord-red); }
.weekend-gold { background-color: var(--discord-yellow); color: #313338 !important; /* Texte sombre sur le jaune */ }

/* Contenu accordéon */
.ligne-chantier-content {
    background-color: #2f3136; /* Légèrement différent pour le contraste */
    border-top: 1px solid #1e1f22;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0, 1, 0, 1);
}
.ligne-chantier-content.active {
    max-height: 2000px;
    padding: 15px;
    transition: max-height 0.5s ease-in-out;
}

/* Ligne interne */
.ligne-chantier {
    background: var(--discord-bg);
    padding: 15px;
    border-radius: var(--radius-lg);
    border: none;
    margin-bottom: 15px;
    position: relative; /* Pour positionner le bouton trash */
}

/* --- NOUVEAU STYLE DE GRILLE DE LIGNE (Fusion des deux champs chantier) --- */
.ligne-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}
/* Grande taille : 4 colonnes (Site, Bâtiment, Chantier, Heures+Frais) */
@media (min-width: 992px) {
    .ligne-grid { grid-template-columns: 1.5fr 1fr 2fr 1fr; }
}
/* Le champ Chantier/Projet et Description prennent la largeur de la grille */
.chantier-full { 
    grid-column: 1 / -1; 
}
/* Le champ Description prend toujours toute la largeur pour être lisible */
.desc-full { 
    grid-column: 1 / -1; 
}

/* --- Groupe Heures et Bouton Frais --- */
.heures-frais-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.input-heures {
    flex-grow: 1; 
    font-weight: bold;
    color: var(--discord-blurple) !important;
    text-align: center;
}

/* Bouton qui active la section frais */
.btn-toggle-frais {
    background-color: var(--discord-element);
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0; /* Ne doit pas rétrécir */
}

.btn-toggle-frais:hover {
    background-color: rgba(88, 101, 242, 0.1);
    color: var(--discord-blurple);
}

/* État Actif/Saisi pour le bouton frais */
.btn-toggle-frais.frais-active {
    background-color: var(--discord-yellow);
    color: var(--discord-element); /* Texte sombre sur le jaune */
}

/* --- Bouton "Ajouter ligne" --- */
.btn-ajouter-ligne {
    background: transparent;
    border: 1px dashed var(--text-muted);
    color: var(--text-muted);
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}
.btn-ajouter-ligne:hover {
    border-color: var(--discord-blurple);
    color: var(--discord-blurple);
    background: rgba(88, 101, 242, 0.1);
}

/* --- Footer Fixe --- */
#totalSemaineConteneur {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 800px;
    background: #111214; /* Très sombre, presque noir */
    padding: 15px 30px;
    border-radius: 8px;
    box-shadow: var(--shadow-float);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #1e1f22;
    z-index: 100;
}

.label-total {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
}
.total-semaine-display {
    font-size: 1.8rem;
    color: var(--discord-green); /* Le total général en vert Discord */
    margin: 0;
    line-height: 1;
}
.total-semaine-display small {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 400;
}

.actions-wrapper {
    display: flex;
    gap: 10px;
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border-radius: 4px; /* Boutons plus carrés comme Discord */
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: var(--discord-blurple);
    color: white;
}
.btn-primary:hover {
    background-color: var(--discord-blurple-dark);
}

.btn-secondary {
    background-color: #4f545c;
    color: white;
}
.btn-secondary:hover {
    background-color: #686d73;
}

/* Responsive */
@media (max-width: 600px) {
    #totalSemaineConteneur {
        flex-direction: column;
        gap: 15px;
        bottom: 0;
        width: 100%;
        border-radius: 10px 10px 0 0;
        max-width: 100%;
        padding: 20px;
    }
    .actions-wrapper { width: 100%; }
    .btn-primary, .btn-secondary { flex: 1; justify-content: center; }
}

/* ========================================================= */
/* BOUTONS DU HEADER — STYLE PREMIUM (Non modifiés)          */
/* ========================================================= */

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}
/* Style commun */
.btn-header {
    width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,0.04); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; color: var(--text-header); font-size: 1.1rem; border: 1px solid rgba(255,255,255,0.06); transition: 0.25s ease; cursor: pointer;
}
/* Hover premium */
.btn-header:hover {
    background: rgba(88,101,242,0.15); border-color: var(--discord-blurple); color: var(--discord-blurple); transform: translateY(-2px); box-shadow: 0 0 12px rgba(88,101,242,0.5);
}
/* Icon Matériaux */
.btn-materials i { color: var(--discord-blurple); }
/* Icon Déconnexion */
.btn-logout-center i { color: var(--discord-red); }
.btn-logout-center:hover {
    background: rgba(218,55,60,0.15); border-color: var(--discord-red); box-shadow: 0 0 12px rgba(218,55,60,0.5); color: var(--discord-red);
}

/* Boutons centrés sous le logo */
.header-buttons-centered {
    margin-top: 18px; display: flex; justify-content: center; gap: 14px;
}
.page-chantiers-title {
    font-size: 1.3rem; text-align: center; color: var(--text-header); margin-bottom: 20px;
}
/* === POPUP GENERIC STYLES === */
.popup-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.65); display: none; justify-content: center; align-items: center; z-index: 999; opacity: 0; transition: opacity 0.3s;
}
.popup-overlay.active {
    display: flex;
    opacity: 1;
}
.popup-card {
    background: var(--discord-sidebar); padding: 25px; width: 320px; border-radius: var(--radius-lg); box-shadow: var(--shadow-float); transform: scale(0.95); transition: transform 0.3s;
}
.popup-overlay.active .popup-card {
    transform: scale(1);
}

/* === NOUVEAU STYLE POPUP INFO FRAIS (MODIFIÉ) === */
.popup-card.info-card {
    width: 90%;
    max-width: 500px;
    padding: 30px;
    background: var(--discord-sidebar);
    border: 2px solid var(--discord-blurple);
}

.popup-card.info-card h3 {
    text-align: center;
    color: var(--discord-blurple);
    margin-bottom: 25px;
    font-size: 1.3rem;
    font-weight: 700;
}

.popup-card.info-card h3 i {
    margin-right: 10px;
}

.frais-info-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.frais-info-item {
    background: var(--discord-element);
    padding: 15px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    border-left: 4px solid transparent; /* Pour la couleur d'accentuation */
}

.frais-info-item h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-header);
    font-weight: 600;
}

.frais-info-item p {
    font-size: 0.9rem;
    color: var(--text-normal);
    margin-top: 5px;
}

.frais-info-item i {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

/* Couleurs d'accentuation pour chaque item */
.icon-voiture { color: #f0b232; } 
.frais-info-item:nth-child(1) { border-left-color: #f0b232; }

.icon-repas { color: var(--discord-green); }
.frais-info-item:nth-child(2) { border-left-color: var(--discord-green); }

.icon-debours { color: var(--discord-blurple); }
.frais-info-item:nth-child(3) { border-left-color: var(--discord-blurple); }

.popup-actions {
    margin-top: 25px;
    display: flex;
    justify-content: center; 
}


/* --- STYLES FRAIS DIVERS (COMPACT/INLINE) --- */

/* Conteneur des frais: caché par défaut */
.frais-divers-container-hidden {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px dashed rgba(255, 255, 255, 0.05);
}

.frais-divers-container-hidden.active {
    max-height: 500px; 
}

.frais-header-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.frais-title-label {
    font-size: 0.8rem;
    color: var(--discord-yellow); 
    font-weight: 700;
    text-transform: uppercase;
}

.btn-info-frais {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem; 
    cursor: pointer;
    transition: color 0.2s;
    padding: 0;
    line-height: 1;
}
.btn-info-frais:hover {
    color: var(--discord-blurple);
}

/* Grille pour les 3 champs de frais (plus compacte) */
.frais-inline-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 10px;
}

@media (min-width: 768px) {
    .frais-inline-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
}

.frais-item-inline {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #1e1f22; /* Encadrement léger pour chaque item */
    padding: 5px 8px;
    border-radius: 4px;
}

.frais-label-inline {
    white-space: nowrap;
    font-weight: 500;
    color: var(--text-muted);
    min-width: 40px; 
    font-size: 0.8rem; 
}

/* Input montant */
.input-frais[type="number"] {
    flex-grow: 1;
    max-width: 80px; 
    text-align: right;
    padding: 5px;
    font-size: 0.85rem;
    color: var(--discord-green) !important;
    background-color: #313338; 
}

/* Style du bouton photo */
.btn-photo {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px;
    background-color: #3b3d42; 
    border-radius: 4px;
    font-size: 0.7rem; 
    color: var(--text-muted);
    transition: background-color 0.2s;
    margin-left: 5px;
    flex-shrink: 0; 
}

.btn-photo:hover {
    background-color: #474a50;
    color: var(--discord-blurple);
}

.btn-photo i {
    font-size: 0.8rem;
}

.btn-photo .file-name {
    max-width: 35px; 
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

/* Adaptation du style pour le repas (de montant à checkbox) */
.frais-item-inline.checkbox-item {
    justify-content: flex-start;
}

/* Style de la checkbox (Custom Discord style) */
.input-repas-declare {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 20px; 
    height: 20px; 
    border: 2px solid var(--text-muted);
    border-radius: var(--radius-md);
    background-color: var(--discord-element);
    cursor: pointer;
    position: relative;
    margin: 0;
    flex-shrink: 0;
    transition: all 0.2s;
}

.input-repas-declare:checked {
    background-color: var(--discord-green);
    border-color: var(--discord-green);
}

.input-repas-declare:checked::after {
    content: '\f00c'; /* Checkmark icon (Font Awesome) */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: var(--discord-element);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
}