*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #F5F4F0;
    --surface:   #FFFFFF;
    --border:    #E2E0D8;
    --text:      #1A1916;
    --muted:     #8A8880;
    --accent:    #3e0088;
    --accent-lt: #F5E8E5;
    --tag-bg:    #EDECEA;
    --radius:    10px;
    --shadow:    0 2px 12px rgba(0,0,0,.07);
    --trans:     .18s ease;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.5;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 100px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.logo-link { display: flex; align-items: center; flex-shrink: 0; }
.logo-img  { display: block; }
.header-title { font-size: 15px; font-weight: 400; color: var(--muted); }
.header-count {
    margin-left: auto;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--muted);
    background: var(--tag-bg);
    padding: 4px 10px;
    border-radius: 20px;
}
.limit-warn { }

.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: calc(100vh - 100px);
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 20px;
    position: sticky;
    top: 100px;
    height: calc(100vh - 100px);
    overflow-y: auto;
}

/* ── Onglets ── */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 22px;
}
.tab-btn {
    padding: 6px 11px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: all var(--trans);
    white-space: nowrap;
    text-decoration: none;
    display: inline-block;
}
.tab-btn:hover { border-color: var(--accent); color: var(--accent); }
.tab-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Formulaire ── */
.form-group { margin-bottom: 16px; }
label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 6px;
    letter-spacing: .03em;
}
input[type="text"], select {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color var(--trans), box-shadow var(--trans);
    appearance: none;
    -webkit-appearance: none;
}
input[type="text"]:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-lt);
}
.select-wrap { position: relative; }
.select-wrap::after {
    content: '▾';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
    font-size: 11px;
}
.hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

.btn-search {
    width: 100%;
    padding: 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity var(--trans), transform var(--trans);
    margin-top: 4px;
}
.btn-search:hover { opacity: .88; transform: translateY(-1px); }
.btn-search:active { transform: translateY(0); }

.btn-reset {
    width: 100%;
    padding: 9px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    margin-top: 8px;
    transition: border-color var(--trans), color var(--trans);
    text-decoration: none;
    display: block;
    text-align: center;
}
.btn-reset:hover { border-color: var(--accent); color: var(--accent); }

main { padding: 32px; }

