/* ==========================================================================
   HydSmPro 2026 — ux-enhancements.css
   Audit V2 + V3 (2026-04-27) — Améliorations UX non-invasives
   --------------------------------------------------------------------------
   Charge UNIQUEMENT après tokens.css (cascade).
   ========================================================================== */

/* ============================================================
   V2.3 — Layout fluid : exploiter les écrans larges (≥1600 px)
   ============================================================ */
body > .app,
body > main,
body > .layout,
body > [class*="app-shell"],
body > [class*="app-root"] {
  max-width: var(--hp-content-max, 1840px);
  margin-inline: auto;
}

/* ============================================================
   V2.1 — Méga-menu navigation
   ============================================================ */
.hp-megamenu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border-bottom: 1px solid var(--hp-border, #dce5f5);
  box-shadow: 0 8px 32px rgba(11, 33, 64, 0.14);
  padding: 24px;
  display: none;
  z-index: 50;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.hp-megamenu.open { display: grid; }

.hp-megamenu-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}
.hp-megamenu-item:hover,
.hp-megamenu-item:focus-visible {
  background: var(--hp-blue-100, #eaf3fb);
}
.hp-megamenu-item .name {
  font-size: 13px;
  font-weight: var(--hp-fw-bold, 700);
  color: var(--hp-dark, #0b2140);
  display: block;
  margin-bottom: 2px;
}
.hp-megamenu-item .desc {
  font-size: 11px;
  color: var(--hp-muted, #667085);
  display: block;
}

.hp-cat-trigger[aria-expanded="true"] {
  background: var(--hp-blue-100, #eaf3fb);
  color: var(--hp-blue, #1d70b7);
}

/* ============================================================
   V2.2 — Assistant IA panel rétractable
   ============================================================ */
.hp-ai-pane {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 340px;
  max-height: calc(100vh - 100px);
  background: #f8fafc;
  color: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(11, 33, 64, 0.24);
  overflow: hidden;
  z-index: 100;
  transition: width 0.3s ease, height 0.3s ease, max-height 0.3s ease;
  display: flex;
  flex-direction: column;
}
.hp-ai-pane.collapsed {
  width: 60px;
  height: 60px;
  max-height: 60px;
  border-radius: 30px;
}
.hp-ai-pane-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.hp-ai-pane-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--hp-warning, #ffa940), var(--hp-danger, #ff4d4f));
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.hp-ai-pane-title { font-size: 13px; font-weight: 700; flex: 1; }
.hp-ai-pane.collapsed .hp-ai-pane-title,
.hp-ai-pane.collapsed .hp-ai-pane-content,
.hp-ai-pane.collapsed .hp-ai-pane-toggle { display: none; }
.hp-ai-pane-toggle {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}
.hp-ai-pane-content {
  padding: 0 18px 18px;
  font-size: 13px;
  overflow-y: auto;
  flex: 1;
}

/* Quand le panel runtime est actif, masquer le bandeau IA original plein-écran */
[data-hp-ai-banner-hidden] {
  display: none !important;
}

/* ============================================================
   V2.3 — Hiérarchisation dashboard (KPI hero plus saillant)
   ============================================================ */
[data-hp-kpi-hero] {
  background: #f8fafc !important;
  color: #fff !important;
  border-radius: 16px;
  padding: 24px 28px;
  position: relative;
  overflow: hidden;
}
[data-hp-kpi-hero]::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255, 169, 64, 0.25), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

/* ============================================================
   V3.1 — Devis : dropdown unifié pour les 7 boutons "+"
   ============================================================ */
.hp-add-line-dropdown {
  position: relative;
  display: inline-block;
}
.hp-add-line-trigger {
  background: var(--hp-blue, #1d70b7);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hp-add-line-trigger:hover { background: var(--hp-blue-700, #155a93); }
.hp-add-line-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: 1px solid var(--hp-border, #dce5f5);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(11, 33, 64, 0.12);
  display: none;
  z-index: 20;
  min-width: 220px;
  padding: 6px;
}
.hp-add-line-dropdown.open .hp-add-line-menu { display: block; }
.hp-add-line-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--hp-text, #172033);
  cursor: pointer;
}
.hp-add-line-menu button:hover { background: var(--hp-bg, #f7faff); }
.hp-add-line-menu .icon {
  display: inline-block;
  width: 18px;
  color: var(--hp-blue, #1d70b7);
  margin-right: 6px;
}

/* Masquer les 7 boutons originaux quand le dropdown unifié est actif */
[data-hp-line-buttons-hidden] {
  display: none !important;
}

/* ============================================================
   V3.2 — Saisie temps : raccourcis quick-time
   ============================================================ */
.hp-quick-time-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.hp-quick-time-row button {
  background: var(--hp-bg2, #eef5fb);
  color: var(--hp-blue, #1d70b7);
  border: 1px solid var(--hp-border, #dce5f5);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}
.hp-quick-time-row button:hover {
  background: var(--hp-blue, #1d70b7);
  color: #fff;
}

/* ============================================================
   Masquage FAB legacy — Quick-Add + Raccourcis clavier
   Les fonctionnalités restent accessibles via window.quickAdd /
   raccourci clavier "?" ; seuls les boutons flottants sont retirés
   de l'UI à la demande utilisateur (2026-05-26).
   ============================================================ */
.qafab2-btn,
.qafab2-bd,
.qafab2-pop,
#kbds2-fab {
  display: none !important;
}

/* ============================================================
   Hub containers : remplir la viewport, pas de "vide bloqué"
   en bas sur les pages courtes.
   Cible les containers injectés par les hubs intégrés
   (commercial-hub, objectifs-commissions, encours-acomptes,
   rentabilite-affaires, forecast-commercial, pipeline-commercial,
   dso-tracker, satisfaction-nps, fidelite-b2b, etc.).
   Convention : main > div[id$="-container"] ou [id$="-hub-container"].
   2026-05-27 — débloque le bas, complète _bizClearMainInline.
   ============================================================ */
#main > div[id$="-container"],
#main > div[id$="-hub-container"] {
  min-height: calc(100vh - 140px);
  padding-bottom: 32px;
  box-sizing: border-box;
}
/* Évite que les shells internes des hubs cappent en hauteur fixe sur
   le main (overflow-y du parent est déjà géré par .main : auto). */
#main > div[id$="-container"] > div[class$="-shell"],
#main > div[id$="-hub-container"] > div[class$="-shell"] {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Élargi (2026-05-27) — couvre les wrappers legacy V1 et dashboard V2
   qui n'utilisent pas la convention *-container : dv2-shell, pipe-shell,
   commhub-shell, et autres conventions *-shell direct enfants de #main. */
#main > .dv2-shell,
#main > .pipe-shell,
#main > .commhub-shell,
#main > .biz2-shell,
#main > .cli2-shell,
#main > .aff2-shell,
#main > .fact2-shell {
  min-height: calc(100vh - 140px);
  padding-bottom: 32px;
  box-sizing: border-box;
}
