/* =============================================
   MODULE DÉMARCHES — Ordre de mission
   Formulaire de création (new.html.twig)
   100 % tokens du design system → compatible 5 thèmes (dark inclus)
   ============================================= */

/* Carte du formulaire : largeur de lecture confortable, centrée.
   max-width (pas width fixe) → se réduit proprement sur mobile. */
.om-form-card {
    max-width: 760px;
    margin: 2rem auto 0;
    padding: 2.5rem;
}

@media (max-width: 768px) {
    .om-form-card {
        padding: 1.5rem;
        margin-top: 1.5rem;
    }
}

/* Petit texte d'introduction sous le titre de la carte */
.om-intro {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0 0 1.75rem;
}

/* -------------------------------------------------
   Bandeau « Demandeur » en lecture seule
   ------------------------------------------------- */
.om-requester {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.75rem;
    background: var(--bg-body-secondary);
    border: 1px solid var(--border-main);
    border-radius: var(--radius-ui);
}

.om-requester-avatar {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-main);
    color: var(--text-muted);
}

.om-requester-avatar i,
.om-requester-avatar svg {
    width: 22px;
    height: 22px;
}

.om-requester-body {
    min-width: 0; /* autorise l'ellipsis des longues adresses */
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.om-requester-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.om-requester-name {
    font-weight: 600;
    color: var(--text-main);
}

.om-requester-email {
    font-size: 0.88rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* -------------------------------------------------
   Disposition des champs
   ------------------------------------------------- */
.om-fields {
    display: grid;
    gap: 1.25rem;
}

/* Deux dates côte à côte (repli en colonne sous 768px via .grid-2 partagé) */
.om-dates {
    margin-top: 0; /* l'espacement vient déjà de .om-fields */
}

/* Champ avec icône décorative (dates) : l'icône se superpose à gauche de
   l'input. Le wrapper est le contexte de positionnement ; l'icône est ancrée
   sur la ligne de l'input (et non sur le bloc label+input). */
.om-field-icon {
    position: relative;
}

/* Cible uniquement l'icône décorative directe du wrapper (pas une éventuelle
   icône au sein d'un message d'erreur ou du widget). */
.om-field-icon > i,
.om-field-icon > svg {
    position: absolute;
    left: 0.9rem;
    /* aligne sur la ligne de l'input : haut du groupe + hauteur label
       (~1.05rem) + gap label↔input (0.5rem) + demi-hauteur input (~1.5rem). */
    top: 3.05rem;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 1;
}

.om-field-icon .form-input {
    padding-left: 2.5rem;
}

/* -------------------------------------------------
   Zone d'actions
   ------------------------------------------------- */
.om-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 2rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--border-light);
}

/* Sur mobile : actions empilées et pleine largeur, primaire en premier visuellement */
@media (max-width: 768px) {
    .om-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .om-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* =============================================
   MODULE DÉMARCHES — Avis d'absence
   Saisie, fiche (circuit + preuves)
   ============================================= */

.abs-page {
    max-width: 900px;
    margin: 2rem auto 0;
}

/* Case à cocher : la case avant son libellé */
.abs-check {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin: 0.5rem 0 1rem;
    cursor: pointer;
}

.abs-check input {
    margin-top: 0.25rem;
    flex-shrink: 0;
}

.abs-fieldset {
    border: 1px solid var(--border-main);
    border-radius: var(--radius-ui);
    padding: 1rem 1.25rem 0.25rem;
    margin: 0 0 1.5rem;
}

.abs-fieldset legend {
    font-weight: 600;
    padding: 0 0.4rem;
}

/* Fiche : récapitulatif */
.abs-card {
    padding: 2rem;
}

@media (max-width: 768px) {
    .abs-card {
        padding: 1.25rem;
    }
}

.abs-summary {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 0.75rem 1.5rem;
    margin: 0;
}

.abs-summary dt {
    font-weight: 600;
    color: var(--text-muted);
}

.abs-summary dd {
    margin: 0;
    white-space: pre-line;
}

@media (max-width: 640px) {
    .abs-summary {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .abs-summary dd {
        margin-bottom: 0.75rem;
    }
}

.abs-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* Circuit : une ligne par étape */
.abs-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.abs-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-main);
    border-radius: var(--radius-ui);
}

.abs-step > i,
.abs-step > svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 0.15rem;
    color: var(--text-muted);
}