.state-box { text-align: center; padding: 80px 20px; color: var(--muted); }
.state-icon { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.state-title { font-size: 17px; font-weight: 500; margin-bottom: 8px; color: var(--text); }
.state-sub { font-size: 14px; max-width: 360px; margin: 0 auto; }

.error-box {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-radius: var(--radius);
    padding: 16px 20px;
    color: #B91C1C;
    font-size: 14px;
    margin-bottom: 24px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--trans), box-shadow var(--trans), border-color var(--trans);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #C9C7BE; }
.card-photo { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; background: var(--tag-bg); }
.card-body  { padding: 10px 12px 12px; }
.card-name  { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-fn    { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-desc  { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26,25,22,.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface);
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    overflow: hidden;
    animation: modalIn .2s ease;
    position: relative;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    padding: 28px 28px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-photo    { width: 80px; height: 100px; object-fit: cover; border-radius: 8px; flex-shrink: 0; background: var(--tag-bg); }
.modal-name     { font-size: 20px; font-weight: 600; line-height: 1.2; }
.modal-fn       { color: var(--muted); font-size: 14px; margin-top: 2px; }
.modal-desc     { color: var(--accent); font-size: 12px; font-weight: 500; margin-top: 8px; background: var(--accent-lt); display: inline-block; padding: 2px 8px; border-radius: 20px; }
.modal-body     { padding: 20px 28px 28px; display: flex; flex-direction: column; gap: 12px; }
.modal-row      { display: flex; align-items: center; gap: 12px; }
.modal-icon     { width: 32px; height: 32px; background: var(--tag-bg); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.modal-row-label{ font-size: 11px; color: var(--muted); }
.modal-row-val  { font-size: 14px; font-weight: 500; }
.modal-row-val a{ color: var(--accent); text-decoration: none; }
.modal-row-val a:hover { text-decoration: underline; }
.modal-nip      { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--muted); background: var(--tag-bg); padding: 2px 7px; border-radius: 4px; }
.modal-close    { position: absolute; top: 16px; right: 16px; width: 32px; height: 32px; background: var(--tag-bg); border: none; border-radius: 50%; cursor: pointer; font-size: 16px; color: var(--muted); display: flex; align-items: center; justify-content: center; transition: background var(--trans); }
.modal-close:hover { background: var(--border); }

/* ── Photo cliquable dans modal ── */
.modal-photo {
    cursor: zoom-in;
    transition: opacity var(--trans);
}
.modal-photo:hover { opacity: .88; }

/* ── Lightbox ── */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.88);
    z-index: 300;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
    animation: modalIn .2s ease;
}

@media (max-width: 768px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
    main { padding: 20px 16px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
    header { padding: 0 16px; }
}

/* ── Signalement ── */
.modal-footer {
    padding: 0 28px 20px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: -8px;
}
.btn-report {
    background: none;
    border: none;
    font-family: inherit;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    padding: 0;
    transition: color var(--trans);
}
.btn-report:hover { color: var(--accent); }

/* ── Classes utilitaires (remplacement styles inline) ── */
.hidden                { display: none !important; }
.modal-header--top     { align-items: flex-start; padding-bottom: 16px; }
.modal-name--sm        { font-size: 16px; }
.hint--mt              { margin-top: 6px; }
.form-group--full      { width: 100%; }
.textarea-report {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    outline: none;
    transition: border-color var(--trans), box-shadow var(--trans);
}
.textarea-report:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-lt);
}
.report-feedback {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: var(--radius);
}
.report-feedback--ok  { background: #F0FDF4; color: #166534; }
.report-feedback--err { background: #FEF2F2; color: #B91C1C; }

/* ── Page de login ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 56px 48px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,.07);
    max-width: 380px;
    width: 100%;
}
.login-logo { margin-bottom: 36px; }
.login-logo img { max-width: 200px; height: auto; }
.login-title { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.login-sub   { font-size: 14px; color: var(--muted); margin-bottom: 32px; }
.btn-login {
    display: inline-block;
    padding: 12px 32px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: opacity .18s ease, transform .18s ease;
}
.btn-login:hover  { opacity: .88; transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }

/* ── Select désactivé ── */
select:disabled {
    opacity: .45;
    cursor: not-allowed;
}

/* ── Bouton imprimer ── */
.btn-print {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--tag-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: border-color var(--trans), color var(--trans);
}
.btn-print:hover { border-color: var(--accent); color: var(--accent); }

/* ── En-tête d'impression (masqué à l'écran) ── */
.print-header { display: none; }

/* ── CSS impression ── */
@media print {
    /* Masquer les éléments non nécessaires */
    .no-print,
    header,
    .sidebar,
    .modal-overlay,
    .lightbox,
    .btn-print    { display: none !important; }

    /* Mise en page */
    body { background: #fff; font-size: 11pt; }

    .layout { display: block; }

    main { padding: 0; }

    /* En-tête d'impression */
    .print-header {
        display: flex;
        align-items: center;
        gap: 16px;
        border-bottom: 2px solid #3e0088;
        padding-bottom: 12px;
        margin-bottom: 20px;
    }
    .print-logo    { height: 40px; width: auto; }
    .print-criteria {
        font-size: 13pt;
        font-weight: 600;
        color: #1A1916;
        flex: 1;
    }
    .print-count {
        font-size: 10pt;
        color: #8A8880;
    }

    /* Grille trombinoscope */
    .grid {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
    }

    .card {
        border: 1px solid #ddd;
        border-radius: 6px;
        overflow: hidden;
        break-inside: avoid;
        cursor: default;
    }

    .card-photo {
        width: 100%;
        aspect-ratio: 3/4;
        object-fit: cover;
    }

    .card-body { padding: 6px 8px 8px; }
    .card-name { font-size: 9pt; font-weight: 600; }
    .card-fn   { font-size: 8pt; color: #666; }
    .card-desc { font-size: 7pt; color: #888; margin-top: 2px; }
}

/* ── Toolbar (boutons vue + impression) ── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.view-toggle {
    display: flex;
    gap: 4px;
}
.view-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    font-size: 16px;
    cursor: pointer;
    color: var(--muted);
    transition: all var(--trans);
    display: flex;
    align-items: center;
    justify-content: center;
}
.view-btn:hover { border-color: var(--accent); color: var(--accent); }
.view-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Vue liste ── */
.list-view {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.list-row {
    display: grid;
    grid-template-columns: 220px 1fr 1fr 140px;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--trans), border-color var(--trans);
}
.list-row:hover { background: var(--accent-lt); border-color: var(--accent); }
.list-sn   { font-weight: 600; font-size: 14px; }
.list-fn   { font-size: 14px; color: var(--muted); margin-left: 6px; }
.list-desc { font-size: 13px; color: var(--muted); }
.list-mail { font-size: 13px; color: var(--muted); }
.list-tel  { font-size: 13px; color: var(--muted); }

/* ── Impression selon la vue active ── */
@media print {
    .toolbar { display: none !important; }

    /* Par défaut (vue grille) : masquer la liste */
    .list-view { display: none !important; }

    /* Vue liste active : masquer la grille, afficher la liste */
    body.print-list .grid      { display: none !important; }
    body.print-list .list-view {
        display: flex !important;
        flex-direction: column;
        gap: 1px;
    }
    body.print-list .list-row {
        padding: 6px 10px;
        border-radius: 4px;
        break-inside: avoid;
    }
    body.print-list .list-sn,
    body.print-list .list-fn   { font-size: 10pt; }
    body.print-list .list-desc,
    body.print-list .list-mail { font-size: 9pt; }
}

/* ── Lien header ── */
.header-link {
    font-size: 14px;
    color: var(--muted);
    text-decoration: none;
    transition: color var(--trans);
}
.header-link:hover { color: var(--accent); }

/* ── Lien Intranet dans le header ── */
.header-intranet {
    font-size: 14px;
    color: var(--muted);
    text-decoration: none;
    transition: color var(--trans);
}
.header-intranet:hover { color: var(--accent); }

/* ── Lien header titre ── */
a.header-title {
    font-size: 15px;
    font-weight: 400;
    color: var(--muted);
    text-decoration: none;
}
a.header-title:hover { color: var(--accent); }

/* ── Recherche globale header ── */
.header-search { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.header-search-wrap {
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--trans), box-shadow var(--trans);
    overflow: hidden;
}
.header-search-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-lt);
}
.header-search-input {
    width: 240px;
    padding: 7px 12px;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    outline: none;
}
.header-search-icon {
    padding: 7px 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    align-items: center;
    transition: color var(--trans);
}
.header-search-icon:hover { color: var(--accent); }
.header-search-hint { font-size: 11px; color: var(--muted); }

/* Réajuster header-count à gauche de la recherche */
.header-count { margin-left: 0; }

/* ── endRole dans modal ── */
.modal-endrole {
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    margin-top: 4px;
}

