/**
 * <sis-floor-plan> — v1
 *
 * Plan interactif 2D du maker space (prompt 04 §4.1).
 * SVG inline schématique cohérent avec window.fixtures (7 zones, 19 postes).
 * Direction éditoriale technique française reconduite : grille blueprint,
 * eyebrow mono compl-1, libellés serif, statuts par couleur.
 *
 * Light DOM — préfixe `.sfp-` (sis-floor-plan).
 */

sis-floor-plan {
  --sfp-serif: "Iowan Old Style", "Palatino", "Hoefler Text", "Times New Roman", Georgia, serif;
  --sfp-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sfp-body: var(--font-family-base);

  display: block;
  min-height: 100vh;
  background: var(--color-bg);
  font-family: var(--sfp-body);
  color: var(--color-text);
  position: relative;
  overflow: hidden;
}

/* Top bar */
.sfp-top {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: max(env(safe-area-inset-top, 0), var(--space-sm)) var(--space-md) var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.sfp-back {
  background: 0; border: 1px solid var(--color-border);
  width: var(--touch-target-min); height: var(--touch-target-min);
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text);
}
.sfp-back:hover { background: var(--color-bg-soft); }
.sfp-back svg { width: 18px; height: 18px; }
.sfp-top__titles { flex: 1; min-width: 0; }
.sfp-top__eyebrow {
  font-family: var(--sfp-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--uttop-compl-1);
  font-weight: var(--font-weight-semibold);
}
.sfp-top__title {
  font-family: var(--sfp-body);
  font-size: 0.95rem;
  font-weight: var(--font-weight-semibold);
}

.sfp-filter-toggle {
  background: 0; border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-family: var(--sfp-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--color-text-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.sfp-filter-toggle.is-on {
  background: var(--uttop-compl-1);
  color: #fff;
  border-color: var(--uttop-compl-1);
}
.sfp-filter-toggle__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Toolbar filtres (chips) */
.sfp-toolbar {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.sfp-toolbar::-webkit-scrollbar { display: none; }
.sfp-chip {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 6px 10px;
  font-family: var(--sfp-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-soft);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}
.sfp-chip:hover { background: var(--color-bg-soft); }
.sfp-chip.is-active {
  background: var(--chip-color, var(--uttop-principale));
  color: #fff;
  border-color: var(--chip-color, var(--uttop-principale));
  font-weight: var(--font-weight-bold);
}
.sfp-chip__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--chip-color, var(--uttop-principale));
}
.sfp-chip.is-active .sfp-chip__dot { background: rgba(255,255,255,0.85); }

/* Plan SVG container */
.sfp-canvas {
  position: relative;
  background: var(--color-bg-soft);
  padding: var(--space-md);
  /* La grille blueprint en background */
}
.sfp-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(0,80,120,0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,80,120,0.04) 1px, transparent 1px);
  background-size: 16px 16px;
  pointer-events: none;
}
.sfp-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* SVG : architecture (murs, portes, fenêtres) d'après plan Bastien */
.sfp-svg .sfp-wall-outer {
  fill: var(--color-bg);
  stroke: var(--color-text);
  stroke-width: 3.5;
  stroke-linejoin: round;
}
.sfp-svg .sfp-wall-inner {
  stroke: var(--color-text);
  stroke-width: 3;
  stroke-linecap: round;
}
.sfp-svg .sfp-door {
  fill: none;
  stroke: var(--color-text-soft);
  stroke-width: 1.2;
}
.sfp-svg .sfp-window {
  stroke: var(--uttop-compl-3);
  stroke-width: 4;
  stroke-linecap: butt;
}
.sfp-svg .sfp-archi-label {
  font-family: var(--sfp-mono);
  font-size: 7px;
  letter-spacing: 0.1em;
  fill: var(--color-text-soft);
  text-anchor: middle;
}

