/* Surcharges Pico.css + gabarit responsive (charte : doc/ecrans.md). */

:root[data-theme="light"] {
  --wpm-bg: #f6f5f2;
  --wpm-surface: #ffffff;
  --wpm-border: #e3e1db;
  --wpm-text: #1c1b19;
  --wpm-muted: #5b5953;
  --wpm-accent: #2f4fa8;
  --wpm-sidebar: #1c1b19;
  --wpm-radius: 10px;
  --pico-font-family-sans-serif: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pico-font-family-monospace: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --pico-background-color: var(--wpm-bg);
  --pico-color: var(--wpm-text);
  --pico-muted-color: var(--wpm-muted);
  --pico-primary: var(--wpm-accent);
  --pico-primary-background: var(--wpm-accent);
  --pico-primary-border: var(--wpm-accent);
  --pico-primary-hover: #24408c;
  --pico-primary-hover-background: #24408c;
  --pico-primary-hover-border: #24408c;
  --pico-primary-focus: rgba(47, 79, 168, 0.35);
  --pico-border-radius: var(--wpm-radius);
  --pico-font-size: 100%;
  --pico-spacing: 1rem;
  --pico-form-element-spacing-vertical: 0.6rem;
}

html { scroll-behavior: smooth; }
body { margin: 0; background: var(--wpm-bg); }