.abs-step--done > i,
.abs-step--done > svg {
    color: var(--success);
}

.abs-step--refused > i,
.abs-step--refused > svg {
    color: var(--error);
}

.abs-step--current {
    border-color: var(--warning);
}

.abs-step--current > i,
.abs-step--current > svg {
    color: var(--warning);
}

.abs-step-title {
    font-weight: 600;
}

.abs-step-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

/* Bloc d'action (signer, transmettre, statuer, archiver) */
.abs-action {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-main);
}

.abs-action h3,
.abs-proof h3 {
    font-size: 1rem;
    margin: 0 0 0.75rem;
}

.abs-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

/* Contrôle d'intégrité */
.abs-proof {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-main);
}

.abs-proof-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.abs-proof-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.abs-proof-list i,
.abs-proof-list svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.abs-ok {
    color: var(--success);
}

.abs-ko {
    color: var(--error);
}

.abs-hash {
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
    overflow-wrap: anywhere;
}

/* Refus d'un ordre de mission : motif + bouton sur une ligne */
.abs-refuse {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.abs-refuse .form-input {
    min-width: 220px;
    flex: 1;
}

/* =============================================
   MODULE DÉMARCHES — Boîte unique (accueil)
   À traiter / En cours / Terminées, filtrables par type
   ============================================= */

.dm-page {
    max-width: 1000px;
    margin: 2rem auto 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dm-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.05rem;
    margin: 0 0 1rem;
}

.dm-section-title i,
.dm-section-title svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.dm-count {
    min-width: 1.5rem;
    padding: 0 0.45rem;
    border-radius: 999px;
    background: var(--bg-body-secondary);
    font-size: 0.8rem;
    line-height: 1.5rem;
    text-align: center;
}

/* Nouvelle démarche : une carte par type */
.dm-create {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.dm-create-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    color: inherit;
    text-decoration: none;
}

.dm-create-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-ui);
    background: var(--bg-body-secondary);
}

.dm-create-icon i,
.dm-create-icon svg {
    width: 22px;
    height: 22px;
}

.dm-create-label {
    display: block;
    font-weight: 700;
}

.dm-create-desc {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Filtre par type */
.dm-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dm-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--border-main);
    border-radius: 999px;
    color: inherit;
    font-size: 0.9rem;
    text-decoration: none;
}

.dm-chip i,
.dm-chip svg {
    width: 15px;
    height: 15px;
}

.dm-chip.is-active {
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

/* Blocs */
.dm-box {
    padding: 1.25rem 1.5rem;
}

.dm-box--action {
    border-left: 4px solid var(--warning);
}

.dm-box--action .dm-section-title i,
.dm-box--action .dm-section-title svg {
    color: var(--warning);
}

.dm-empty {
    color: var(--text-muted);
    margin: 0;
}

/* Lignes */
.dm-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dm-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border-main);
}

.dm-row:first-child {
    border-top: none;
    padding-top: 0;
}

.dm-row-icon {
    flex-shrink: 0;
    color: var(--text-muted);
}

.dm-row-icon i,
.dm-row-icon svg {
    width: 20px;
    height: 20px;
}

.dm-row-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.dm-row-title {
    font-weight: 600;
    color: inherit;
    text-decoration: none;
}

.dm-row-title:hover {
    text-decoration: underline;
}

.dm-row-detail {
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dm-row-side {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.dm-row-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dm-row-pdf {
    color: var(--text-muted);
    display: inline-flex;
}

.dm-row-pdf i,
.dm-row-pdf svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 640px) {
    .dm-row {
        flex-wrap: wrap;
    }

    .dm-row-side {
        width: 100%;
        padding-left: calc(20px + 0.9rem);
    }

    .dm-row-detail {
        white-space: normal;
    }
}

/* POC — page « certificat du ministère » (publique, sans menus) */
.cert-page {
    padding: 0 1rem;
}

.cert-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.3rem;
    margin: 0 0 0.75rem;
}

/* Signature par certificat : rappel juste au-dessus du bouton */
.abs-cert-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.abs-cert-hint i,
.abs-cert-hint svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Contrôle d'intégrité : replié par défaut */
details.abs-proof > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
}

details.abs-proof[open] > summary {
    margin-bottom: 0.75rem;
}

/* Suivi de la demande : repliable */
details.abs-circuit > summary {
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 0.75rem;
}