/* SVG : styles internes (compat v1) */
.sfp-svg .zone-wall {
  fill: var(--color-bg);
  stroke: var(--color-text);
  stroke-width: 2;
  stroke-linejoin: round;
}
.sfp-svg .zone-room {
  fill: var(--zone-color, var(--color-bg));
  fill-opacity: 0.08;
  stroke: var(--zone-color, var(--color-text-soft));
  stroke-width: 1.5;
  stroke-dasharray: none;
  transition: fill-opacity var(--transition-fast);
  cursor: pointer;
}
.sfp-svg .zone-room.is-faded {
  fill-opacity: 0.02;
  stroke-opacity: 0.3;
}
.sfp-svg .zone-room.is-highlighted {
  fill-opacity: 0.18;
}
.sfp-svg .zone-label {
  font-family: var(--sfp-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  fill: var(--zone-color, var(--color-text));
  font-weight: 700;
  pointer-events: none;
  text-anchor: middle;
}
.sfp-svg .zone-label.is-faded { fill-opacity: 0.3; }

.sfp-svg .poste {
  cursor: pointer;
  transition: transform var(--transition-fast);
  transform-origin: center;
  transform-box: fill-box;
}
.sfp-svg .poste:hover { transform: scale(1.08); }
.sfp-svg .poste-shape {
  fill: var(--color-bg);
  stroke: var(--zone-color, var(--color-text-soft));
  stroke-width: 1.5;
  transition: fill var(--transition-fast);
}
.sfp-svg .poste.is-dispo .poste-shape { fill: var(--uttop-compl-2); stroke: var(--uttop-compl-1); }
.sfp-svg .poste.is-reserve .poste-shape { fill: var(--uttop-compl-3); stroke: #856704; }
.sfp-svg .poste.is-occupe .poste-shape { fill: var(--color-text-soft); fill-opacity: 0.4; stroke: var(--color-text-soft); }
.sfp-svg .poste.is-panne .poste-shape { fill: var(--color-danger); fill-opacity: 0.85; stroke: #7c1d1d; }
.sfp-svg .poste.is-selected .poste-shape {
  stroke-width: 3;
  stroke: var(--uttop-principale);
  filter: drop-shadow(0 2px 6px rgba(0,80,120,0.35));
}
.sfp-svg .poste.is-faded { opacity: 0.25; }

.sfp-svg .poste-icon {
  font-family: var(--sfp-mono);
  font-size: 9px;
  font-weight: 700;
  fill: var(--color-text);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.sfp-svg .poste.is-dispo .poste-icon,
.sfp-svg .poste.is-reserve .poste-icon { fill: #1F2937; }
.sfp-svg .poste.is-panne .poste-icon { fill: #fff; }

/* Légende statuts */
.sfp-legend {
  padding: var(--space-sm) var(--space-md) 0;
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  font-family: var(--sfp-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--color-text-soft);
}
.sfp-legend__item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sfp-legend__swatch {
  width: 12px; height: 12px;
  border-radius: 3px;
  border: 1.5px solid currentColor;
}
.sfp-legend__swatch.is-dispo   { background: var(--uttop-compl-2); border-color: var(--uttop-compl-1); }
.sfp-legend__swatch.is-reserve { background: var(--uttop-compl-3); border-color: #856704; }
.sfp-legend__swatch.is-occupe  { background: var(--color-text-soft); opacity: 0.4; border-color: var(--color-text-soft); }
.sfp-legend__swatch.is-panne   { background: var(--color-danger); border-color: #7c1d1d; }

/* Stats résumé */
.sfp-stats {
  padding: var(--space-sm) var(--space-md);
  display: flex;
  gap: var(--space-md);
  justify-content: space-around;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-sm);
}
.sfp-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.sfp-stat__num {
  font-family: var(--sfp-serif);
  font-size: 1.3rem;
  line-height: 1;
  color: var(--color-text);
}
.sfp-stat__label {
  font-family: var(--sfp-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-soft);
}

/* Bottom sheet : fiche poste rapide au tap */
.sfp-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: var(--z-modal);
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -16px 40px rgba(0,0,0,0.12);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
  padding: var(--space-md);
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0));
}
.demo-frame .sfp-sheet { position: absolute; bottom: 0; left: 0; right: 0; }
.sfp-sheet.is-open { transform: translateY(0); }
.sfp-sheet__handle {
  width: 40px; height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  margin: 0 auto var(--space-md);
}
.sfp-sheet__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}
.sfp-sheet__icon {
  flex: 0 0 44px;
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  background: var(--zone-color, var(--uttop-principale));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sfp-mono);
  font-size: 11px;
  font-weight: 700;
}
.sfp-sheet__body { flex: 1; min-width: 0; }
.sfp-sheet__zone {
  font-family: var(--sfp-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--zone-color, var(--uttop-principale));
  font-weight: var(--font-weight-semibold);
}
.sfp-sheet__name {
  font-family: var(--sfp-serif);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.15;
  margin-top: 2px;
}
.sfp-sheet__close {
  background: 0; border: 1px solid var(--color-border);
  border-radius: 50%;
  width: var(--touch-target-min); height: var(--touch-target-min);
  cursor: pointer;
  color: var(--color-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.sfp-sheet__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sfp-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-md);
}
.sfp-sheet__status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
.sfp-sheet__status.is-dispo   { background: rgba(18,154,126,0.10); color: #0a5040; }
.sfp-sheet__status.is-reserve { background: rgba(245,216,54,0.15); color: #856704; }
.sfp-sheet__status.is-occupe  { background: rgba(107,114,128,0.10); color: var(--color-text-soft); }
.sfp-sheet__status.is-panne   { background: rgba(220,38,38,0.08); color: #7c1d1d; }

.sfp-sheet__hab {
  background: var(--color-bg-soft);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--sfp-body);
  font-size: 0.85rem;
  color: var(--color-text);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.sfp-sheet__hab__icon {
  flex: 0 0 24px;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.sfp-sheet__hab.is-ok .sfp-sheet__hab__icon { background: var(--uttop-compl-1); }
.sfp-sheet__hab.is-ko .sfp-sheet__hab__icon { background: var(--color-danger); }

.sfp-sheet__actions {
  display: flex;
  gap: var(--space-sm);
}
.sfp-sheet__btn {
  flex: 1;
  font-family: var(--sfp-body);
  font-size: 0.9rem;
  font-weight: var(--font-weight-semibold);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 0;
  cursor: pointer;
  min-height: var(--touch-target-comfortable);
}
.sfp-sheet__btn--primary { background: var(--uttop-principale); color: #fff; }
.sfp-sheet__btn--secondary { background: var(--color-bg-soft); color: var(--uttop-principale); border: 1px solid var(--color-border); }

/* Backdrop sheet */
.sfp-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: calc(var(--z-modal) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.demo-frame .sfp-sheet-backdrop { position: absolute; }
.sfp-sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  .sfp-svg .poste:hover { transform: none; }
}
