/* ==========================================================================
   SIDEBAR APPLICATIVE V3 — propriétaire unique, Accueil ET Dossier.
   Mesures relevées sur le mockup (sidebar 170 px) ramenées à 210 px (×1,235).
   ========================================================================== */
body:is([data-active-surface="home"],[data-active-surface="dossier"])>.v3-home-sidebar[data-ui="v3"]{
  --v3-sidebar-row:36px;
  --v3-sidebar-text:14px;
  --v3-sidebar-icon:16px;
  /* Au-dessus du contenu de page, SOUS les modales (.modalOverlay z-index 50) : le voile d'une
     modale couvre aussi la sidebar et une grande modale n'est plus masquée par elle. */
  z-index:40;
  display:flex;
  flex-direction:column;
  align-items:stretch;
  justify-content:flex-start;
  min-height:0;
  height:auto;
  padding:12px var(--v3-home-sidebar-pad-x) 10px;
  border:0;
  border-radius:var(--v3-home-radius-shell) 0 0 var(--v3-home-radius-shell);
  background:var(--fi-gradient-nav);
  box-shadow:none;
  color:#fff;
  font-family:var(--v3-home-font);
  overflow:hidden;
}

/* Logo d'origine (F&I gras + « Studio » régulier), recoloré pour le fond marine. */
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .home2-brand{
  display:grid;
  grid-template-columns:1fr;
  grid-template-rows:auto auto;
  align-content:start;
  order:1;
  width:100%;
  min-width:0;
  height:auto;
  margin:0 0 14px;
  padding:0 8px;
  border:0;
  background:transparent;
  box-shadow:none;
}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #softwareLogoMark{
  position:relative;
  display:block;
  /* Taille visuelle doublée (92×22 → 184×44), proportions conservées, jamais plus large que la colonne. */
  width:min(184px,100%);
  height:auto;
  aspect-ratio:92 / 22;
  overflow:hidden;
  background:none;
  /* Runtime branding sets an inline legacy background: keep one visual source. */
  background-size:0 0;
}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #softwareLogoMark::before{
  content:"";
  position:absolute;
  inset:0;
  background:transparent url("../../../assets/fi-studio-wordmark-v3.svg") left center/contain no-repeat;
}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #softwareLogoMark::after{content:none}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .home2-wordmark{display:none}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .appBuildMarker{
  display:block;
  margin-top:3px;
  color:#8796d6;
  font-family:var(--v3-home-font);
  font-size:12px;
  font-weight:500;
  line-height:1.2;
}

