/* ---------- Base ---------- */
:root {
    --bord: #d0d7de;
    --fond: #f4f6f8;
    --texte: #1f2328;
    --principal: #1f4e79;
    --danger: #b42318;
    --vert: #d8f3dc;
    --orange: #ffe5c2;
    --jaune: #fff7c2;
    --gris: #eceff1;
    --gris-fonce: #cfd8dc;
}

* { box-sizing: border-box; }
html, body { margin: 0; font-family: "Segoe UI", Roboto, Arial, sans-serif; font-size: 14px; color: var(--texte); background: var(--fond); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h1 small { font-weight: normal; color: #666; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
a { color: var(--principal); }
code { background: #eef1f4; padding: 0 .25em; border-radius: 3px; }

/* ---------- Barre du haut (couleur = société) ---------- */
.barre { display: flex; align-items: center; gap: 1.5rem; padding: .5rem 1rem; color: #fff; position: sticky; top: 0; z-index: 10; }
.barre a, .barre .btn-lien { color: #fff; text-decoration: none; }
.barre .titre { font-weight: 600; font-size: 1.1rem; }
.barre .menu { display: flex; gap: .25rem; }
.barre .menu a { padding: .35rem .7rem; border-radius: 4px; }
.barre .menu a.active, .barre .menu a:hover { background: rgba(255, 255, 255, .2); }
.barre .droite { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.barre select { margin-left: .4rem; padding: .2rem; border-radius: 4px; border: none; }
.barre label { color: #fff; }
.barre .societe { font-weight: 600; padding: .2rem .6rem; background: rgba(255, 255, 255, .2); border-radius: 4px; }
.btn-lien { background: none; border: none; cursor: pointer; font: inherit; text-decoration: underline; }

.contenu { padding: 1rem; }
.contenu.centre { display: flex; flex-direction: column; align-items: center; padding-top: 8vh; }

/* ---------- Cartes / formulaires ---------- */
.carte { background: #fff; border: 1px solid var(--bord); border-radius: 6px; padding: .9rem 1rem; margin-bottom: 1rem; }
.connexion { width: 360px; }
.connexion label, .grille-fiche label { display: block; margin-bottom: .6rem; }
label { font-size: .9rem; color: #444; }
input, select, textarea { font: inherit; padding: .35rem .45rem; border: 1px solid var(--bord); border-radius: 4px; background: #fff; }
.connexion input, .connexion select, .grille-fiche select, .grille-fiche textarea { width: 100%; margin-top: .2rem; }
textarea[readonly] { background: #f6f8fa; }
.ligne-champs { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: .5rem; }
.ligne-champs label { margin-bottom: 0; }
.ligne-champs input[type=number] { width: 7rem; }
label.case, label.radio { display: inline-flex; align-items: center; gap: .35rem; margin-right: 1rem; }
fieldset { border: 1px solid var(--bord); border-radius: 4px; margin: 0 0 .75rem; }

.btn { padding: .4rem .9rem; border: 1px solid var(--bord); background: #fff; border-radius: 4px; cursor: pointer; font: inherit; }
.btn:hover:not(:disabled) { background: #f0f3f6; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.principal { background: var(--principal); color: #fff; border-color: var(--principal); }
.btn.principal:hover:not(:disabled) { filter: brightness(1.1); background: var(--principal); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.petit { padding: .2rem .5rem; }

.alerte { padding: .6rem .8rem; border-radius: 4px; margin: .5rem 0; }
.alerte.erreur { background: #fdecea; color: #8a1c12; }
.alerte.succes { background: #e7f6ec; color: #1a6232; }
.alerte.avertissement { background: #fff4d6; color: #7a5300; }
.alerte.info, .info { color: #555; }

/* ---------- Accueil ---------- */
.tuiles { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tuile { display: block; width: 240px; padding: 1.2rem; background: #fff; border: 1px solid var(--bord); border-radius: 6px; text-decoration: none; color: var(--texte); }
.tuile:hover { border-color: var(--principal); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.tuile b { font-size: 1.2rem; color: var(--principal); }

/* ---------- Liste ---------- */
.filtres { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.navigation-travailleur { display: flex; gap: .25rem; align-items: center; }
.navigation-travailleur select { min-width: 260px; }
.actions { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; flex-wrap: wrap; }
.compteur { margin-left: auto; color: #555; }
.table-defilante { overflow: auto; max-height: calc(100vh - 260px); background: #fff; border: 1px solid var(--bord); border-radius: 6px; }
.grille { border-collapse: collapse; width: 100%; white-space: nowrap; }
.grille th, .grille td { border-bottom: 1px solid #e5e8eb; padding: .3rem .45rem; text-align: left; }
.grille thead th { position: sticky; top: 0; background: #f6f8fa; z-index: 1; font-weight: 600; }
.grille tfoot td { position: sticky; bottom: 0; background: #f6f8fa; font-weight: 600; }
.grille .n { text-align: right; }
.grille td.texte { white-space: normal; min-width: 160px; max-width: 280px; }
.grille tbody tr { cursor: pointer; }
.grille tbody tr:hover td { filter: brightness(.96); }
.grille.simple tbody tr { cursor: default; }
/* Dernière ligne ouverte (retour de la fiche) : barre bleue à gauche + texte en gras */
.grille tr.selectionnee td { font-weight: 600; }
.grille tr.selectionnee td:first-child { box-shadow: inset 5px 0 0 var(--principal); }
.l-vert td { background: var(--vert); }
.l-orange td { background: var(--orange); }
.l-jaune td { background: var(--jaune); }
.l-gris td { background: var(--gris); }
.l-gris-fonce td { background: var(--gris-fonce); }
td.anomalie { background: #1d4f91 !important; color: #fff; }
.pastille { width: 26px; height: 26px; border-radius: 50%; border: none; color: #fff; cursor: pointer; font-weight: bold; }
.pastille.verte { background: #2e7d32; }
.pastille.rouge { background: #c62828; }
.pastille-couleur { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
.vide { padding: 1rem; color: #666; }

/* ---------- Fiche détail ---------- */
.entete-fiche { display: flex; justify-content: space-between; align-items: flex-start; }
.entete-fiche .boutons { display: flex; gap: .5rem; }
.date-lettres { margin: -.4rem 0 .8rem; font-size: 1.1rem; text-transform: capitalize; }
/* Fiche : 3 colonnes. Ligne 1 : Prestations | Déplacements | Données travailleur.
   Ligne 2 : Chantiers (2 colonnes) | Approbations + Historique empilés à droite. */
.grille-fiche { display: grid; grid-template-columns: repeat(3, minmax(320px, 1fr)); gap: 0 1rem; align-items: start; }
.grille-fiche .chantiers-carte { grid-column: span 2; }
.grille-fiche .colonne-droite { display: flex; flex-direction: column; }
.grille-fiche .carte { height: calc(100% - 1rem); }
.grille-fiche .colonne-droite .carte, .grille-fiche .chantiers-carte { height: auto; }
@media (max-width: 1150px) {
    .grille-fiche { grid-template-columns: 1fr; }
    .grille-fiche .chantiers-carte { grid-column: auto; }
    .grille-fiche .carte { height: auto; }
}
.chantiers { border-collapse: collapse; }
.chantiers th, .chantiers td { padding: .2rem .4rem; text-align: left; }
.chantiers input { width: 9rem; }
.chantiers input[type=number] { width: 6rem; }
input.calcule { background: var(--vert); }
input.anomalie-champ { background: var(--jaune); }
.libelle-chantier { font-size: .85rem; color: #555; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.libelle-chantier.inconnu { color: var(--danger); font-weight: 600; }
.libelle-chantier.cloture { color: #b45309; }
.chantiers input.inconnu { border-color: var(--danger); background: #fdecea; }
.anomalie-texte { color: #8a1c12; font-weight: 600; }
.heure { width: 5.5rem; text-align: center; }
.champ-date { display: inline-flex; align-items: center; position: relative; gap: .15rem; }
.champ-date input.date { width: 7.5rem; text-align: center; }
.champ-date input.invalide, input.invalide { border-color: var(--danger); background: #fdecea; }
.btn-calendrier { border: 1px solid var(--bord); background: #fff; border-radius: 4px; cursor: pointer; padding: .25rem .35rem; line-height: 1; }
.calendrier-cache { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.historique { white-space: pre-wrap; font-family: inherit; margin: 0; max-height: 260px; overflow: auto; }

/* ---------- Blazor ---------- */
#blazor-error-ui { background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2); display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
