/* =========================================================
   Hub Design System — composants partagés
   Chargé après style.css. Le shell (.app/.sidebar/.topbar) est
   global (pas de conflit avec style.css). Les composants partagés
   (.btn, .card, .kpi, .tag, .tabs, .fchip, .search, .page) sont
   scopés .hub-body pour ne pas écraser les styles legacy des
   pages non refondues (mard_guide.html, consulter.html, etc.).
   ========================================================= */

/* ===== APP SHELL (global) ===== */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.main { display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }

/* ===== SIDEBAR (global) ===== */
.sidebar { background: #1C1C1A; color: #CFCDC4; padding: 22px 0 24px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; border-right: 1px solid #000; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 22px 20px; border-bottom: 1px solid #2a2a27; margin-bottom: 14px; flex-shrink: 0; }
/* Zone de navigation défilante : le logo reste en haut, le profil en bas ;
   seules les entrées défilent quand l'écran est trop court pour tout afficher. */
.nav-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.16) transparent; }
.nav-scroll::-webkit-scrollbar { width: 8px; }
.nav-scroll::-webkit-scrollbar-track { background: transparent; }
.nav-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.nav-scroll:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,.28); background-clip: padding-box; }
.nav-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.4); background-clip: padding-box; }
.brand-mark { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 8px; flex-shrink: 0; text-decoration: none; }
.brand-mark img { width: 28px; height: 28px; object-fit: contain; }
.brand-name { font-family: var(--font-display); font-weight: 900; font-size: 16px; color: #fff; letter-spacing: .01em; }
.brand-sub { font-size: 10px; color: #8a8880; letter-spacing: .1em; text-transform: uppercase; margin-top: 2px; }
.sidebar-close { display: none; background: transparent; border: 0; color: #fff; font-size: 28px; line-height: 1; cursor: pointer; padding: 0 4px; margin-left: auto; }

.nav-section { padding: 0 10px; }
.nav-section + .nav-section { margin-top: 18px; }
.nav-title { font-size: 10px; font-weight: 700; letter-spacing: .14em; color: #6d6b63; text-transform: uppercase; padding: 0 12px 8px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 7px; color: #CFCDC4; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all .12s; text-decoration: none; }
.nav-item:hover { background: #2a2a27; color: #fff; }
.nav-item.active { background: #1E327F; color: #fff; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 700; background: rgba(255,255,255,.08); padding: 2px 7px; border-radius: 10px; }
.nav-item.active .nav-count { background: rgba(255,255,255,.18); }

.sidebar-foot { margin-top: auto; padding: 14px 22px 0; border-top: 1px solid #2a2a27; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.me-avatar { width: 34px; height: 34px; border-radius: 50%; background: #1E327F; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; font-family: var(--font-display); flex-shrink: 0; }
.me-name { font-size: 13px; color: #fff; font-weight: 600; }
.me-role { font-size: 11px; color: #8a8880; }
.nav-item-logout { color: #8a8880; padding: 8px; flex-shrink: 0; }
.nav-item-logout:hover { background: #2a2a27; color: #fff; }

/* ===== TOPBAR (global) ===== */
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 0 28px; height: 56px; display: flex; align-items: center; gap: 18px; position: sticky; top: 0; z-index: 15; }
.crumbs { font-size: 13px; color: var(--fg-3); display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumbs a { color: inherit; text-decoration: none; }
.crumbs a:hover { color: var(--fg-1); }
.crumbs .sep { color: var(--line-strong); }
.crumbs .here { color: var(--fg-1); font-weight: 600; }
.topbar-spacer { flex: 1; }
.topbar-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 10px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fg-2); cursor: pointer; transition: all .12s; }
.topbar-btn:hover { border-color: var(--line-strong); background: var(--bg-soft); }
.burger { display: none; width: 40px; height: 40px; border: 1px solid var(--line); background: #fff; border-radius: 8px; align-items: center; justify-content: center; cursor: pointer; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }

/* ===== Composants partagés (scopés .hub-body) =====
   Ces classes (.btn, .card, .kpi, .tag, .tabs, .fchip, .search-wrap, .page)
   peuvent entrer en conflit avec style.css legacy si appliquées partout.
   Scope = pages refondues uniquement (qui ajoutent hub-body au body via
   {% block body_class %}hub-body page-xxx{% endblock %}). */

.hub-body .btn { display: inline-flex; align-items: center; gap: 7px; padding: 0 14px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--fg-1); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all .12s; text-decoration: none; }
.hub-body .btn:hover { background: var(--bg-soft); border-color: var(--line-strong); }
.hub-body .btn-primary { background: #1E327F; color: #fff; border-color: #1E327F; }
.hub-body .btn-primary:hover { background: #172761; border-color: #172761; }
.hub-body .btn-success { background: #3E6B25; color: #fff; border-color: #3E6B25; }
.hub-body .btn-success:hover { background: #2F511C; }
.hub-body .btn-warn { background: #C58B14; color: #fff; border-color: #C58B14; }
.hub-body .btn-warn:hover { background: #A4720B; }
.hub-body .btn-danger { color: #8C1512; border-color: #F3C6C4; background: #fff; }
.hub-body .btn-danger:hover { background: #FCE9E8; border-color: #E2211C; }
.hub-body .btn-ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.hub-body .btn-ghost:hover { background: var(--bg-soft); border-color: var(--line); }
.hub-body .btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.hub-body .btn-icon { width: 36px; height: 36px; padding: 0; }

.hub-body .tag { display: inline-flex; align-items: center; font-family: var(--font-display); font-weight: 700; padding: 3px 9px; border-radius: 4px; font-size: 11.5px; letter-spacing: .03em; white-space: nowrap; }
.hub-body .tag.t-vente { background: #DEE9F6; color: #1E327F; }
.hub-body .tag.t-location { background: #EBE5F7; color: #4C2B8E; }
.hub-body .tag.t-pppt { background: #E5EFEC; color: #2A5B4E; }
.hub-body .tag.t-dtg { background: #DEEBD0; color: #3E6B25; }
.hub-body .tag.t-syndic { background: #DEE9F6; color: #1E327F; }
.hub-body .tag.t-agence { background: #FBE4D4; color: #9C4716; }
.hub-body .tag.t-notaire { background: #EBE5F7; color: #4C2B8E; }
.hub-body .tag.t-bailleur { background: #E5EFEC; color: #2A5B4E; }
.hub-body .tag.t-particulier { background: #EEEDE7; color: #4B4B49; }

.hub-body .fchip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--fg-1); cursor: pointer; font-weight: 600; position: relative; }
.hub-body .fchip:hover { background: #EEEDE7; border-color: var(--line-strong); }
.hub-body .fchip .fc-active { background: #1E327F; color: #fff; padding: 0 7px; border-radius: 999px; font-size: 10.5px; font-weight: 800; line-height: 18px; min-width: 18px; text-align: center; }
.hub-body .fchip.is-open { border-color: #1E327F; }

.hub-body .tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.hub-body .tabs button { background: transparent; border: 0; height: 32px; padding: 0 14px; cursor: pointer; color: var(--fg-2); font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.hub-body .tabs button.is-active { background: #1E327F; color: #fff; }
.hub-body .tabs button:not(.is-active):hover { background: var(--bg-soft); }
.hub-body .tabs button .ct { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: rgba(0,0,0,.08); }
.hub-body .tabs button.is-active .ct { background: rgba(255,255,255,.20); }

.hub-body .search-wrap { flex: 1; max-width: 480px; position: relative; min-width: 240px; }
.hub-body .search-wrap input { width: 100%; height: 40px; padding: 0 16px 0 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); color: var(--fg-1); font-size: 13.5px; outline: none; font-family: inherit; }
.hub-body .search-wrap input:focus { border-color: #1E327F; background: #fff; box-shadow: 0 0 0 3px rgba(30,50,127,.10); }
.hub-body .search-wrap > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--fg-3); }
.hub-body .search-wrap kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 10.5px; padding: 1px 6px; background: #fff; border: 1px solid var(--line); border-radius: 4px; color: var(--fg-3); font-family: var(--font-mono); }

.hub-body .kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(0,0,0,.03); position: relative; overflow: hidden; cursor: pointer; transition: all .14s; }
.hub-body .kpi:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.06); }
.hub-body .kpi-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: #1E327F; }
.hub-body .kpi.k-warn .kpi-accent { background: var(--c-plomb); }
.hub-body .kpi.k-danger .kpi-accent { background: var(--c-amiante); }
.hub-body .kpi.k-good .kpi-accent { background: var(--c-dpe); }
.hub-body .kpi.k-pink .kpi-accent { background: var(--c-erp); }
.hub-body .kpi-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.hub-body .kpi-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--fg-3); }
.hub-body .kpi-icon { width: 30px; height: 30px; border-radius: 8px; background: #F3F2FB; color: #1E327F; display: flex; align-items: center; justify-content: center; }
.hub-body .kpi.k-warn .kpi-icon { background: #FBE4D4; color: #9C4716; }
.hub-body .kpi.k-danger .kpi-icon { background: #F7CFCE; color: #8C1512; }
.hub-body .kpi.k-good .kpi-icon { background: #DEEBD0; color: #3E6B25; }
.hub-body .kpi.k-pink .kpi-icon { background: #FAE1EE; color: #8E2E6A; }
.hub-body .kpi-value { font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1; color: var(--fg-1); letter-spacing: -0.01em; }
.hub-body .kpi-unit { font-size: 14px; color: var(--fg-3); font-weight: 500; margin-left: 2px; }

.hub-body .card { background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.03); margin-bottom: 16px; }
.hub-body .card:last-child { margin-bottom: 0; }
.hub-body .card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.hub-body .card-head h2 { font-family: var(--font-display); font-weight: 700; font-size: 15px; margin: 0; flex: 1; letter-spacing: -0.005em; }
.hub-body .card-link { font-size: 12px; font-weight: 600; color: #1E327F; cursor: pointer; }
.hub-body .card-link:hover { text-decoration: underline; }

.hub-body .page { padding: 22px 28px 48px; max-width: 1480px; width: 100%; margin: 0 auto; }
.hub-body .page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.hub-body .page-head h1 { font-family: var(--font-display); font-weight: 800; font-size: 32px; line-height: 1.1; margin: 0; letter-spacing: -0.01em; }
.hub-body .page-head .sub { font-size: 13.5px; color: var(--fg-3); margin: 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .app { grid-template-columns: 72px 1fr; }
  .brand { justify-content: center; padding: 0 0 18px; }
  .brand-name, .brand-sub, .nav-title, .nav-item span:not(.nav-count) { display: none; }
  .nav-item { justify-content: center; padding: 11px 0; position: relative; }
  .nav-count { position: absolute; top: 4px; right: 8px; font-size: 9px; padding: 1px 5px; margin: 0; }
  .sidebar-foot { padding: 14px 0 0; justify-content: center; }
  .me { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 276px; z-index: 50; transform: translateX(-100%); transition: transform .25s; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { display: block; }
  .sidebar .brand { justify-content: flex-start; padding: 0 22px 20px; }
  .sidebar .brand-name, .sidebar .brand-sub, .sidebar .sidebar-close, .sidebar .nav-title { display: block; }
  .sidebar .nav-item { justify-content: flex-start; padding: 9px 12px; position: static; }
  .sidebar .nav-item span:not(.nav-count) { display: inline; }
  .sidebar .nav-count { position: static; margin-left: auto; font-size: 11px; padding: 2px 7px; }
  .sidebar .me { display: flex; }
  .burger { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .hub-body .page { padding: 16px 16px 40px; }
}

/* ===== Accessibilité ===== */
.skip-nav { position: absolute; left: -9999px; top: 0; }
.skip-nav:focus { left: 8px; top: 8px; z-index: 100; background: #fff; padding: 8px 16px; border-radius: 4px; box-shadow: var(--shadow-2); }
