/*
 * Que Bâtir 22.23 — coque de navigation uniquement.
 *
 * Cette feuille ne remplace aucune règle métier et ne modifie aucun composant
 * de calcul. Elle réorganise visuellement les éléments existants autour d'une
 * navigation fixe, conformément au prototype validé.
 */
:root {
  --qb-shell-sidebar: 200px;
  --qb-shell-header: 76px;
  --qb-shell-green: #17776f;
  --qb-shell-ink: #263b42;
  --qb-shell-muted: #718087;
  --qb-shell-line: #dce5e3;
  --qb-shell-bg: #f4f7f6;
}

html { scroll-padding-top: calc(var(--qb-shell-header) + 18px); }
body { min-width: 320px; background: var(--qb-shell-bg) !important; }
.qb-app-shell { min-height: 100vh; }
.qb-shell-content { min-height: 100vh; margin-left: var(--qb-shell-sidebar); padding-top: var(--qb-shell-header); }

.qb-shell-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 2200;
  display: flex;
  flex-direction: column;
  width: var(--qb-shell-sidebar);
  padding: 22px 14px 16px;
  border-right: 1px solid var(--qb-shell-line);
  background: #fff;
  box-shadow: 8px 0 32px rgb(34 69 62 / 5%);
}
.qb-shell-logo {
  display: block;
  padding: 2px 12px 25px;
  color: #293b42;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -.8px;
  text-decoration: none;
}
.qb-shell-logo b { color: var(--qb-shell-green); }
/* Logotype QueBâtir.fr en haut à gauche ; « QB » seul quand la barre se réduit. */
.qb-shell-logo { padding: 0 4px 20px; }
.qb-shell-logo img { display: block; width: 100%; height: auto; max-height: 96px; object-fit: contain; }
.qb-shell-logo-mini { display: none; }
.qb-shell-logo:focus-visible { outline: 3px solid var(--qb-shell-green); outline-offset: 2px; border-radius: 6px; }
.qb-shell-nav { display: grid; gap: 5px; }
.qb-shell-nav button {
  display: grid;
  grid-template-columns: 25px 1fr;
  align-items: center;
  width: 100%;
  min-height: 43px;
  padding: 9px 11px;
  border: 0;
  border-radius: 8px;
  color: #40555c;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 720;
  line-height: 1.2;
  text-align: left;
}
.qb-shell-nav button span { color: #628078; font-size: 17px; text-align: center; }
.qb-shell-nav button:hover { color: #203f3b; background: #eef5f3; }
.qb-shell-nav button.active {
  color: #194e49;
  background: #e2f0ed;
}
.qb-shell-nav button.active span { color: var(--qb-shell-green); }

.qb-route-exports #main-content > :not(#qb-export-page) { display: none !important; }
.qb-export-page {
  width: min(1080px, calc(100% - 40px));
  margin: 34px auto;
  padding: 34px;
  border: 1px solid var(--qb-shell-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 50px rgb(35 67 61 / 8%);
}
.qb-export-page[hidden] { display: none !important; }
.qb-export-heading { max-width: 680px; margin-bottom: 26px; }
.qb-export-heading h2 { margin: 5px 0 8px; color: var(--qb-shell-ink); font-size: clamp(25px, 3vw, 38px); }
.qb-export-heading p { margin: 0; color: var(--qb-shell-muted); }
.qb-export-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.qb-export-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  min-height: 270px;
  padding: 22px;
  border: 1px solid #dfe8e6;
  border-radius: 13px;
  background: #f8faf9;
}
.qb-export-card h3 { margin: 0 0 7px; color: #294148; font-size: 18px; }
.qb-export-card p { margin: 0; color: #6d7d81; font-size: 13px; line-height: 1.55; }
.qb-export-format {
  display: inline-grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 11px;
  color: #fff;
  background: var(--qb-shell-green);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: .06em;
}
.qb-export-card button { width: 100%; min-height: 44px; }
.qb-export-status { min-height: 22px; margin: 20px 0 0; color: #405f5a; font-size: 13px; }

.qb-shell-summary {
  display: grid;
  gap: 11px;
  margin-top: auto;
  padding: 14px 12px;
  border: 1px solid #e1e8e6;
  border-radius: 10px;
  background: #f8faf9;
}
.qb-shell-summary div { display: grid; gap: 2px; }
.qb-shell-summary span { color: #7b898d; font-size: 10px; }
.qb-shell-summary strong { overflow: hidden; color: #2b4147; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }

.top-bar {
  position: fixed !important;
  inset: 0 0 auto var(--qb-shell-sidebar) !important;
  z-index: 2100 !important;
  display: grid !important;
  grid-template-columns: minmax(300px, 650px) 1fr auto !important;
  align-items: center !important;
  min-height: var(--qb-shell-header) !important;
  padding: 10px 22px !important;
  border-bottom: 1px solid var(--qb-shell-line) !important;
  background: rgb(255 255 255 / 96%) !important;
  box-shadow: 0 8px 24px rgb(36 69 62 / 5%) !important;
  backdrop-filter: blur(12px);
}
.top-bar-brand { display: none !important; }
.top-bar-actions { grid-column: 3; gap: 7px !important; }
.top-bar-actions .app-version,
.top-bar-actions #contrast-button,
.top-bar-actions #signup-button { display: none !important; }
.top-bar-actions #login-button {
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: #3d555a;
  font-size: 12px;
}
.qb-shell-search-host { grid-column: 1; grid-row: 1; min-width: 0; }
.qb-shell-search-host .search-panel {
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.qb-shell-search-host .section-heading,
.qb-shell-search-host #address-form > label { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.qb-shell-search-host .search-row { gap: 7px; }
.qb-shell-search-host #address-input {
  min-height: 42px;
  padding: 9px 43px 9px 14px;
  border: 1px solid #d6e0de;
  border-radius: 9px;
  background: #f8faf9;
  color: #31464b;
  font-size: 12px;
  box-shadow: inset 0 1px 2px rgb(39 68 63 / 3%);
}
.qb-shell-search-host #search-button {
  min-width: 45px;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 0;
}
.qb-shell-search-host #search-button::before { content: "⌕"; font-size: 21px; line-height: 1; }
.qb-shell-search-host #status-message {
  position: absolute;
  top: 59px;
  left: 23px;
  max-width: 620px;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  color: #63767a;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qb-shell-route-status {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  margin: 0 14px;
  color: #718085;
  font-size: 11px;
  text-align: right;
}

.address-history-item { display: grid; grid-template-columns: 1fr 34px; align-items: center; gap: 4px; }
.address-history-remove { min-width: 32px; padding: 6px !important; color: #7b4b4b; background: transparent !important; border: 0 !important; }
.address-history-clear { width: 100%; padding: 8px 12px !important; color: #60736f; font-size: 12px; background: #f4f7f6 !important; border: 0 !important; }

.c8-dimension-actions, .c8-ground-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.c8-dimension-actions button, .c8-ground-actions button { padding: 6px 8px; font-size: 11px; }
.c8-dimension-group { margin-top: 10px; color: #49605e; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.c8-dimension-row.selected { outline: 2px solid #e23d87; outline-offset: 1px; background: #fff1f7; }
.c8-dimension-toggle { display: flex; align-items: center; gap: 7px; min-width: 0; }
.c8-ground-cover-card { display: grid; gap: 8px; }
.c8-ground-cover-card label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.c8-ground-legend { display: grid; gap: 5px; font-size: 11px; color: #52645f; }
.c8-ground-swatch { display: inline-block; width: 12px; height: 12px; margin-right: 5px; border-radius: 3px; vertical-align: -2px; }

.hero { display: none !important; }
.layout { max-width: none !important; padding: 20px 22px 30px !important; }
.primary-stage-grid { display: none !important; }
.workspace {
  grid-template-columns: minmax(0, 1.6fr) minmax(285px, .62fr) !important;
  gap: 12px !important;
  min-height: calc(100vh - var(--qb-shell-header) - 40px);
}
.map-panel,
.selection-panel,
.qb-property-dashboard,
.qb-topic-content { border-radius: 10px !important; box-shadow: 0 8px 30px rgb(28 63 56 / 6%) !important; }
#map { height: calc(100vh - var(--qb-shell-header) - 42px) !important; min-height: 520px !important; }
.selection-panel { max-height: calc(100vh - var(--qb-shell-header) - 42px); padding: 17px !important; overflow: auto; }
.qb-property-dashboard { max-width: none !important; margin: 0 !important; }
.qb-dashboard-header { padding-top: 3px; }
.qb-topic-tabs { position: sticky; top: calc(var(--qb-shell-header) + 6px); z-index: 20; }

/* L'atelier historique reste intact. Seule sa fenêtre est inscrite dans la
   coque, pour que la navigation et la recherche restent toujours visibles. */
.c8-editor {
  top: var(--qb-shell-header) !important;
  right: 0 !important;
  bottom: 0 !important;
  left: var(--qb-shell-sidebar) !important;
  z-index: 1800 !important;
}
.c8-studio-bar { min-height: 62px; }
.c8-editor-body { background: #eef3f1 !important; }
.c8-plan-stage { margin: 8px 0 8px 8px; border: 1px solid #dce5e2; border-radius: 9px; }
.c8-editor-side { margin: 8px 8px 8px 0; border: 1px solid #dce5e2 !important; border-radius: 0 9px 9px 0; }

/* Les trois surfaces utiles sont reprises dans la petite légende fixe à
   gauche. Elles ne consomment plus une rangée entière au-dessus du dessin. */
.c8-live-metrics { display: none !important; }

/* Atelier Projet : les commandes existantes sont conservées mais regroupées
   selon le vocabulaire d'un projet d'architecture. */
.c8-editor[data-shell-mode="project"] .c8-draw-tools {
  align-items: stretch;
  flex: 1 1 100%;
  flex-wrap: wrap;
  gap: 8px;
}
.c8-tool-section {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid #dfe8e5;
  border-radius: 8px;
  background: #f8faf9;
}
.c8-tool-section-title {
  width: 100%;
  color: #6f817c;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.c8-project-volumetry { flex: 1 1 430px; }
.c8-project-volumetry .c8-direct-volume { flex-wrap: wrap; }

/* Plan et 3D existants : ce sont des vues de consultation. Les outils de
   projet et l'inspecteur disparaissent ; le plan conserve uniquement la
   commande de pleine terre demandée. */
.c8-editor[data-shell-mode^="existing-"] .c8-studio-tools,
.c8-editor[data-shell-mode^="existing-"] .c8-studio-kicker,
.c8-editor[data-shell-mode^="existing-"] #c8-editor-parcel,
.c8-editor[data-shell-mode^="existing-"] .c8-view-switch,
.c8-editor[data-shell-mode^="existing-"] .c8-tool-section,
.c8-editor[data-shell-mode^="existing-"] #c8-finish-trace,
.c8-editor[data-shell-mode^="existing-"] #c8-cancel-trace,
.c8-editor[data-shell-mode^="existing-"] #c8-live-state,
.c8-editor[data-shell-mode^="existing-"] .c8-editor-side { display: none !important; }
.c8-editor[data-shell-mode="existing-plan"] .c8-plan-ground { display: flex !important; }
.c8-editor[data-shell-mode^="existing-"] .c8-studio-bar { min-height: 48px; padding-block: 9px !important; }
.c8-editor[data-shell-mode^="existing-"] .c8-workspace-bar {
  min-height: 48px;
  padding: 7px 14px;
}
.c8-editor[data-shell-mode^="existing-"] .c8-draw-tools { width: 100%; }
.c8-editor[data-shell-mode^="existing-"] #c8-fit { margin-left: auto; }
.c8-editor[data-shell-mode^="existing-"] .c8-plan-stage {
  margin-right: 8px;
  border-radius: 9px;
}
.c8-editor[data-shell-mode="existing-volume"] .c8-live-hint { display: none !important; }

body.qb-shell-contrast .qb-shell-sidebar,
body.qb-shell-contrast .top-bar { border-color: #93aaa5 !important; }

/* Attentes explicites, sans faux pourcentage. La progression LiDAR conserve
   sa jauge réelle ; les petites attentes affichent un anneau QueBâtir. */
.qb-waiting { align-items: center; gap: 9px; }
.qb-waiting[hidden] { display: none !important; }
.qb-hourglass { font-size: 0 !important; }
.qb-hourglass,
#status-message.qb-waiting::before,
#c8-lidar-progress:not([hidden]) #c8-lidar-progress-title::before {
  display: inline-block;
  flex: 0 0 auto;
  content: "";
  width: 12px;
  height: 12px;
  margin-right: 6px;
  vertical-align: -2px;
  border: 2.5px solid #d6e7e1;
  border-top-color: #12866d;
  border-right-color: #152a3a;
  border-radius: 50%;
  animation: qb-loading-turn .9s linear infinite;
}
#status-message.qb-waiting { display: flex; color: #315e57; font-weight: 750; }
.plu-loading.qb-waiting { display: flex; border-left-color: var(--qb-shell-green); background: #edf6f3; }
.c8-generation-wait {
  display: flex;
  min-height: 42px;
  padding: 9px 18px;
  border-bottom: 1px solid #d7e2de;
  color: #234c44;
  background: #f4f9f7;
  font-size: 12px;
}

/* Indicateur d'attente central : logo QB au milieu, anneau qui tourne. */
#qb-loading-overlay {
  position: fixed;
  z-index: 2300;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 16px;
  background: rgb(244 249 247 / 82%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: qb-loading-fade .18s ease-out;
}
#qb-loading-overlay[hidden] { display: none !important; }
.qb-loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(360px, 100%);
  box-sizing: border-box;
  padding: 28px 24px 24px;
  border: 1px solid #cfe2db;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 20px 55px rgb(20 42 59 / 16%);
  text-align: center;
  color: #152a3a;
}
.qb-loading-mark { position: relative; display: grid; place-items: center; width: 96px; height: 96px; }
.qb-loading-ring {
  position: absolute;
  inset: 0;
  border: 6px solid #e2efea;
  border-top-color: #12866d;
  border-right-color: #12866d;
  border-bottom-color: #152a3a;
  border-radius: 50%;
  animation: qb-loading-turn 1.1s cubic-bezier(.55,.15,.45,.85) infinite;
}
.qb-loading-letters {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f6faf8;
  font-family: "Montserrat", "Segoe UI", Arial, sans-serif;
  font-size: 27px;
  line-height: 1;
  letter-spacing: -1.5px;
  animation: qb-loading-pulse 1.6s ease-in-out infinite;
}
.qb-loading-letters b { font-weight: 900; }
.qb-loading-letters .qb-q { color: #152a3a; }
.qb-loading-letters .qb-b { color: #12866d; }
.qb-loading-title { font-size: 17px; line-height: 1.3; }
.qb-loading-detail { margin: 0; color: #4f6a63; font-size: 13.5px; line-height: 1.45; }
@keyframes qb-loading-turn { to { transform: rotate(360deg); } }
@keyframes qb-loading-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(.94); } }
@keyframes qb-loading-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .qb-loading-ring,
  .qb-hourglass,
  #status-message.qb-waiting::before,
  #c8-lidar-progress:not([hidden]) #c8-lidar-progress-title::before { animation-duration: 3s; }
  .qb-loading-letters { animation: none; }
}

@media (max-width: 1000px) {
  :root { --qb-shell-sidebar: 76px; }
  .qb-shell-sidebar { padding: 18px 8px 12px; }
  .qb-shell-logo { padding: 4px 2px 20px; text-align: center; }
  .qb-shell-logo img { display: none; }
  .qb-shell-logo-mini { display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto; border-radius: 12px; background: #142a3b; color: #fff; font-size: 17px; font-weight: 900; letter-spacing: -.5px; }
  .qb-shell-nav button { grid-template-columns: 1fr; justify-items: center; padding: 8px 3px; font-size: 9px; text-align: center; }
  .qb-shell-summary { display: none; }
  .top-bar { grid-template-columns: minmax(220px, 1fr) auto !important; padding-inline: 12px !important; }
  .qb-shell-route-status { display: none; }
  .top-bar-actions { grid-column: 2; }
  .workspace { grid-template-columns: 1fr !important; }
  .selection-panel { max-height: none; }
  #map { height: 58vh !important; min-height: 400px !important; }
  .qb-export-grid { grid-template-columns: 1fr; }
  .qb-export-card { min-height: 0; }
}

@media (max-width: 620px) {
  :root { --qb-shell-sidebar: 58px; --qb-shell-header: 68px; }
  .qb-shell-logo-mini { width: 40px; height: 40px; font-size: 15px; }
  .qb-shell-nav button { min-height: 42px; font-size: 0; }
  .qb-shell-nav button span { font-size: 18px; }
  .top-bar-actions { display: none !important; }
  .top-bar { grid-template-columns: 1fr !important; }
  .layout { padding: 10px !important; }
  .c8-editor { overflow: auto !important; }
  .qb-export-page { width: 100%; margin: 10px 0; padding: 20px; }
}

/* Insertion photoréaliste par API externe retirée de cette version. */
#c8-open-visualizer, #c8-visualizer { display: none !important; }

/* Analyse PLU (repris de la 22.43) : dès qu'une fiche parcelle existe, les
   confirmations passent avant la gestion des pièces officielles. Hauteur et
   stationnement sont ainsi accessibles sans descendre dans la page. */
.plu-panel.plu-has-analysis:not([hidden]) { display: flex; flex-direction: column; }
.plu-panel.plu-has-analysis > #plu-analysis-result { order: 1; }
.plu-panel.plu-has-analysis > #plu-search-pane { order: 3; margin-top: 12px; }
.plu-panel.plu-has-analysis > #plu-upload-details { order: 4; }
.plu-panel.plu-has-analysis > .constraints-actions { order: 5; }
.plu-panel.plu-has-analysis > #plu-fiche-xlsx-status { order: 6; }
.rule-questions {
  grid-template-columns: minmax(0,1.15fr) minmax(260px,.85fr);
  align-items: stretch;
  gap: 10px !important;
  padding: 12px !important;
  border-width: 2px !important;
  box-shadow: 0 8px 24px rgb(92 66 18 / 7%);
}
.rule-questions-title { grid-column: 1 / -1; color: #7f5611; font-size: 14px; }
.rule-priority-question {
  margin: 0 !important;
  padding: 13px !important;
  border: 2px solid #e4bd69 !important;
  border-radius: 10px !important;
  background: #fff !important;
  min-width: 0;
}
.rule-station-question { display: grid !important; align-content: start; gap: 8px !important; }
.rule-priority-label { color: #122c4a; font-size: 16px; }
.rule-priority-copy { color: #435b55; line-height: 1.4; }
.rule-priority-select { width: 100%; max-width: none !important; min-height: 42px; border: 1px solid #a7bcb5; border-radius: 8px; background: white; }
.rule-priority-note { color: #6d765f; line-height: 1.35; }
.rule-questions > label:not(.rule-priority-question),
.rule-questions > button { grid-column: 1 / -1; }
@media (max-width: 900px) { .rule-questions { grid-template-columns: 1fr; } }