/* Concessionnaire actif : nom complet sur une ligne. */
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .v3-home-dealer{
  order:2;
  display:grid;
  grid-template-columns:20px minmax(0,1fr) 8px;
  align-items:center;
  gap:6px;
  width:100%;
  height:48px;
  margin:0 0 14px;
  padding:0 7px;
  border:1px solid rgba(255,255,255,.06);
  border-radius:10px;
  background:rgba(255,255,255,.075);
  color:#fff;
  font-family:var(--v3-home-font);
  font-size:12.5px;
  font-weight:650;
  letter-spacing:-.005em;
  text-align:left;
}
.v3-home-dealer #v3HomeDealerName{min-width:0;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-height:1.25;white-space:normal;overflow-wrap:anywhere}
.v3-home-dealer__icon{display:grid;place-items:center;width:20px;height:20px;border-radius:6px;background:rgba(255,255,255,.1)}
.v3-home-dealer svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.v3-home-dealer .v3-home-dealer__chevron{width:8px;height:8px;color:#aeb7d2}

body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .home2-toolbar,
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .toolbarUtilities{display:contents}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .home2-tb-divider{display:none}

/* Navigation. */
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .toolbar :is(button,.premiumToolbarIcon,.topbarDirectoryButton,.compactLanguageButton){
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:12px;
  width:100%;
  min-width:0;
  height:var(--v3-sidebar-row);
  min-height:var(--v3-sidebar-row);
  margin:0 0 3px;
  padding:0 12px;
  border:0;
  border-radius:9px;
  background:transparent;
  color:#b4bcd9;
  box-shadow:none;
  font-family:var(--v3-home-font);
  font-size:var(--v3-sidebar-text);
  font-weight:550;
  letter-spacing:0;
  transform:none;
}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .toolbar button:hover{background:rgba(255,255,255,.06);color:#fff;box-shadow:none;transform:none}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .toolbar svg{display:block;flex:0 0 var(--v3-sidebar-icon);width:var(--v3-sidebar-icon);height:var(--v3-sidebar-icon);margin:0;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;overflow:visible}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .v3-sidebar-label{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #workspaceHomeButton{order:3}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #openClientDirectoryButton{order:4}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #openToolsButton{order:5}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #settingsButton{order:6}
/* Entrée active : celle de la surface affichée. */
body[data-active-surface="home"] .v3-home-sidebar #workspaceHomeButton,
body[data-active-surface="dossier"] .v3-home-sidebar #openClientDirectoryButton{background:linear-gradient(100deg,color-mix(in srgb,var(--fi-action-primary) 24%,var(--fi-nav)),var(--fi-nav));color:#b4bcd9;font-weight:550;box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--fi-action-primary) 30%,transparent)}

body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #homeNewDealButton{
  order:7;
  display:flex;
  justify-content:center;
  gap:8px;
  height:var(--v3-sidebar-row);
  min-height:var(--v3-sidebar-row);
  margin:12px 0 0;
  border:0;
  border-radius:10px;
  background:var(--fi-gradient-secondary);
  color:var(--fi-ink);
  box-shadow:var(--fi-shadow-sm);
  font-size:var(--v3-sidebar-text);
  font-weight:650;
  line-height:1;
  text-align:center;
}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #homeNewDealButton:hover{background:#f3f5fb;color:#1f2a4d}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #homeNewDealButton::before{content:"+";font-size:16px;font-weight:500;line-height:1}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #dmsImportButton{order:8}

/* États système (synchronisation, mode) : compacts, sans casser la colonne. */
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar :is(#cloudSyncStatus,#cloudEntitlementStatus){
  order:9;
  display:flex;
  justify-content:center;
  width:100%;
  min-height:28px;
  height:auto;
  margin:10px 0 0;
  padding:4px 10px;
  border:1px solid var(--fi-warning);
  border-radius:8px;
  background:color-mix(in srgb,var(--fi-warning-soft) 14%,var(--fi-nav));
  color:#ffd892;
  font-size:12px;
  font-weight:650;
  letter-spacing:.02em;
  text-transform:none;
  white-space:normal;
}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar :is(#cloudSyncStatus,#cloudEntitlementStatus)[hidden]{display:none}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #devCloudModeButton{
  order:1;
  justify-content:flex-start;
  height:18px;
  min-height:18px;
  margin:-8px 8px 10px;
  padding:0;
  overflow:hidden;
  border:0;
  border-radius:0;
  background:transparent;
  color:#8796d6;
  font-size:11px;
  font-weight:650;
  text-overflow:ellipsis;
  white-space:nowrap;
}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .toolbarUtilities>.fi-select-control{
  order:2;
  width:100%;
  height:48px;
  margin:0 0 14px;
}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .toolbarUtilities>.fi-select-control .fi-select-control__button.fi-select-control__button{
  display:grid;
  grid-template-columns:20px minmax(0,1fr) 8px;
  align-items:center;
  gap:6px;
  height:100%;
  min-height:100%;
  padding:0 7px;
  border:1px solid rgba(255,255,255,.06);
  border-radius:10px;
  background:rgba(255,255,255,.075);
  color:#fff;
  font-size:12.5px;
  font-weight:650;
  letter-spacing:-.005em;
  text-align:left;
}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar .toolbarUtilities>.fi-select-control .fi-select-control__button::before{
  content:"";
  width:20px;
  height:20px;
  border-radius:6px;
  background:rgba(255,255,255,.1) center/12px 12px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8.5h12v10H6zM8 5.5h8v3H8zM9 13h6M9 16h4'/%3E%3C/svg%3E");
}
body:has(#platformAdminOrganizationSwitcher:not([hidden])) .v3-home-dealer{display:none}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #languageButton{order:20;margin-top:auto}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #languageButton::before{content:"";flex:0 0 var(--v3-sidebar-icon);width:var(--v3-sidebar-icon);height:var(--v3-sidebar-icon);background:center/var(--v3-sidebar-icon) no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b4bcd9' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='8.5'/%3E%3Cpath d='M3.5 12h17M12 3.5c2.4 2.4 3.4 5.2 3.4 8.5s-1 6.1-3.4 8.5c-2.4-2.4-3.4-5.2-3.4-8.5s1-6.1 3.4-8.5Z'/%3E%3C/svg%3E")}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #v3HomeSignOutButton{order:21;display:flex}
body:is([data-active-surface="home"],[data-active-surface="dossier"]) .v3-home-sidebar #platformAdminSignOutButton{display:none}

.v3-home-profile{
  order:30;
  position:relative;
  display:block;
  min-height:46px;
  margin-top:8px;
  padding:0;
  border-radius:11px;
  background:transparent;
}
.v3-home-profile__button{
  display:grid;
  grid-template-columns:32px minmax(0,1fr) 14px;
  align-items:center;
  gap:9px;
  width:100%;
  min-height:46px;
  margin:0;
  padding:7px 9px;
  border:1px solid color-mix(in srgb,var(--fi-on-action) 16%,transparent);
  border-radius:var(--fi-radius-xl);
  background:linear-gradient(135deg,color-mix(in srgb,var(--fi-on-action) 14%,var(--fi-nav)),color-mix(in srgb,var(--fi-on-action) 7%,var(--fi-nav)));
  color:#fff;
  font-family:var(--v3-home-font);
  text-align:left;
  box-shadow:var(--fi-shadow-sm);
  cursor:pointer;
}
.v3-home-profile__button:hover,.v3-home-profile__button[aria-expanded="true"]{background:rgba(255,255,255,.13)}
.v3-home-profile__button:focus-visible{outline:none;box-shadow:var(--fi-shadow-focus-ring)}
.v3-home-profile__button>.fi-chevron{color:var(--fi-on-action)}
.v3-home-profile__button[aria-expanded="true"]>.fi-chevron{transform:rotate(180deg)}
.v3-home-profile__avatar{display:grid;place-items:center;flex:0 0 auto;width:32px;height:32px;border-radius:50%;background:var(--fi-surface);color:var(--fi-violet);font-size:13px;font-weight:750}
.v3-home-profile__copy{display:grid;min-width:0;line-height:1.2}
.v3-home-profile__copy strong{overflow:hidden;color:#fff;font-size:14px;font-weight:700;text-overflow:ellipsis;white-space:nowrap}
.v3-home-profile__copy small{margin-top:2px;color:#d9e6ff;font-size:12px;font-weight:500}
.v3-home-profile-menu.fi-menu{
  position:absolute;
  right:0;
  bottom:calc(100% + var(--fi-space-xs));
  left:0;
  width:100%;
  max-height:none;
}
.v3-home-profile-menu.fi-menu[hidden]{display:none}
.v3-home-profile-menu .fi-menu__item{justify-content:flex-start;padding-inline:var(--fi-space-sm);font-size:var(--fi-text-xs);white-space:normal}
.v3-home-profile-menu__version{margin-top:var(--fi-space-xs);padding:var(--fi-space-sm) var(--fi-space-md) 2px;border-top:1px solid var(--fi-border-soft);color:var(--fi-ink-faint);font-size:var(--fi-text-xs);font-weight:var(--fi-weight-meta)}

/* Hors Accueil/Dossier, la barre reprend son rôle compact legacy. */
body:not([data-active-surface="home"]):not([data-active-surface="dossier"]) :is(.v3-home-dealer,.v3-home-profile,.v3-sidebar-label,#v3HomeSignOutButton){display:none}

/* Keep the actual save state and its semantic tone; only normalize its geometry. */
.v3-home-sidebar #dealSaveStatus:not([hidden]){display:inline-flex;align-items:center;justify-content:center;align-self:flex-start;max-width:100%;min-height:20px;padding:0 var(--fi-space-sm);border-radius:var(--fi-radius-pill);font-size:var(--fi-text-sm2);font-weight:var(--fi-weight-meta);letter-spacing:0;line-height:var(--fi-leading-tight)}

/* Paint-only save-state variants. The existing class/state still determines the meaning. */
.v3-home-sidebar #dealSaveStatus.fi-badge--warning{background:var(--fi-save-pending-bg);color:var(--fi-save-pending-ink)}
.v3-home-sidebar #dealSaveStatus.fi-badge--success{background:linear-gradient(110deg,var(--fi-success-soft),var(--fi-mint));color:var(--fi-nav)}
