/* ---------- En-tête de page ---------- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1rem 0;
}

    .page-header h1 {
        margin: 0;
        font-size: 1.6rem;
        font-weight: 700;
        color: #111827;
    }

.table-tools {
    display: flex;
    gap: .5rem;
    align-items: center;
}

.btn-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: .4rem;
    background: #2563eb;
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    text-decoration: none;
    border: none;      /* aussi en <button> */
    cursor: pointer;
}

    .btn-add:hover {
        background: #1d4ed8;
        color: #fff;
    }

/* ---------- Boutons ---------- */
.btn-primary,
.btn-secondary {
    height: 2rem;
    padding: 0 .8rem;
    border-radius: .3rem;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary {
    background: #2563eb;
    border: 1px solid #2563eb;
    color: #fff;
}

    .btn-primary:hover:not(:disabled) {
        background: #1d4ed8;
    }

.btn-secondary {
    background: #fff;
    border: 1px solid #9ca3af;
    color: #374151;
}

    .btn-secondary:hover:not(:disabled) {
        background: #f3f4f6;
    }

    .btn-primary:disabled,
    .btn-secondary:disabled {
        opacity: .6;
        cursor: not-allowed;
    }

/* ---------- Tableau classique ---------- */
.table-wrap {
    overflow-x: auto;
    background: #fff;
}

table.grid {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

    table.grid th,
    table.grid td {
        border: 1px solid #d1d5db;
        padding: .45rem .6rem;
        text-align: left;
        vertical-align: middle;
        white-space: nowrap;
    }

    /* titres */
    table.grid thead tr:first-child th {
        background: #e5e7eb;
        color: #111827;
        font-weight: 700;
    }

th.sortable {
    cursor: pointer;
    user-select: none;
}

    th.sortable:hover {
        background: #d1d5db;
    }

.sort-icon {
    margin-left: .3rem;
    font-size: .7rem;
}

/* filtres */
.filter-row th {
    background: #f9fafb;
    padding: .3rem .4rem;
    font-weight: 400;
}

.filter-input {
    width: 100%;
    min-width: 80px;
    height: 1.8rem;
    padding: 0 .4rem;
    border: 1px solid #9ca3af;
    border-radius: .25rem;
    font-size: .85rem;
    background: #fff;
}

    .filter-input:focus {
        outline: none;
        border-color: #2563eb;
    }

/* lignes */
table.grid tbody tr:nth-child(even) {
    background: #f9fafb;
}

table.grid tbody tr:hover {
    background: #e8f0fe;
}

table.grid tbody tr.editing,
table.grid tbody tr.editing:hover {
    background: #fffbe6;
}

td.center {
    text-align: center;
}

.actions-cell {
    width: 1%;
    text-align: center;
    white-space: nowrap;   /* plusieurs boutons restent sur une ligne */
}

    .actions-cell > * + * {
        margin-left: .3rem;
    }

/* ---------- Champs d'édition ---------- */
.input {
    min-width: 7rem;
    height: 1.9rem;
    padding: 0 .4rem;
    border: 1px solid #9ca3af;
    border-radius: .25rem;
    font-size: .9rem;
    background: #fff;
}

    .input:focus {
        outline: none;
        border-color: #2563eb;
    }

/* ---------- Divers ---------- */
.empty {
    text-align: center;
    color: #6b7280;
    padding: 1.2rem !important;
}

/* rapports : ligne de grand total (ex. total du passif et des capitaux, résultat net) */
.report-total {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
    padding: .6rem .75rem;
    background: #e8eef5;
    color: #1f3a5f;
    font-weight: 700;
}

.table-footer {
    margin-top: .5rem;
    color: #6b7280;
    font-size: .85rem;
    text-align: right;
}

.form-error {
    margin-bottom: 1rem;
    padding: .7rem .9rem;
    border-radius: .3rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: .9rem;
}

/* ===== Lignes dépliables (ex. lignes d'un bon de commande) ===== */
table.grid .expand-cell {
    width: 2rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    text-align: center;
}

.btn-expand {
    width: 1.6rem;
    height: 1.6rem;
    padding: 0;
    border: none;
    border-radius: 0.35rem;
    background: transparent;
    color: #475569;
    font-size: 0.75rem;
    cursor: pointer;
}

    .btn-expand:hover {
        background: #e2e8f0;
        color: #111827;
    }

table.grid tbody tr.expanded > td {
    background: #eff6ff;
}

table.grid tbody tr.detail-row > td,
table.grid tbody tr.detail-row:hover > td {
    background: #f8fafc;
    padding-top: 0.5rem;
    padding-bottom: 0.75rem;
}

table.grid.sub-grid {
    width: 100%;
    font-size: 0.85rem;
    background: #fff;
}

table.grid .num {
    text-align: right;
    white-space: nowrap;
}

/* pastilles de statut */
.status {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-ordered { background: #dbeafe; color: #1e40af; }
.status-inreception { background: #fef3c7; color: #92400e; }
.status-received { background: #dcfce7; color: #166534; }
.status-inprogress { background: #f1f5f9; color: #475569; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-incomplete { background: #ffedd5; color: #9a3412; }
.status-draft { background: #f1f5f9; color: #475569; }
.status-posted { background: #dcfce7; color: #166534; }
.status-voided { background: #fee2e2; color: #991b1b; }
/* bons de travail (cancelled : déjà défini) */
.status-planned { background: #f1f5f9; color: #475569; }
.status-released { background: #dbeafe; color: #1e40af; }
.status-completed { background: #dcfce7; color: #166534; }
.status-closed { background: #e5e7eb; color: #374151; }

/* titre de colonne sur plusieurs lignes (colonne étroite) */
table.grid th.th-wrap {
    white-space: normal;
    line-height: 1.2;
}
