/* DIGIMAT-TECH – administration */
:root {
    --primary: #3d22e6; --primary-dark: #2a14b8; --primary-soft: #eeebff;
    --green: #148a3c; --green-soft: #e6f5ec; --orange: #f5a52f;
    --red: #c62828; --red-soft: #fdecec;
    --navy: #0b1035; --text: #1d2140; --muted: #6a6f8c;
    --bg: #f4f5fa; --border: #e2e4ee; --radius: 14px;
    --shadow: 0 6px 20px rgba(17, 20, 60, .07);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--navy); line-height: 1.25; margin: 0 0 .8em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.6em; }
img { max-width: 100%; }
.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex-shrink: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45em; padding: .6em 1.1em; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; transition: all .2s; text-decoration: none !important; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: .35em .8em; font-size: .88rem; }
.btn-block { width: 100%; }
.btn-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; transition: all .2s; }
.btn-icon:hover { border-color: var(--primary); color: var(--primary); }
.btn-icon.danger:hover { border-color: var(--red); color: #fff; background: var(--red); }

/* Alertes, pastilles */
.alert { padding: .85rem 1.1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.alert-success { background: var(--green-soft); color: #0d6b2d; }
.alert-error { background: var(--red-soft); color: #a32020; }
.pill { display: inline-block; padding: .15em .7em; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.pill-ok { background: var(--green-soft); color: var(--green); }
.pill-off { background: #eceef4; color: var(--muted); }
.pill-wait { background: #fff4e0; color: #a86400; }

/* Page de connexion / installation */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; background: radial-gradient(circle at 20% 10%, #2a1f8f, var(--navy) 60%); }
.auth-card { width: min(440px, 100%); background: #fff; border-radius: 20px; padding: 2.4rem 2rem; box-shadow: 0 30px 70px rgba(0, 0, 0, .35); }
.auth-logo { display: block; height: 64px; margin: 0 auto 1.2rem; }
.auth-card h1 { text-align: center; font-size: 1.35rem; }
.checklist { list-style: none; padding: 0; margin: 0 0 1.2rem; display: grid; gap: .3rem; font-size: .9rem; }
.checklist li { display: flex; align-items: center; gap: .5rem; }
.checklist .ok { color: var(--green); }
.checklist .ko { color: var(--red); font-weight: 600; }

/* Formulaires */
.form { display: grid; gap: 1rem; }
.form label { display: grid; gap: .35rem; font-weight: 600; font-size: .9rem; color: var(--navy); }
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=number], .form input[type=url], .form input[type=datetime-local], .form input[type=date], .form input[type=time], .form input[type=tel], .form input[type=file], .form select, .form textarea {
    width: 100%; font: inherit; font-weight: 400; color: var(--text); padding: .7em .9em; border: 1.5px solid var(--border); border-radius: 10px; background: #fff; transition: border-color .2s, box-shadow .2s;
}
.form textarea { resize: vertical; }
.form textarea.editor { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; line-height: 1.6; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(61, 34, 230, .12); }
.form label.check { display: flex; align-items: center; gap: .55rem; font-weight: 600; cursor: pointer; }
.form label.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.help { font-weight: 400; color: var(--muted); font-size: .8rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.form-actions form { margin: 0; }
.field-image { display: grid; gap: .5rem; }
.field-image .label { font-weight: 600; font-size: .9rem; color: var(--navy); }
.img-preview { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.img-empty { display: grid; place-items: center; height: 140px; background: var(--bg); color: #b9bccd; }
.img-empty .icon { width: 40px; height: 40px; }

/* Barre d'outils de l'éditeur */
.editor-tools { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: -.2rem; }
.editor-tools button { border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: .3em .7em; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--navy); }
.editor-tools button:hover { border-color: var(--primary); color: var(--primary); }

/* Mise en page admin */
.admin { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.admin-sidebar { position: sticky; top: 0; height: 100vh; background: var(--navy); color: #c3c6e6; display: flex; flex-direction: column; padding: 1.2rem .9rem; overflow-y: auto; }
.admin-brand { display: block; background: #fff; border-radius: 12px; padding: .5rem .8rem; margin-bottom: 1.5rem; }
.admin-brand img { display: block; height: 42px; margin: 0 auto; }
.admin-sidebar nav { display: grid; gap: .2rem; }
.admin-sidebar nav a { display: flex; align-items: center; gap: .75rem; padding: .7rem .85rem; border-radius: 10px; color: #c3c6e6; font-weight: 500; text-decoration: none; transition: background .2s, color .2s; }
.admin-sidebar nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.admin-sidebar nav a.active { background: var(--primary); color: #fff; }
.badge { margin-left: auto; background: var(--orange); color: var(--navy); font-size: .75rem; font-weight: 800; padding: .05em .55em; border-radius: 999px; }
.admin-sidebar-foot { margin-top: auto; padding-top: 1.2rem; border-top: 1px solid rgba(255, 255, 255, .08); display: grid; gap: .2rem; }
.admin-sidebar-foot a, .admin-sidebar-foot button { display: flex; align-items: center; gap: .7rem; padding: .6rem .85rem; color: #c3c6e6; background: none; border: 0; font: inherit; cursor: pointer; border-radius: 10px; text-decoration: none; width: 100%; text-align: left; }
.admin-sidebar-foot a:hover, .admin-sidebar-foot button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.admin-sidebar-foot form { margin: 0; }
.admin-main { min-width: 0; }
.admin-topbar { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 2rem; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.admin-topbar h1 { font-size: 1.3rem; margin: 0; flex: 1; }
.admin-user { color: var(--muted); font-weight: 600; }
.admin-burger { display: none; border: 0; background: var(--bg); width: 40px; height: 40px; border-radius: 10px; cursor: pointer; }
.admin-content { padding: 2rem; max-width: 1300px; }

.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.panel-head h2 { margin: 0; }
.panel.empty { text-align: center; color: var(--muted); padding: 3rem; }
.panel.empty .icon { width: 44px; height: 44px; color: #c8cbe0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.grid-2 .panel { margin: 0; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.toolbar p { margin: 0; max-width: 680px; }
.toolbar form { margin: 0; }

/* Tableau de bord */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2rem; margin-bottom: 1.5rem; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; display: grid; gap: .2rem; color: var(--text); box-shadow: var(--shadow); transition: transform .2s; text-decoration: none !important; }
.stat-card:hover { transform: translateY(-3px); }
.stat-card strong { font-size: 2rem; color: var(--navy); line-height: 1.1; }
.stat-card span:last-child { color: var(--muted); font-size: .9rem; }
.stat-card-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); margin-bottom: .5rem; }
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-list li a { display: grid; grid-template-columns: 1fr auto; gap: 0 1rem; padding: .75rem .6rem; border-radius: 10px; color: var(--text); text-decoration: none; }
.msg-list li a:hover { background: var(--bg); }
.msg-list span { grid-column: 1; color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-list time { grid-row: 1; grid-column: 2; color: var(--muted); font-size: .8rem; }
.msg-list li.unread strong::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--orange); border-radius: 50%; margin-right: .45rem; }
.todo { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: .6rem; }
.todo li { display: flex; gap: .6rem; align-items: flex-start; }
.todo .icon { color: var(--orange); margin-top: .15em; }
.quick-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

/* Tableaux */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .9rem 1rem; border-bottom: 1px solid var(--border); background: #fafbfe; }
.table td { padding: .8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbfe; }
.table .thumb { width: 72px; }
.table .thumb img { width: 56px; height: 42px; object-fit: cover; border-radius: 8px; display: block; }
.thumb-icon { display: grid; place-items: center; width: 56px; height: 42px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.table .actions { display: flex; gap: .4rem; justify-content: flex-end; }
.table .actions form { margin: 0; }
.table-click tr[data-href] { cursor: pointer; }
.table tr.unread td { font-weight: 600; background: #fffaf0; }

/* Vignettes */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.2rem; }
.tiles-wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.tile { position: relative; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tile img, .tile-noimg { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.tile-noimg { display: grid; place-items: center; background: var(--bg); color: #c8cbe0; }
.tile-body { padding: .9rem 1rem 1rem; display: grid; gap: .15rem; }
.tile-body small { color: var(--green); font-weight: 700; text-transform: uppercase; font-size: .72rem; letter-spacing: .06em; }
.tile-actions { position: absolute; top: .6rem; right: .6rem; display: flex; gap: .3rem; }
.tile-actions form { margin: 0; }

/* Édition */
.edit-form { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.5rem; align-items: start; }
.edit-main { display: grid; gap: 1rem; margin: 0; }
.edit-side { display: grid; gap: 1.2rem; position: sticky; top: 90px; }
.edit-side .panel { margin: 0; display: grid; gap: 1rem; }
.edit-side .form-actions { justify-content: flex-end; }

/* Paramètres */
.settings-form { display: block; }
.settings-form .panel { display: grid; gap: .5rem; }
.form-stack { display: grid; gap: 1rem; }
.form-grid-2 { display: grid; grid-template-columns: 160px 1fr; gap: 1rem; }
.sticky-actions { position: sticky; bottom: 0; padding: 1rem 0; background: linear-gradient(transparent, var(--bg) 40%); display: flex; justify-content: flex-end; }

/* Messages */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin: 0 0 1.5rem; }
.meta-grid dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.meta-grid dd { margin: .1rem 0 0; font-weight: 600; }
.message-body { background: var(--bg); border-radius: 10px; padding: 1.3rem; margin-bottom: 1.5rem; white-space: normal; line-height: 1.7; }

/* Comptes */
.user-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.user-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 10px; }
.user-list form { margin: 0; }

/* Responsive */
@media (max-width: 1100px) {
    .stat-cards { grid-template-columns: 1fr 1fr; }
    .edit-form, .grid-2 { grid-template-columns: 1fr; }
    .edit-side { position: static; }
}
@media (max-width: 860px) {
    .admin { grid-template-columns: 1fr; }
    .admin-sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .3s; }
    .sidebar-open .admin-sidebar { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .4); }
    .admin-burger { display: grid; place-items: center; }
    .admin-topbar { padding: .9rem 1rem; }
    .admin-content { padding: 1.2rem 1rem; }
    .form-row, .form-grid-2 { grid-template-columns: 1fr; }
    .admin-user { display: none; }
}
@media (max-width: 520px) {
    .stat-cards { grid-template-columns: 1fr; }
}

/* ==========================================================
   Espace employés et demandes
   ========================================================== */
.espace .admin-sidebar { background: linear-gradient(180deg, #0b1035, #16206b); }
.espace .admin-sidebar nav a.active { background: var(--green); }
.sidebar-label { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--orange); padding: 0 .85rem .6rem; }
.auth-kicker { text-align: center; margin: -.4rem 0 .2rem; font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--green); }
.auth-card .form-row { gap: .8rem; }
.small { font-size: .85rem; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.field-error { color: var(--red); font-weight: 500; font-size: .82rem; }
.has-error input, .has-error select, .has-error textarea { border-color: #d93a3a !important; background: #fff6f6 !important; }
.success-box { text-align: center; padding: .5rem 0 1rem; }
.success-box > .icon { width: 64px; height: 64px; padding: 14px; border-radius: 50%; background: var(--green-soft); color: var(--green); margin-bottom: .6rem; }
.pill-ko { background: var(--red-soft); color: var(--red); }

.stat-cards-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card-icon.wait { background: #fff4e0; color: #a86400; }
.stat-card-icon.ok { background: var(--green-soft); color: var(--green); }
.stat-card-icon.ko { background: var(--red-soft); color: var(--red); }

.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.type-card { display: grid; gap: .35rem; padding: 1.2rem; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--text); text-decoration: none !important; transition: border-color .2s, box-shadow .2s, transform .2s; }
.type-card:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-3px); }
.type-card strong { color: var(--navy); }
.type-card small { color: var(--muted); line-height: 1.4; }
.type-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); margin-bottom: .3rem; }
.type-icon .icon { width: 22px; height: 22px; }
.type-icon.sm { width: 38px; height: 38px; border-radius: 10px; margin: 0; flex-shrink: 0; }
.type-icon.sm .icon { width: 18px; height: 18px; }
.type-intro { display: flex; align-items: center; gap: .8rem; margin: 0 0 .5rem; color: var(--muted); }

.req-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.req-list a { display: flex; align-items: center; gap: .9rem; padding: .7rem .6rem; border-radius: 10px; color: var(--text); text-decoration: none; }
.req-list a:hover { background: var(--bg); }
.req-main { flex: 1; min-width: 0; display: grid; }
.req-main strong { color: var(--navy); }
.req-main small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.req-side { display: grid; justify-items: end; gap: .2rem; }
.req-side time { color: var(--muted); font-size: .8rem; }

.filter-bar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.2rem; }
.filter-bar select { font: inherit; padding: .55em .8em; border: 1.5px solid var(--border); border-radius: 10px; background: #fff; }
.push-right { margin-left: auto; }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tabs a { padding: .65rem 1rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tabs a:hover { color: var(--navy); }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.tabs a span { display: inline-block; min-width: 22px; text-align: center; font-size: .75rem; padding: .05em .45em; border-radius: 999px; background: #eceef4; color: var(--muted); margin-left: .25rem; }
.tabs a.active span { background: var(--primary-soft); color: var(--primary); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field-grid > label { grid-column: 1 / -1; }
.field-grid > label.half { grid-column: auto; }

.req-details { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; margin: 0; }
.req-details > div { min-width: 0; }
.req-details > div.wide { grid-column: 1 / -1; }
.req-details dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.req-details dd { margin: .15rem 0 0; font-weight: 500; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0 0 1rem; padding: 0 0 0 1.2rem; border-left: 2px solid var(--border); display: grid; gap: 1rem; }
.timeline li { position: relative; display: grid; }
.timeline li::before { content: ""; position: absolute; left: calc(-1.2rem - 7px); top: .25em; width: 12px; height: 12px; border-radius: 50%; background: var(--border); border: 2px solid #fff; }
.timeline li.done::before { background: var(--primary); }
.timeline li.current::before { background: var(--orange); box-shadow: 0 0 0 4px #fff4e0; }
.timeline li.ok::before { background: var(--green); }
.timeline li.ko::before { background: var(--red); }
.timeline span { color: var(--muted); font-size: .85rem; }
.comment { background: var(--bg); border-left: 3px solid var(--primary); border-radius: 8px; padding: .8rem 1rem; }
.comment p { margin: .3rem 0 0; }
.who { margin: 0 0 .6rem; line-height: 1.5; }
.form-actions.stack { display: grid; gap: .5rem; }
.form-actions.stack form, .form-actions.stack .btn { width: 100%; }
.file-line { display: flex; gap: .5rem; align-items: center; margin: 0; font-size: .9rem; }

.files { display: grid; gap: .6rem; }
.file-item { display: flex; align-items: center; gap: .8rem; padding: .5rem; border: 1px solid var(--border); border-radius: 10px; }
.file-thumb { display: grid; place-items: center; width: 64px; height: 48px; border-radius: 8px; overflow: hidden; background: var(--bg); color: var(--muted); flex-shrink: 0; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-meta { flex: 1; min-width: 0; display: grid; }
.file-meta a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-item form { margin: 0; }
.temp-pass code { font-size: 1.2rem; font-weight: 800; letter-spacing: .08em; background: #fff; padding: .15em .5em; border-radius: 6px; user-select: all; }

@media (max-width: 860px) {
    .stat-cards-3 { grid-template-columns: 1fr; }
    .field-grid, .req-details { grid-template-columns: 1fr; }
    .push-right { margin-left: 0; }
}
