/* ==========================================================================
   pages.css : tableau de bord, demandes/messages, notifications, réglages
   ========================================================================== */

/* ---------- Tableau de bord ---------- */
.hi { font-size: 24px; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }

.kpi {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
}

.kpi b { font-size: 28px; line-height: 1.1; }
.kpi span { color: var(--mut); font-size: 14px; }
.kpi.is-hot { background: var(--blue-t); border-color: #b9d4f2; }
.kpi.is-hot b, .kpi.is-hot span { color: var(--blue-d); }

a.chip { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; }
.shortcuts { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.hgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.card-head h2 { font-size: 16px; }

.recent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.recent:hover { background: var(--bg); }
.recent small { display: block; color: var(--mut); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
}

.tile b { font-size: 24px; }
.tile span { font-weight: 500; }
.tile small { color: var(--mut); }
.tile em { margin-top: 8px; font-style: normal; font-weight: 500; color: var(--blue); }

/* ---------- Demandes et messages ---------- */
.ihead { display: none; }
.irows { margin: 0; padding: 0; list-style: none; }
.irow { display: grid; grid-template-columns: var(--chk, 0px) minmax(0, 1fr); border-top: 1px solid var(--line); }
.irow.is-current { background: var(--blue-t); }
.irow.is-picked { background: #f0f6fd; }
.irows.is-selecting { --chk: 40px; }
.irow-chk { display: none; align-items: center; justify-content: center; }
.irows.is-selecting .irow-chk { display: flex; }
.irow-chk input { width: 20px; height: 20px; accent-color: var(--blue); }

.irow-btn {
  position: relative;
  grid-column: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "type status" "name status" "meta status";
  column-gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 72px;
  padding: 12px 14px 12px 22px;
  border: 0;
  background: none;
  text-align: left;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.irow-btn:active { background: var(--bg); }

.irow-btn.is-new::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--blue);
}

.c-type { grid-area: type; font-weight: 600; }
.c-name { grid-area: name; overflow-wrap: anywhere; }
.c-meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--mut); }
.c-status { grid-area: status; display: flex; align-items: center; gap: 4px; color: var(--faint); }
.d-long { display: none; }
.c-loc, .c-date { overflow-wrap: anywhere; }

/* Volet de détail : plein écran sur mobile */
.detail {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--card);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .25s ease, visibility 0s .25s;
}

.detail-scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(20, 30, 50, .35);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s;
}

.detail-scrim.is-on { opacity: 1; visibility: visible; }

.detail.is-open { transform: none; visibility: visible; transition: transform .25s ease; }
.detail-head { display: flex; align-items: center; gap: 4px; flex: none; height: 56px; padding: 0 8px 0 4px; border-bottom: 1px solid var(--line); }
.detail-head h2 { font-size: 16px; }
.detail-body { flex: 1; overflow: auto; padding: 16px; overscroll-behavior: contain; }
.detail-empty { display: none; }
.dt { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dt h3 { font-size: 20px; }
.sub { margin-top: 2px; font-size: 13px; color: var(--mut); }
.sec { margin-top: 22px; }
.sec h4 { margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--mut); }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv > :first-child { color: var(--mut); }
.kv > :last-child { text-align: right; overflow-wrap: anywhere; }
.kv a { font-weight: 500; text-decoration: none; }
.msg { padding: 12px 14px; border-radius: var(--radius-s); background: var(--bg); white-space: pre-wrap; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.seg button { min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-s); background: #fff; font-weight: 500; }
.seg [aria-pressed="true"] { border-color: currentColor; }
.seg [data-set="nouvelle"][aria-pressed="true"] { background: var(--blue-t); color: var(--blue); }
.seg [data-set="en_cours"][aria-pressed="true"] { background: var(--amber-t); color: var(--amber); }
.seg [data-set="traitee"][aria-pressed="true"] { background: var(--green-t); color: var(--green); }
.acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.note { display: block; width: 100%; min-height: 76px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); resize: vertical; }
.timeline { margin: 0; padding: 0; list-style: none; font-size: 14px; }
.timeline li { display: flex; gap: 10px; padding-bottom: 12px; }
.timeline li::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--blue); }
.timeline small { display: block; color: var(--mut); }

/* Barre d'actions groupées */
.selbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--navh) + env(safe-area-inset-bottom) + 8px);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 8px 14px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

.selbar span { flex: 1; font-size: 14px; }
.selbar .btn { min-height: 40px; padding: 0 12px; border-color: rgba(255, 255, 255, .3); background: none; color: #fff; font-size: 13px; }

/* ---------- Notifications ---------- */
.nh { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.nbtn { display: flex; flex-wrap: wrap; gap: 8px; }
.nt { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 24px; border-top: 1px solid var(--line); }
.nt:first-child { border-top: 0; }
.nt.is-unread { background: #f5f9fe; }
.nt.is-unread::before { content: ""; position: absolute; left: 9px; top: 22px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.nb { min-width: 0; }
.nb p { margin: 2px 0 4px; overflow-wrap: anywhere; }
.nb small { color: var(--mut); }
.na { display: flex; align-items: center; flex: none; }

/* ---------- Tablette ---------- */
@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .ihead { display: grid; grid-template-columns: var(--chk, 40px) minmax(0, 1fr); background: var(--bg); border-top: 1px solid var(--line); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--mut); }
  .ihead-cols, .irow-btn { display: grid; grid-template-columns: 112px minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, .9fr) 120px; column-gap: 12px; align-items: center; padding: 10px 12px 10px 20px; }
  .irows, .ihead { --chk: 40px; }
  .irow-chk { display: flex; }
  .irow-btn { grid-template-areas: "date type name loc status"; min-height: 64px; }
  .c-meta { display: contents; }
  .c-date { grid-area: date; }
  .c-loc { grid-area: loc; }
  .c-type { font-weight: 400; }
  .c-name { font-weight: 600; }
  .c-sep, .d-short { display: none; }
  .d-long { display: flex; flex-direction: column; }
  .d-long small { color: var(--mut); }
  .c-status .ic { display: none; }
  .irow:hover { background: var(--bg); }
  .irow.is-current { background: var(--blue-t); }

  .detail { width: 460px; box-shadow: var(--shadow); }
  .selbar { left: calc(var(--navw) + 20px); right: 20px; bottom: 20px; max-width: 560px; }
}

@media (min-width: 1024px) {
  .hgrid { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
  .selbar { left: calc(var(--navw) + 24px); }
}

/* ---------- Grand écran : liste et détail côte à côte ---------- */
@media (min-width: 1280px) {
  .split { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }

  .detail {
    position: sticky;
    inset: auto;
    top: 76px;
    z-index: 1;
    width: auto;
    height: calc(100dvh - 100px);
    transform: none;
    visibility: visible;
    transition: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: none;
    overflow: hidden;
  }

  .detail:not(.has-item) .detail-body { display: none; }
  .detail:not(.has-item) .detail-empty { display: grid; flex: 1; place-items: center; padding: 24px; text-align: center; color: var(--mut); }
  .detail-back, .detail-scrim { display: none; }
}

@media (min-width: 1600px) {
  .split { grid-template-columns: minmax(0, 1fr) 460px; }
}
