/* Style épuré, clair et sobre (CDC 13.4) */
:root {
    --text: #1f2933;
    --muted: #616e7c;
    --border: #d9e2ec;
    --accent: #2f6fb0;
    --danger: #b42318;
    --bg: #f7f9fb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--accent);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.user {
    color: var(--muted);
    font-size: 0.9rem;
}

.content {
    padding: 1rem;
}

.login {
    max-width: 22rem;
    margin: 3rem auto;
    padding: 1.5rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.login h1 {
    margin: 0 0 0.5rem;
    font-size: 1.4rem;
}

.login input {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
}

.login button {
    margin-top: 0.75rem;
    padding: 0.6rem;
    border: 0;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
}

table.data {
    border-collapse: collapse;
    background: #fff;
}

table.data th,
table.data td {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

form.stacked {
    max-width: 32rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

form.stacked .row {
    display: flex;
    gap: 1rem;
}

form.stacked input,
form.stacked select,
form.stacked textarea {
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
}

form.stacked button {
    align-self: flex-start;
    padding: 0.5rem 1rem;
    border: 0;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}

button.link {
    border: 0;
    background: none;
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}

.notice {
    padding: 0.5rem;
    border-radius: 4px;
    background: #e6f4ea;
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
}

/* Planning (RG-AFF-01 à RG-AFF-03) */
.planning-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    align-items: center;
    margin: 0.5rem 0 1rem;
    font-size: 0.9rem;
}

/* Liens de navigation en boutons, regroupés par fonction (décision MOA du 29/10/2026) */
.btn-group {
    display: inline-flex;
}

.btn-group > a,
a.button {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border: 1px solid #bcccdc;
    background: #fff;
    color: var(--text);
    font-size: 0.85rem;
    line-height: 1.3;
    text-decoration: none;
    white-space: nowrap;
}

a.button {
    border-radius: 6px;
}

.btn-group > a + a {
    margin-left: -1px;
}

.btn-group > a:first-child {
    border-radius: 6px 0 0 6px;
}

.btn-group > a:last-child {
    border-radius: 0 6px 6px 0;
}

.btn-group > a:hover,
a.button:hover {
    background: #eef3f8;
}

.btn-group > a.active {
    position: relative;
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

/* Colonnes de même largeur, sauf Absents plus large ; 4 lignes au moins par case (décision MOA du 29/10/2026) */
table.planning {
    border-collapse: collapse;
    background: #fff;
    font-size: 0.85rem;
    line-height: 1.35;
    width: 100%;
    table-layout: fixed;
}

table.planning col.date {
    width: 6.5rem;
}

table.planning col.half {
    width: 5.5rem;
}

table.planning col.absents {
    width: 11rem;
}

table.planning td {
    position: relative;
    height: calc(4 * 1.35em + 0.5rem);
    overflow-wrap: anywhere;
}

table.planning th,
table.planning td {
    border: 1px solid var(--border);
    padding: 0.25rem 0.35rem;
    vertical-align: top;
}

table.planning tbody.day {
    border-top: 2px solid #9aa5b1;
}

table.planning th.practitioner {
    background: var(--color, #5b7083);
    color: #fff;
}

table.planning th.half {
    font-weight: normal;
    color: var(--muted);
    white-space: nowrap;
}

td.cell.off {
    background: #eceff1;
}

/* Praticien absent hors repos : hachures, motif dans la case */
td.cell.absent,
.card-half.absent {
    background: repeating-linear-gradient(135deg, #e4e7eb 0 6px, #f5f7fa 6px 12px);
}

/* Alertes du brouillon, une couleur par cas (décision MOA du 29/10/2026) */
.alert-need,
td.cell.alert-need {
    background: #fbd5d2;
}

.alert-trainee,
td.cell.alert-trainee {
    background: #ffe0b8;
}

.alert-experienced,
td.cell.alert-experienced {
    background: #fff3b0;
}

/* Groupes de praticiens par espace */
table.planning th.group {
    background: var(--group, #eceff1);
    text-align: center;
    font-weight: 600;
}

table.planning .group-start {
    border-left: 3px solid #9aa5b1;
}

table.planning tbody.week-separator td {
    height: 0.6rem;
    padding: 0;
    border: 0;
    background: #7b8794;
}

table.planning th.date {
    white-space: nowrap;
    text-align: left;
}

/* En-tête et navigation toujours visibles (décalage des lignes d'en-tête calculé dans app.js) */
.toolbar.sticky {
    position: sticky;
    top: 0;
    z-index: 3;
    margin: 0;
    padding: 0.5rem 0;
    background: var(--bg);
}

table.planning thead th {
    position: sticky;
    z-index: 2;
    background: #fff;
}

/* Support et Absents : 4 lignes au plus, liste entière (un nom par ligne) au survol */
.clamp {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

td.absents .clamp {
    font-size: 0.8rem;
}

/* Planning publié : noms centrés, fond bleu léger pour Support et Absents */
table.planning.published td {
    text-align: center;
}

table.planning.published td.support,
table.planning.published td.absents,
table.planning.published th.side {
    background: #eaf2fb;
}

/* Planning des secrétaires : largeur réduite, jours à gauche, espaces et absentes centrés */
table.planning.secretaries {
    width: auto;
    table-layout: auto;
}

table.planning.secretaries td,
table.planning.secretaries thead th {
    text-align: center;
    min-width: 8rem;
}

table.planning.secretaries td.absents {
    min-width: 11rem;
}

table.planning.secretaries th.date,
table.planning.secretaries th.half {
    text-align: left;
}

table.planning tr.closed td,
table.planning tr.incoherent td {
    height: auto;
}

tr.closed td {
    background: #eceff1;
    color: var(--muted);
    text-align: center;
}

tr.incoherent td {
    color: var(--danger);
    font-size: 0.8rem;
}

.chip {
    display: inline-block;
    margin: 0 0.25rem 0.15rem 0;
}

/* Dans le tableau : un nom par ligne */
table.planning td.cell .chip {
    display: block;
    margin: 0;
}

.chip.trainee {
    font-style: italic;
}

/* Dérogation : en gras ; inversion (brouillon) : en rouge (décision MOA du 29/10/2026) */
.chip.override {
    font-weight: 700;
}

.swap {
    color: var(--danger);
}

/* Icône de modification en bas à droite de la case */
td a.edit {
    position: absolute;
    right: 0.2rem;
    bottom: 0.1rem;
    text-decoration: none;
    opacity: 0.3;
}

td:hover a.edit {
    opacity: 1;
}

.reason {
    color: var(--muted);
    font-size: 0.75rem;
}

.mobile {
    display: none;
}

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 4px solid var(--color, #5b7083);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
}

.card h2 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
}

.card-half {
    padding: 0.2rem 0;
}

@media (max-width: 768px) {
    .desktop {
        display: none;
    }

    .mobile {
        display: block;
    }
}

.alert {
    margin: 0;
    padding: 0.5rem;
    border-radius: 4px;
    background: #fdecea;
    color: var(--danger);
}

/* Fiche personne en fenêtre modale (RG-AFF-05) */
.clickable {
    cursor: pointer;
}

.chip.clickable:hover,
th.clickable:hover {
    text-decoration: underline;
}

dialog#person-card,
dialog.modal {
    max-width: 44rem;
    width: calc(100% - 2rem);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
}

dialog.modal {
    max-width: 28rem;
}

dialog#person-card::backdrop,
dialog.modal::backdrop {
    background: rgba(31, 41, 51, 0.4);
}

dialog#person-card form.close,
dialog.modal form.close {
    float: right;
}

dialog#person-card form.close button,
dialog.modal form.close button {
    border: 0;
    background: none;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Détail des jours de congé, par mois */
dialog.modal h2 {
    margin-top: 0;
    font-size: 1.1rem;
}

dialog.modal h3 {
    margin: 0.9rem 0 0.3rem;
    font-size: 0.95rem;
}

ul.leave-days {
    margin: 0;
    padding-left: 1.2rem;
    columns: 2;
}

/* État des congés : colonnes de même largeur, valeurs centrées */
table.data.balances {
    table-layout: fixed;
    width: 100%;
    max-width: 60rem;
}

table.data.balances th,
table.data.balances td {
    text-align: center;
}

table.data.balances button.link {
    font: inherit;
}

/* Demande de congé : libellés au-dessus des zones, zones alignées sur une grille */
form.leave-form {
    max-width: 36rem;
    gap: 1rem;
}

form.leave-form .row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.5rem;
}

form.leave-form .row > div,
form.leave-form > div {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

form.leave-form label {
    font-weight: 600;
    font-size: 0.9rem;
}

form.leave-form input,
form.leave-form select,
form.leave-form textarea {
    width: 100%;
    box-sizing: border-box;
}

form.leave-form textarea {
    min-height: 4.5rem;
}

/* Mes demandes : largeurs de colonnes équilibrées */
table.data.requests {
    table-layout: fixed;
    width: 100%;
    max-width: 60rem;
}

table.data.requests col.date {
    width: 17%;
}

table.data.requests col.status {
    width: 24%;
}

table.data.requests col.action {
    width: 9%;
}

table.data.requests td {
    vertical-align: top;
    overflow-wrap: anywhere;
}

.person-card h2 {
    margin-top: 0;
    font-size: 1.2rem;
}

.person-card h3 {
    font-size: 1rem;
    margin: 1rem 0 0.4rem;
}

/* Notifications (RG-MAIL-03) */
.badge {
    display: inline-block;
    min-width: 1.2rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.75rem;
    text-align: center;
}

tr.unread td {
    font-weight: 600;
}

/* Aide en ligne (RG-AID-01) */
.help {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.help-toc {
    flex: 0 0 16rem;
    font-size: 0.9rem;
}

.help-toc a.active {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.help-content {
    max-width: 48rem;
    line-height: 1.55;
}

.help-content table {
    border-collapse: collapse;
}

.help-content th,
.help-content td {
    border: 1px solid var(--border);
    padding: 0.3rem 0.6rem;
}

a.help-icon {
    display: inline-block;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    line-height: 1.3rem;
}

@media (max-width: 768px) {
    .help {
        flex-direction: column;
    }

    .help-toc {
        flex-basis: auto;
        order: 2;
    }
}