.mono, code, pre { font-family: var(--pico-font-family-monospace); }
.mono { font-size: 0.92em; word-break: break-all; }
.small { font-size: 0.8em; }
.muted { color: var(--wpm-muted); }
.visually-hidden, .nav-toggle {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; background: #fff; padding: 0.75rem 1rem; }
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

:focus-visible { outline: 3px solid var(--wpm-accent); outline-offset: 2px; }

/* Boutons et zones tactiles ≥ 44 px */
button, [role="button"], input[type="submit"], select, input:not([type="checkbox"], [type="radio"]) {
  min-height: 44px;
}
input[type="checkbox"], input[type="radio"] { width: 1.35rem; height: 1.35rem; }
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { min-height: 44px; display: flex; align-items: center; gap: 0.5rem; }

/* --- Gabarit ------------------------------------------------------------------ */

.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.topbar { display: none; }
.nav-backdrop { display: none; }

.sidebar {
  background: var(--wpm-sidebar); color: #e8e6e1; padding: 1rem 0.75rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem;
}
.sidebar a { color: #e8e6e1; text-decoration: none; }
.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; padding: 0.25rem 0.5rem; color: #fff; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list li { list-style: none; margin: 0; padding: 0; }
.nav-link {
  display: flex; align-items: center; gap: 0.6rem; min-height: 44px; padding: 0.4rem 0.6rem;
  border-radius: 8px; color: #e8e6e1;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.08); }
.nav-link.active { background: var(--wpm-accent); color: #fff; }
.nav-soon { opacity: 0.45; cursor: default; }
.nav-soon small { font-size: 0.7em; margin-left: 0.3rem; }
.nav-icon { width: 1.5rem; text-align: center; flex: none; }
.nav-section { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: #a19e97; margin: 0 0.6rem 0.3rem; }

/* Liens rapides : dock façon macOS (tuiles, grossissement au survol/focus). Sélecteurs à deux
   classes pour passer devant « nav ul:first-of-type » et « nav li » de Pico. */
.sidebar .dock {
  display: block; padding: 0.5rem; border-radius: 16px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 16px rgba(0, 0, 0, 0.25);
}
.dock .dock-title { margin: 0 0.25rem 0.4rem; }
.dock .dock-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(3.5rem, 1fr)); gap: 0.25rem;
  list-style: none; margin: 0; padding: 0;
}
.dock .dock-item { display: block; list-style: none; margin: 0; padding: 0; min-width: 0; }
.dock .dock-link {
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem; margin: 0;
  min-width: 44px; min-height: 44px; padding: 0.25rem 0.15rem; border-radius: 10px; color: #e8e6e1; text-align: center;
}
.dock-tile {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(#f7f6f2, #dcdad3); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transform-origin: bottom center; transition: transform 0.15s ease;
}
.dock-favicon { width: 24px; height: 24px; object-fit: contain; }
.dock-fallback { color: var(--wpm-sidebar); font-size: 1.2rem; line-height: 1; }
.dock-label { max-width: 100%; font-size: 0.7rem; line-height: 1.2; color: #c9c6bf; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock .dock-link:hover .dock-tile, .dock .dock-link:focus-visible .dock-tile { transform: translateY(-3px) scale(1.12); }
.dock .dock-link:hover .dock-label, .dock .dock-link:focus-visible .dock-label { color: #fff; }
.dock .dock-link:focus-visible { outline: 3px solid #9fb3ea; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .dock-tile { transition: none; }
  .dock .dock-link:hover .dock-tile, .dock .dock-link:focus-visible .dock-tile { transform: none; }
}
.user-box { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.6rem; border-top: 1px solid #3a3935; }
.user-box .nav-label { display: flex; flex-direction: column; font-size: 0.85rem; }
.user-box small { color: #a19e97; }
.user-box a { text-decoration: underline; }
.user-box form { margin: 0; width: 100%; }
.logout { width: 100%; margin: 0; color: #e8e6e1; border-color: #5b5953; }

.content { padding: 1.5rem 2rem 3rem; min-width: 0; }

.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.page-header h1 { margin: 0; font-size: 1.6rem; }
.overline { margin: 0 0 0.25rem; font-size: 0.85rem; color: var(--wpm-muted); }
.page-actions, .inline-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.page-actions form, .inline-actions form { margin: 0; }
.page-actions button, .page-actions [role="button"], .inline-actions button { margin: 0; width: auto; }

.panel {
  background: var(--wpm-surface); border: 1px solid var(--wpm-border); border-radius: var(--wpm-radius);
  padding: 1.25rem; margin-bottom: 1.25rem;
}
.panel h2 { font-size: 1.15rem; margin-bottom: 0.75rem; }
.panel-highlight { border-color: var(--wpm-accent); }
.two-columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.25rem; align-items: start; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--wpm-surface); border: 1px solid var(--wpm-border); border-radius: var(--wpm-radius); padding: 1rem; margin: 0; box-shadow: none; }
.stat p { margin: 0; }
.stat-label { color: var(--wpm-muted); font-size: 0.85rem; }
.stat-value { font-size: 1.8rem; font-weight: 600; }
.stat-note { font-size: 0.8rem; color: var(--wpm-muted); }

/* Notifications */
.notifications:empty { display: none; }
.notice { padding: 0.75rem 1rem; border-radius: 8px; margin: 0 0 1rem; border: 1px solid transparent; }
.notice-ok { background: #e3f2ea; color: #17603c; }
.notice-info { background: #e6ecfa; color: #27428f; }
.notice-error { background: #fbe7e5; color: #9b1c12; }

/* Pastilles de statut (libellé toujours présent) */
.badge {
  display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.8rem;
  font-weight: 500; line-height: 1.5; white-space: nowrap; border: 1px solid transparent;
}
.badge-ok { background: #e3f2ea; color: #17603c; }
.badge-running { background: #e6ecfa; color: #27428f; }
.badge-warn { background: #fbeedd; color: #8a4608; }
.badge-fail { background: #fbe7e5; color: #9b1c12; }
.badge-neutral { background: #eeece7; color: #4a4843; }
.badge-planned { background: #fff; color: #4a4843; border: 1px dashed #8e8a81; }

/* Bandeau nouvelle installation */
.banner {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem;
  background: #e6ecfa; color: #1c2c5c; border: 1px solid #c6d2f0; border-radius: var(--wpm-radius);
  padding: 0.75rem 1rem; margin-bottom: 0.75rem;
}
.banner p { margin: 0; }
.banner form { margin: 0; }

.callout {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid #c6d2f0;
  border-radius: var(--wpm-radius);
  background: #f3f6fd;
}
.callout h3 { margin-top: 0; font-size: 1rem; }
.callout ol { margin-bottom: 0.5rem; }
.callout > :last-child { margin-bottom: 0; }
.compact-table { margin: 0.75rem 0; }
.compact-table th, .compact-table td { padding: 0.45rem 0.65rem; }

.scan-status { margin: 0 0 1rem; }

/* Filtres */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.filter {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem; border-radius: 999px;
  border: 1px solid var(--wpm-border); background: var(--wpm-surface); text-decoration: none; color: var(--wpm-text);
}
.filter.active { background: var(--wpm-accent); border-color: var(--wpm-accent); color: #fff; }
.form-end { display: flex; align-items: flex-end; }

/* Tableaux */
table { background: var(--wpm-surface); border-radius: var(--wpm-radius); overflow: hidden; }
th { font-size: 0.85rem; color: var(--wpm-muted); }
tr.untracked td { color: var(--wpm-muted); background: #faf9f7; }
tr.anomaly td:first-child { box-shadow: inset 4px 0 0 #9b1c12; }

/* Chronologie */
.timeline { list-style: none; padding: 0; margin: 1rem 0 0; }
.timeline-item { list-style: none; border-left: 3px solid var(--wpm-border); padding: 0 0 1rem 1rem; margin: 0; }
.timeline-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-size: 0.85rem; color: var(--wpm-muted); }
.timeline-body { margin: 0.35rem 0 0; white-space: pre-line; }
.action-form summary { display: inline-flex; align-items: center; }
.action-form form { margin-top: 1rem; }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.4rem 1rem; margin: 0; }
.facts dt { color: var(--wpm-muted); font-weight: 400; }
.facts dd { margin: 0; }

/* Réglages */
.settings-layout { display: grid; grid-template-columns: 13rem minmax(0, 60rem); gap: 1.5rem; align-items: start; }
/* Neutralise le « nav, nav ul { display: flex } » de Pico : liste verticale dans sa colonne. */
.subnav { display: block; position: sticky; top: 1.5rem; }
.subnav ul { display: flex; flex-direction: column; align-items: stretch; gap: 0.25rem; list-style: none; padding: 0; margin: 0; }
.subnav li { display: block; list-style: none; margin: 0; padding: 0; }
.subnav a {
  display: flex; align-items: center; min-height: 44px; margin: 0; padding: 0.5rem 0.75rem; border-radius: 8px;
  text-decoration: none; color: var(--wpm-text); line-height: 1.3; text-align: left;
}
.subnav a:hover { background: #eeece7; }
.subnav a.active { background: var(--wpm-accent); color: #fff; font-weight: 500; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0; }
.inline-form input { flex: 1 1 8rem; min-width: 0; margin: 0; }
.inline-form button { flex: none; margin: 0; width: auto; }
.secrets-table { table-layout: fixed; width: 100%; }
.secrets-table th { white-space: nowrap; }
.secrets-table .col-value { width: 8rem; }
.secrets-table .col-date { width: 8.5rem; white-space: nowrap; }
.secrets-table .col-replace { width: 21rem; }
.link-row { display: grid; grid-template-columns: 1fr 2fr 6rem; gap: 0 0.75rem; border-bottom: 1px solid var(--wpm-border); padding-bottom: 0.75rem; margin-bottom: 0.75rem; }
.link-row > label, .link-row > .inline-actions { grid-column: 1 / -1; }
.log { max-height: 20rem; overflow: auto; font-size: 0.8rem; white-space: pre-wrap; }
.pagination { display: flex; justify-content: space-between; gap: 1rem; }
.qr img { background: #fff; padding: 0.5rem; border: 1px solid var(--wpm-border); border-radius: 8px; }

/* Pages publiques (connexion) */
.public-main { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.public-card { width: min(440px, 100%); margin: 0; }
.public-card h1 { font-size: 1.5rem; margin: 0; }

/* --- Tablette : menu réduit aux icônes -------------------------------------------- */
@media (max-width: 1023px) {
  .layout { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding: 1rem 0.5rem; align-items: center; }
  .sidebar .nav-label, .nav-section { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav-link { justify-content: center; padding: 0.4rem; width: 48px; }
  /* Dock vertical centré ; libellés masqués visuellement, nom porté par aria-label/title. */
  .sidebar .dock { padding: 0.25rem; border-radius: 14px; }
  .dock .dock-list { grid-template-columns: 44px; justify-content: center; }
  .dock .dock-link { padding: 0; }
  .user-box { justify-content: center; padding: 0.4rem 0; }
  .logout { padding: 0.4rem; }
  .content { padding: 1.25rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-columns { grid-template-columns: minmax(0, 1fr); }
  .col-secondary { display: none; }
}

/* --- Réglages : onglets horizontaux dès que la place manque pour deux colonnes ----- */
@media (max-width: 1199px) {
  .settings-layout { grid-template-columns: minmax(0, 60rem); gap: 1rem; }
  .subnav { position: static; border-bottom: 1px solid var(--wpm-border); padding-bottom: 0.5rem; }
  .subnav ul { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .subnav a { white-space: nowrap; }
  .secrets-table .col-replace { width: 18.5rem; }
}

/* --- Mobile : menu en tiroir, tableaux en cartes, boutons pleine largeur ----------- */
@media (max-width: 639px) {
  .layout { display: block; }
  .topbar {
    display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 20;
    background: var(--wpm-sidebar); color: #fff; padding: 0 0.75rem; min-height: 56px;
  }
  .topbar-title { font-weight: 600; }
  .nav-button { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 44px; padding: 0 0.75rem; border: 1px solid #5b5953; border-radius: 8px; cursor: pointer; margin: 0; color: #fff; }
  .nav-toggle:focus-visible ~ .topbar .nav-button { outline: 3px solid #9fb3ea; outline-offset: 2px; }
  .sidebar {
    position: fixed; z-index: 30; top: 0; left: 0; bottom: 0; width: min(300px, 85vw); height: 100vh;
    transform: translateX(-100%); transition: transform 0.2s ease; align-items: stretch; padding: 1rem 0.75rem;
  }
  .sidebar .nav-label, .nav-section { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
  .nav-link { justify-content: flex-start; width: auto; padding: 0.4rem 0.6rem; }
  /* Tiroir : dock en grille qui passe à la ligne, libellés visibles sur une ligne. */
  .sidebar .dock { padding: 0.5rem; }
  .dock .dock-list { grid-template-columns: repeat(auto-fill, minmax(4rem, 1fr)); justify-content: stretch; }
  .dock .dock-link { padding: 0.25rem 0.15rem; }
  .sidebar .dock-label { white-space: nowrap; }
  .nav-toggle:checked ~ .layout .sidebar { transform: translateX(0); }
  .nav-toggle:checked ~ .layout .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.45); }
  .content { padding: 1rem; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .page-header { align-items: stretch; flex-direction: column; }
  .page-actions, .inline-actions, .page-actions form, .inline-actions form { width: 100%; }
  button, [role="button"], .page-actions button, .page-actions [role="button"], .inline-actions button { width: 100%; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input { flex: none; width: 100%; }
  .inline-form button { width: 100%; }
  .link-row { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .facts dd { margin-bottom: 0.5rem; }

  table.table-cards, .table-cards thead, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards { background: transparent; }
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-cards tr { background: var(--wpm-surface); border: 1px solid var(--wpm-border); border-radius: var(--wpm-radius); margin-bottom: 0.75rem; padding: 0.5rem 0.75rem; }
  .table-cards td { background: transparent; display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0.5rem; align-items: center; border: 0; padding: 0.35rem 0; }
  .table-cards td::before { content: attr(data-label); font-size: 0.8rem; color: var(--wpm-muted); }
  .table-cards .col-secondary { display: grid; }
  .secrets-table { table-layout: auto; }
  .secrets-table td.col-replace { grid-template-columns: minmax(0, 1fr); }
  .secrets-table .col-value, .secrets-table .col-date, .secrets-table .col-replace { width: 100%; }
  tr.anomaly td:first-child { box-shadow: none; }
  tr.anomaly { border-left: 4px solid #9b1c12; }
}
