/* =========================================================================
   SD Consulting v2 — feuille de styles
   ========================================================================= */
:root {
    --navy:   #06162f;
    --navy-2: #0d2a57;
    --gold:   #f6ba00;
    --gold-d: #d99f00;
    --ink:    #1d2733;
    --muted:  #6b7685;
    --line:   #e7eaf0;
    --bg:     #eef1f6;
    --card:   #ffffff;
    --ok:     #1f9d57;
    --err:    #c0392b;
    --shadow: 0 1px 3px rgba(10,25,55,.08), 0 6px 24px rgba(10,25,55,.06);
    --radius: 12px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand, .topbar__brand {
    font-family: "Poppins", "Inter", "Segoe UI", sans-serif;
}

a { color: #1c5fd6; }

/* =========================================================================
   Pages publiques (connexion)
   ========================================================================= */
body.guest {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #06162f 0%, #0d2a57 60%, #143a73 100%);
    padding: 20px;
}
.guest__card {
    width: 380px;
    max-width: 100%;
    background: rgba(255,255,255,.04);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,.12);
    color: #fff;
    border-radius: 16px;
    padding: 34px 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.brand {
    text-align: center;
    color: var(--gold);
    font-size: 30px;
    font-weight: 700;
    letter-spacing: .5px;
    margin: 0 0 6px;
}
.guest__card::after {
    content: "Suivi de projet";
    display: block;
    text-align: center;
    color: rgba(255,255,255,.55);
    font-size: 12px;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin: -2px 0 22px;
}

/* =========================================================================
   Formulaires & boutons
   ========================================================================= */
.form__intro { color: #cfd8e3; font-size: 13px; margin-top: 0; }
.form__label { display: block; margin: 16px 0 5px; font-weight: 600; font-size: 13px; }
.form__input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #2a3b57;
    border-radius: 9px;
    font-size: 14px;
    background: rgba(255,255,255,.95);
    color: var(--ink);
}
.form__input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.form__check { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; font-size: 13px; color: #cfd8e3; }
.form__links { margin-top: 18px; font-size: 13px; text-align: center; }
.form__links a { color: var(--gold); text-decoration: none; }
.form__links a:hover { text-decoration: underline; }

.btn {
    width: 100%;
    margin-top: 22px;
    padding: 12px 20px;
    border: none;
    border-radius: 9px;
    background: var(--gold);
    color: #1a1300;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, transform .05s;
}
.btn:hover { background: var(--gold-d); }
.btn:active { transform: translateY(1px); }
.btn--inline { width: auto; margin-top: 0; padding: 9px 18px; }

/* =========================================================================
   Messages flash
   ========================================================================= */
.flash { padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 13px; font-weight: 500; }
.flash--success { background: #e6f6ec; color: #156c3b; border: 1px solid #b6e3c6; }
.flash--error   { background: #fdecea; color: #97271b; border: 1px solid #f3c2bc; }
body.guest .flash--success { background: rgba(31,157,87,.2); color: #c9f3d8; border-color: transparent; }
body.guest .flash--error   { background: rgba(192,57,43,.25); color: #ffd2cc; border-color: transparent; }

/* =========================================================================
   Coquille de l'application connectée
   ========================================================================= */
body.app { background: var(--bg); }

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(90deg, var(--navy) 0%, var(--navy-2) 100%);
    color: #e8edf5;
    padding: 0 22px;
    height: 60px;
    box-shadow: 0 2px 10px rgba(6,22,47,.25);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar__brand { color: var(--gold); font-weight: 700; font-size: 19px; letter-spacing: .3px; }
.topbar__spacer { flex: 1; }
.topbar__project { font-weight: 600; color: #fff; }
.topbar__projects select {
    background: rgba(255,255,255,.08);
    color: #fff;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    max-width: 320px;
}
.topbar__projects select option { color: #1d2733; }
.topbar__user {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 600;
    color: #fff;
}
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--navy);
    font-weight: 700;
    font-size: 12px;
    flex: none;
}
.topbar__logout button {
    background: transparent;
    color: var(--gold);
    border: 1px solid rgba(246,186,0,.5);
    border-radius: 9px;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
}
.topbar__logout button:hover { background: rgba(246,186,0,.12); }
.topbar__admin { color: #cfe0ff; text-decoration: none; font-weight: 600; font-size: 13px; padding: 6px 10px; border-radius: 8px; }
.topbar__admin:hover { background: rgba(255,255,255,.1); }

/* --- Back-office admin --------------------------------------------------- */
.admin-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.admin-inline .field__input { width: auto; min-width: 200px; }
.admin-client { border-left: 3px solid var(--gold); }
.admin-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.admin-table th, .admin-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.admin-muted { color: var(--muted); font-size: 13px; }
.admin-subtitle { margin: 18px 0 6px; color: var(--navy); font-size: 15px; }
.admin-actions { display: flex; gap: 12px; align-items: center; }
.admin-actions a, .link-action { font-size: 13px; color: #1c5fd6; text-decoration: none; background: none; border: none; cursor: pointer; padding: 0; }
.admin-actions a:hover, .link-action:hover { text-decoration: underline; }
.admin-flag { color: #b9690a; font-size: 12px; }

.content { max-width: 1180px; margin: 26px auto; padding: 0 22px; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 20px; }
.panel__title { margin: 0 0 4px; color: var(--navy); font-size: 22px; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

/* --- Boutons secondaires / actions --------------------------------------- */
.btn-sm {
    display: inline-block; padding: 7px 14px; border-radius: 8px;
    background: var(--navy); color: #fff; border: none; cursor: pointer;
    font-size: 13px; font-weight: 600; text-decoration: none;
}
.btn-sm:hover { background: var(--navy-2); }
.btn-sm--danger { background: #fff; color: var(--err); border: 1px solid #e6b3ad; }
.btn-sm--danger:hover { background: #fdecea; }
.btn-sm--ghost { background: #fff; color: var(--muted); border: 1px solid var(--line); }
.btn-sm--ghost:hover { background: #f1f3f8; }

/* --- Modale (liens fichiers réseau, etc.) -------------------------------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(6,22,47,.55);
    display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal {
    background: #fff; border-radius: 14px; padding: 24px; width: 520px; max-width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.modal__title { margin: 0 0 10px; color: var(--navy); font-size: 18px; }
.modal__text { color: #44506a; font-size: 14px; line-height: 1.5; margin: 0 0 14px; }
.modal__path {
    width: 100%; padding: 10px 12px; border: 1px solid #d3d9e3; border-radius: 8px;
    font-family: monospace; font-size: 13px; background: #f7f9fc; margin-bottom: 14px;
}
.modal__actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.modal__actions .btn { width: auto; margin-top: 0; }
.modal__hint { color: #156c3b; font-size: 13px; min-height: 18px; margin: 10px 0 0; }
.inline-form { display: inline; }
.link-danger { background: none; border: none; color: var(--err); cursor: pointer; font-size: 12px; padding: 0; }
.link-danger:hover { text-decoration: underline; }

/* --- Formulaires de l'app ------------------------------------------------ */
.field { display: block; margin-bottom: 18px; }
.field__label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--navy); }
.field__input {
    width: 100%; padding: 10px 12px; border: 1px solid #d3d9e3;
    border-radius: 9px; font-size: 14px; font-family: inherit; background: #fff;
}
.field__input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.field-row { display: flex; gap: 18px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 180px; }

/* --- Éditeur de texte riche ---------------------------------------------- */
.editor { border: 1px solid #d3d9e3; border-radius: 9px; overflow: hidden; background: #fff; }
.editor__toolbar {
    display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
    padding: 6px 8px; background: #f4f6fa; border-bottom: 1px solid #e3e7ee;
}
.editor__toolbar button {
    min-width: 32px; height: 30px; padding: 0 9px; border: 1px solid #d7dce5;
    background: #fff; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--ink);
}
.editor__toolbar button:hover { background: #eef1f6; }
.editor__sep { width: 1px; height: 20px; background: #d7dce5; margin: 0 4px; }
.editor__area {
    min-height: 160px; padding: 12px 14px; outline: none; font-size: 14px;
}
.editor__area:focus { box-shadow: inset 0 0 0 2px rgba(246,186,0,.4); }
.editor__hint { font-size: 12px; color: var(--muted); margin: 6px 0 18px; }

/* Actions dans l'en-tête d'un sujet */
.ticket-head__actions { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }
.comment__meta { display: inline-flex; align-items: center; gap: 12px; }
.comment__action { font-size: 12px; color: #1c5fd6; text-decoration: none; }
.comment__action:hover { text-decoration: underline; }

/* =========================================================================
   Barre d'outils de la liste
   ========================================================================= */
.ticket-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 18px 0 6px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}
.ticket-search {
    padding: 10px 12px;
    border: 1px solid #d3d9e3;
    border-radius: 9px;
    width: 300px;
    max-width: 60vw;
    font-size: 14px;
}
.ticket-search:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.ticket-closed { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.ticket-clear { font-size: 12px; color: var(--err); text-decoration: none; }

/* --- Filtres (pastilles cliquables) ------------------------------------- */
.filters { margin: 16px 0 8px; }
.filters__row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters__spacer { flex: 1; }
.ticket-reset { font-size: 12px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.ticket-reset:hover { color: var(--navy); text-decoration: underline; }
.ticket-result { color: var(--muted); font-size: 13px; margin: 4px 0 8px; }

.chip {
    display: inline-block;
    padding: 5px 13px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: opacity .12s, background .12s;
    user-select: none;
}
.chip--off {
    background: #f1f3f8 !important;
    color: #9aa3b2 !important;
    border-color: #e2e6ee;
}
.chip--off:hover { color: #5b6675 !important; }
.chip--unread { border: 1px solid #c9a3e8; color: #7b2cbf; background: #f6edfd; }
.chip--unread-on { background: #7b2cbf; color: #fff; border-color: #7b2cbf; }

/* =========================================================================
   Tableau des sujets
   ========================================================================= */
.ticket-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.ticket-table th, .ticket-table td { padding: 12px 12px; text-align: left; vertical-align: middle; }
.ticket-table thead th {
    font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
    color: var(--muted); border-bottom: 2px solid var(--line); font-weight: 600;
}
.ticket-table th a { color: var(--muted); text-decoration: none; }
.ticket-table th a:hover { color: var(--navy); }
.ticket-table tbody tr { border-bottom: 1px solid var(--line); transition: background .1s; }
.ticket-table tbody tr:hover { background: #f6f9fe; }
.ticket-table tbody tr[data-href] { cursor: pointer; }
.ticket-row--unread { background: #fffaf0; }
.ticket-row--unread .ticket-link { font-weight: 700; }
.ticket-link { color: var(--navy); text-decoration: none; font-weight: 500; }
.ticket-link:hover { color: #1c5fd6; }
.ticket-count {
    text-align: center; color: var(--muted); font-variant-numeric: tabular-nums;
}
.ticket-empty { color: var(--muted); font-style: italic; padding: 10px 0; }

.badge {
    display: inline-block; padding: 4px 11px; border-radius: 999px;
    font-size: 11.5px; font-weight: 700; white-space: nowrap;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.05);
}
.dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--gold); margin-right: 7px; vertical-align: middle;
    box-shadow: 0 0 0 3px rgba(246,186,0,.2);
}

/* Impact (pastille colorée) */
.impact { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.impact--1 { background: #eef1f6; color: #5b6675; }
.impact--2 { background: #e3f0ff; color: #1c5fd6; }
.impact--3 { background: #fff0db; color: #b9690a; }
.impact--4 { background: #fde3e0; color: #c0392b; }

/* Dossiers */
.folder-tag {
    display: inline-block; padding: 3px 10px; border-radius: 7px;
    background: #eef1f6; color: #44506a; font-size: 12px; font-weight: 600;
    text-decoration: none; border: 1px solid #e2e6ee; white-space: nowrap;
}
.folder-tag:hover { background: #e2e8f3; }
.folder-filter {
    padding: 9px 10px; border: 1px solid #d3d9e3; border-radius: 9px;
    font-size: 14px; background: #fff; cursor: pointer; max-width: 220px;
}

/* =========================================================================
   Détail d'un sujet
   ========================================================================= */
.ticket-back { display: inline-block; margin-bottom: 16px; color: #1c5fd6; text-decoration: none; font-weight: 500; }
.ticket-back:hover { text-decoration: underline; }
.ticket-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ticket-meta { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.ticket-body { padding-top: 16px; border-top: 1px solid var(--line); }
.ticket-comments-title { margin: 0 0 18px; color: var(--navy); font-size: 17px; }

.comment {
    display: flex; gap: 14px;
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; margin-bottom: 14px; background: #fbfcfe;
}
.comment__avatar { margin-top: 2px; }
.comment__main { flex: 1; min-width: 0; }
.comment__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.comment__author { font-weight: 700; color: var(--navy); }
.comment__date { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* =========================================================================
   Pièces jointes
   ========================================================================= */
.attachments { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.attachment { display: inline-flex; text-decoration: none; }
.attachment--img img {
    max-width: 160px; max-height: 160px; border-radius: 8px;
    border: 1px solid var(--line); box-shadow: var(--shadow); object-fit: cover; background: #fff;
}
.attachment--img img:hover { box-shadow: 0 4px 14px rgba(10,25,55,.18); }
.attachment--file {
    align-items: center; gap: 8px; padding: 9px 14px; border: 1px solid var(--line);
    border-radius: 9px; background: #f7f9fc; color: var(--navy); font-weight: 500;
}
.attachment--file:hover { background: #eef3fb; }
.attachment__icon { font-size: 16px; }

.file-input { display: block; margin-top: 4px; font-size: 13px; }
.field__hint { display: block; font-size: 12px; color: var(--muted); margin-top: 5px; }
.att-edit { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; }
.att-edit__item {
    display: flex; flex-direction: column; gap: 6px; align-items: center;
    padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: #fafbfd; font-size: 12px;
}
.att-edit__item img { max-width: 90px; max-height: 90px; border-radius: 6px; object-fit: cover; }
.att-edit__file { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-edit__del { color: var(--err); display: inline-flex; align-items: center; gap: 4px; }

/* =========================================================================
   Section Notifications (formulaires)
   ========================================================================= */
.notify { margin: 18px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 9px; background: #fafbfd; }
.notify__toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--navy); }
.notify__details { margin-top: 10px; }
.notify__details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.notify__list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; padding-left: 6px; }
.notify__item { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.notify__role { color: var(--muted); font-size: 12px; }
.notify__none { margin: 0; color: var(--muted); font-size: 13px; font-style: italic; }

/* Choix des personnes concernées (formulaire sujet) */
.concerned__radio { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; font-size: 14px; }
.concerned__radio span { line-height: 1.35; }
.concerned__list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 0 6px; }
.concerned__item { display: flex; align-items: center; gap: 8px; font-size: 14px; }

/* Encart « personnes concernées » sur le détail */
.concerned-box {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
    margin-top: 16px; padding: 12px 14px; border: 1px dashed var(--line);
    border-radius: 9px; background: #fafbfd; font-size: 13px;
}
.concerned-box__label { color: var(--muted); font-weight: 600; }
.concerned-box__people { display: flex; flex-wrap: wrap; gap: 6px; }
.concerned-box__people--empty { color: var(--muted); font-style: italic; }
.concerned-box__chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px 3px 3px; background: #fff; border: 1px solid var(--line);
    border-radius: 999px;
}
.concerned-box__edit { margin-left: auto; color: #1c5fd6; text-decoration: none; font-weight: 600; }
.concerned-box__edit:hover { text-decoration: underline; }
.avatar--sm { width: 22px; height: 22px; font-size: 10px; }

/* =========================================================================
   Contenu riche (HTML assaini)
   ========================================================================= */
.rich { line-height: 1.55; word-wrap: break-word; overflow-wrap: anywhere; color: #2b3543; }
.rich img { max-width: 100%; height: auto; border-radius: 6px; }
.rich table { border-collapse: collapse; }
.rich td, .rich th { border: 1px solid #dde2ea; padding: 5px 9px; }
.rich a { color: #1c5fd6; }
.rich p:first-child { margin-top: 0; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 720px) {
    .topbar { padding: 0 14px; gap: 10px; }
    .topbar__user span.name { display: none; }
    .content { padding: 0 12px; margin: 16px auto; }
    .panel { padding: 18px; }
    .ticket-table thead { display: none; }
    .ticket-table, .ticket-table tbody, .ticket-table tr, .ticket-table td { display: block; width: 100%; }
    .ticket-table tr { padding: 10px 0; }
    .ticket-table td { padding: 4px 0; }
    .ticket-count { text-align: left; }
}
