
/* ---------- Variables de theme (dark / light) ---------- */

body.theme-dark {
  --bg: #07141d;
  --bg-strong: #0c1d2a;
  --panel: rgba(10, 22, 31, 0.82);
  --line: rgba(132, 160, 185, 0.18);
  --line-strong: rgba(124, 204, 255, 0.45);
  --text: #eaf6ff;
  --muted: #98afc8;
  --primary: #53c4ff;
  --primary-strong: #2f9ef5;
  --ghost: rgba(74, 163, 255, 0.22);
  --ghost-strong: rgba(74, 163, 255, 0.34);
  --report: rgba(74, 163, 255, 0.22);
  --report-strong: rgba(74, 163, 255, 0.34);
  --canvas-bg: rgba(9, 20, 28, 0.82);
  --board-bg: rgba(8, 18, 27, 0.18);
  --board-inner-bg: rgba(255, 255, 255, 0.04);
  --board-grid: rgba(122, 142, 168, 0.10);
  --board-glow: rgba(74, 163, 255, 0.14);
  --track: rgba(74, 163, 255, 0.22);
  --thumb: rgb(36, 79, 122);
  --thumb-hover: rgba(29, 104, 216, 1);
}

body.theme-light {
  --bg: #eef5ff;
  --bg-strong: #dfeeff;
  --panel: rgba(255, 255, 255, 0.8);
  --line: rgba(92, 120, 160, 0.16);
  --line-strong: rgba(61, 129, 214, 0.28);
  --text: #18314f;
  --muted: #5a708b;
  --primary: #4aa3ff;
  --primary-strong: #2779e7;
  --ghost: #53c4ff;
  --ghost-strong: #2f9ef5;
  --report: #53c4ff;
  --report-strong: #2f9ef5;
  --canvas-bg: linear-gradient(180deg, #f8fbff, #edf5ff);
  --board-bg: rgba(255, 255, 255, 0.22);
  --board-inner-bg: rgba(255, 255, 255, 0.78);
  --board-grid: rgba(92, 120, 160, 0.14);
  --board-glow: rgba(0, 2, 3, 0.08);
  --track: rgba(17, 30, 48, 0.18);
  --thumb: rgba(61, 86, 114, 0.8);
  --thumb-hover: rgba(27, 51, 75, 0.9);
}

/* ---------- Reset global & base ---------- */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top, rgba(101, 154, 255, 0.15), transparent 32%), linear-gradient(180deg, var(--bg), var(--bg-strong));
  color: var(--text);
  font-family: Inter, "Segoe UI", sans-serif;
}

/* ---------- Layout principal (.app-shell / .sidebar / .workspace) ---------- */

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1920px, 100%);
  height: calc(100vh - 48px);
  min-height: 420px;
  max-height: 820px;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-sizing: border-box;
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
}

body.theme-dark .sidebar,
body.theme-dark .workspace {
  background: rgba(13, 24, 33, 0.72);
}

body.theme-light .sidebar,
body.theme-light .workspace {
  background: linear-gradient(180deg, #f4f8ff, #edf5ff);
}

/* ---------- Recherche sidebar & profil utilisateur ---------- */

.sidebar__search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.sidebar__search-icon {
  font-size: 1rem;
  opacity: 0.8;
}

.sidebar__search input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.sidebar__search input::placeholder {
  color: var(--muted);
}

.User {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 8px 10px;
}

.User--clickable {
  cursor: pointer;
}

.User--clickable:hover {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
}

.User__mark {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
  font-weight: 800;
}

.User__text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  max-height: 42px;
  overflow: hidden;
}

.User__text strong {
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.User__text #userWidgetSub {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
  flex-wrap: wrap;
}

.User__action {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 8px;
  font: inherit;
  font-size: 0.64rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.User__action--login {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
  border-color: transparent;
}

.User__action--login:hover {
  filter: brightness(1.1);
}

.User__action--logout {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.User__action--logout:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.User__action--licenses {
  background: rgba(255, 255, 255, 0.03);
  color: var(--primary);
  border-color: var(--line);
}

.User__action--licenses:hover {
  color: white;
  border-color: var(--line-strong);
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

/* ---------- Liste des marques (sidebar) & logos ---------- */

.sidebar__group {
  margin-bottom: 20px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  flex: 1;
  min-height: 0;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-size: 0.68rem;
}

.tool-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  /* .app-shell (ancetre) a un backdrop-filter : sans isolation, faire
     defiler cette liste force Chromium a re-flouter tout le calque de
     .app-shell a chaque frame (lag ressenti en scrollant les composants).
     will-change promeut .tool-list sur son propre calque compose, dont
     le defilement ne touche plus au backdrop-filter parent. */
  will-change: transform;
}

.tool-list::-webkit-scrollbar {
  width: 8px;
}

.tool-list::-webkit-scrollbar-track {
  background: var(--track);
  border-radius: 999px;
}

.tool-list::-webkit-scrollbar-thumb {
  background: var(--thumb);
  border-radius: 999px;
}

.tool-list::-webkit-scrollbar-thumb:hover {
  background: var(--thumb-hover);
}

.tool {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg,transparent);
  color: var(--text);
  border-radius: 6px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

.brand-logo-box {
  width: 48px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
}

.brand-logo {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.brand-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool.is-active {
  border-color: var(--line-strong);
  background: rgba(74, 163, 255, 0.08);
}

.brand-devices {
  padding: 10px 0 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- Dossiers de composants (deduits du nom, sous chaque marque) ---------- */

.tool.folder-item {
  padding: 8px 10px;
  gap: 8px;
  font-size: 0.86rem;
}

.folder-count {
  color: var(--muted);
  font-size: 0.78rem;
  margin-left: auto;
}

.device-folder-list {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 8px 14px;
}

.device-folder-list.is-open {
  display: flex;
}

/* ---------- Liste des devices (sous chaque marque) ---------- */

.device-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
}

.device-item:hover {
  background: rgba(255,255,255,0.02);
}

.device-thumb {
  width: 40px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.device-meta {
  display: flex;
  flex-direction: column;
}

.device-name {
  font-size: 0.86rem;
  font-weight: 600;
}

/* ---------- Topbar & boutons ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;   
  font-size: clamp(1rem, 2vw, 1rem);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn__icon {
  width: 18px;
  height: 18px;
  flex: none;
}

#adminLink {
  padding: 8px;
  width: 38px;
  height: 38px;
  box-sizing: border-box;
  justify-content: center;
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
  border-color: transparent;
  font-weight: 700;
}

.btn--ghost {
  background: linear-gradient(135deg, var(--ghost), var(--ghost-strong));
  color: white;
  border-color: transparent;
  font-weight: 500;
}

.btn--secondary {
  background: var(--bg-strong);
  color: var(--text);
  border-color: var(--line-strong);
  font-weight: 500;
}

.btn--secondary:hover {
  border-color: var(--primary);
}

.btn--report {
  background: linear-gradient(135deg, var(--report), var(--report-strong));
  color: white;
  border-color: transparent;
  font-weight: 500;
  width: 100%;
  margin-top: 16px;
  cursor: pointer;
  display: block;
  box-sizing: border-box;
}

/* ---------- Interrupteur de theme (dark / light) ---------- */

.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 54px;
  height: 30px;
  border-radius: 999px;
  background: rgba(122, 142, 168, 0.24);
  border: 1px solid var(--line);
  cursor: pointer;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-slider {
  position: absolute;
  inset: 3px auto 3px 3px;
  width: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f4d35e, #f7c948);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease;
}

.theme-switch input:checked + .theme-slider {
  transform: translateX(24px);
  background: linear-gradient(135deg, #7cc7ff, #4aa3ff);
}

/* ---------- Canvas & board (pan / zoom / grille) ---------- */

.canvas {
  position: relative;
  flex: 1;
  min-height: 280px;
  margin: 20px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--canvas-bg);
  overflow: hidden;
  touch-action: none;
}

/* ---------- Onglets des feuilles du projet (style classeur) ---------- */

.sheet-tabs-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 20px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.sheet-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.sheet-tab {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: var(--panel);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  flex: none;
  max-width: 180px;
}

.sheet-tab:hover {
  color: var(--text);
  background: var(--ghost);
}

.sheet-tab.is-active {
  color: var(--text);
  background: var(--canvas-bg);
  border-color: var(--primary);
  font-weight: 600;
}

.sheet-tab.is-dragging {
  opacity: 0.5;
}

.sheet-tab__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-tab__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  line-height: 1;
  flex: none;
}

.sheet-tab__close:hover {
  background: var(--line-strong, var(--line));
  color: var(--text);
}

.sheet-tabs__add {
  appearance: none;
  border: 1px dashed var(--line-strong, var(--line));
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  width: 26px;
  height: 26px;
  flex: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sheet-tabs__add:hover {
  color: var(--text);
  border-color: var(--primary);
}

.board {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--board-bg);
}

.board__inner {
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  /* Pas de will-change: transform permanent ici : il épinglerait le calque
     sur un raster à l'échelle initiale et le zoom resterait flou. La classe
     .is-transforming (posée par board-state.js UNIQUEMENT pendant un
     pan/zoom, retirée au repos) donne la couche de composition pendant le
     mouvement, puis laisse le navigateur re-rasteriser net à l'arrêt. */
  transform-origin: 0 0;
  width: 1400px;
  height: 980px;
  aspect-ratio: 14 / 9.8;
  background:
    linear-gradient(var(--board-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--board-grid) 1px, transparent 1px),
    radial-gradient(circle at center, var(--board-glow), transparent 125%),
    var(--board-inner-bg);
  background-size: 28px 28px, 28px 28px, 100% 100%, 100% 100%;
}

.board__inner.is-transforming {
  will-change: transform;
}

/* ---------- Objet deplacable sur le board ---------- */

/* ---------- Rectangle de sélection (marquee) ---------- */

.board-marquee {
  position: absolute;
  border: 1px solid var(--primary, #4aa3ff);
  background: rgba(74, 163, 255, 0.15);
  pointer-events: none;
  z-index: 9999;
}

.board-object {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 150px;
  height: 90px;
  background: var(--canvas-bg);
  display: grid;
  place-items: center;
  cursor: grab;
  user-select: none;
}

.board-object:has(.board-object__image) {
  background: transparent;
}

.board-object:active {
  cursor: grabbing;
}

.board-object__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

/* ---------- Poignées de redimensionnement (coins, style Publisher) ---------- */

.board-object__handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--primary, #4aa3ff);
  border: 1px solid #fff;
  border-radius: 2px;
  z-index: 5;
  display: none;
  touch-action: none;
}

.board-object:hover .board-object__handle,
.board-object.is-selected .board-object__handle,
.board-text:hover .board-object__handle,
.board-text.is-selected .board-object__handle,
.board-zone:hover .board-object__handle,
.board-zone.is-selected .board-object__handle,
.board-pagelink:hover .board-object__handle,
.board-pagelink.is-selected .board-object__handle {
  display: block;
}

.board-object__handle--nw { top: -5px; left: -5px; cursor: nwse-resize; }
.board-object__handle--ne { top: -5px; right: -5px; cursor: nesw-resize; }
.board-object__handle--sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.board-object__handle--se { bottom: -5px; right: -5px; cursor: nwse-resize; }

/* ---------- Sélection (clic / Maj-clic sur un composant ou texte) ---------- */

.board-object.is-selected,
.board-text.is-selected,
.board-zone.is-selected,
.board-pagelink.is-selected {
  outline: 2px solid var(--primary, #4aa3ff);
  outline-offset: 2px;
}

/* ---------- Verrouillage (empêche déplacement / redimensionnement) ---------- */

.is-locked .board-object__handle {
  display: none !important;
}

.board-object.is-locked,
.board-text.is-locked,
.board-zone.is-locked,
.board-pagelink.is-locked {
  cursor: default;
}

.board-object__lock-badge {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 16px;
  height: 16px;
  padding: 2px;
  box-sizing: border-box;
  background: var(--primary, #4aa3ff);
  color: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 6;
}

/* ---------- Texte libre (déplaçable, éditable au double-clic, sans fond) ---------- */

.board-text {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 60px;
  min-height: 26px;
  padding: 4px 6px;
  background: transparent;
  border: 1px dashed transparent;
  border-radius: 4px;
  cursor: grab;
  user-select: none;
}

.board-text:hover:not(.is-selected) {
  border-color: var(--line-strong, var(--line));
}

.board-text:active {
  cursor: grabbing;
}

.board-text__content {
  width: 100%;
  height: 100%;
  font-size: 0.9rem;
  line-height: 1.3;
  color: var(--text);
  overflow: hidden;
  outline: none;
  word-break: break-word;
}

.board-text__content[contenteditable="true"] {
  cursor: text;
  user-select: text;
}

/* ---------- Zone dessinée (rectangle, trait/couleur/remplissage réglables) ---------- */

.board-zone {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  border: 2px solid #53c4ff;
  background: transparent;
  cursor: grab;
}

.board-zone:active {
  cursor: grabbing;
}

.board-zone--preview {
  pointer-events: none;
  opacity: 0.85;
}

/* ---------- Renvoi cliquable vers une autre feuille du projet ---------- */

.board-pagelink {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  display: grid;
  place-items: center;
  background: transparent;
  cursor: pointer;
  user-select: none;
}

.board-pagelink:active {
  cursor: grabbing;
}

.board-pagelink__icon {
  width: 70%;
  height: 70%;
  /* Couleur du cable relie (voir syncPageLinkColor dans
     js/canvas/page-link-tool.js), sinon la couleur primaire du theme. */
  color: var(--pagelink-color, var(--primary, #4aa3ff));
  pointer-events: none;
}

.board-pagelink__label {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- Ruban d'actions rapides (sous la topbar) ---------- */

.ribbon {
  display: flex;
  align-items: stretch;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 3px 10px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.ribbon::-webkit-scrollbar {
  height: 6px;
}

.ribbon::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

.ribbon__group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1px;
  padding: 2px 6px;
  border-right: 1px solid var(--line);
  flex: none;
}

.ribbon__group:last-child {
  border-right: none;
}

.ribbon__group--debug {
  margin-left: auto;
}

.ribbon__buttons {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-wrap: nowrap;
  justify-content: center;
}

.ribbon__label {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}

.ribbon__btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  width: 26px;
  height: 24px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  flex: none;
}

.ribbon__icon {
  width: 14px;
  height: 14px;
  flex: none;
}

.ribbon__btn:hover:not(:disabled) {
  background: var(--ghost);
  border-color: var(--line);
}

.ribbon__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ribbon__btn.is-active,
.ribbon__toggle:has(input:checked) {
  background: var(--ghost);
  border-color: var(--primary);
  color: var(--primary);
}

.ribbon__toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.ribbon__select,
.ribbon__number {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 0.68rem;
  padding: 3px 5px;
  height: 24px;
  box-sizing: border-box;
  cursor: pointer;
  flex: none;
}

.ribbon__select {
  width: 82px;
}

.ribbon__number {
  width: 42px;
  cursor: text;
}

.ribbon__select:disabled,
.ribbon__number:disabled,
.ribbon__color:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ribbon__color {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  flex: none;
}

.ribbon__color::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.ribbon__color::-webkit-color-swatch {
  border-radius: 6px;
  border: none;
}

.Connector {
  position: absolute;

  left: var(--connector-x);
  top: var(--connector-z);

  width: 10px;
  height: 10px;

  border-radius: 50%;
  background: red;
  cursor: pointer;

  /* Centrer le point */
  transform: translate(-50%, -50%);

  /* Visibles uniquement quand l'outil "Liens" est armé (voir
     js/canvas/link-tool.js qui pose .is-link-tool-armed sur #board) :
     le reste du temps ils sont cachés et ne captent aucun clic. */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.board.is-link-tool-armed .Connector {
  opacity: 1;
  pointer-events: auto;
}

/* Point de départ choisi pendant la création d'un lien (outil "Liens") */
.Connector.is-link-start {
  background: lime;
  box-shadow: 0 0 0 3px rgba(0, 255, 0, 0.35);
}

/* ---------- Calque de la grille logique (debug / visualisation) ---------- */

.grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

#gridOverlayLink {
  z-index: 500;
}

.board-object__label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}


/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  body {
    padding: 14px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 18px 16px;
  }

  .sidebar__group {
    margin-bottom: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
    padding: 20px 18px 16px;
  }

  .topbar__actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .canvas {
    min-height: 420px;
    margin: 12px;
  }
}

@media (max-width: 560px) {
  body {
    padding: 10px;
  }

  .app-shell {
    border-radius: 10px;
  }

  .User {
    margin-bottom: 18px;
  }

  .topbar__actions {
    gap: 8px;
  }

  .btn {
    flex: 1 1 auto;
  }

  .theme-switch {
    margin-left: auto;
  }

  .canvas {
    min-height: 340px;
    margin: 10px;
  }
}

/* ---------- Menu contextuel (clic droit sur composant) ---------- */

.context-menu {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.context-menu.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.context-menu__item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.context-menu__item:hover {
  background: var(--ghost);
}

/* ---------- Modal d'édition des informations ---------- */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--panel);
  border-radius: 12px;
  padding: 24px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.is-visible .modal-content {
  transform: scale(1);
}

.modal-title {
  margin: 0 0 20px 0;
  font-size: 20px;
  color: var(--text);
}

.modal-body {
  margin-bottom: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.form-group label input[type="checkbox"] {
  margin-right: 8px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-strong);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-input::placeholder {
  color: var(--muted);
}

textarea.form-input {
  resize: vertical;
  min-height: 90px;
}

.port-group {
  padding: 12px;
  background: var(--bg-strong);
  border-radius: 8px;
  margin-bottom: 12px;
}

.port-group h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.port-group .form-input {
  margin-bottom: 8px;
}

.port-group .form-input:last-child {
  margin-bottom: 0;
}

/* ---------- Modales Enregistrer / Ouvrir un projet ---------- */

.project-modal__hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.project-modal__hint a {
  color: var(--primary);
}

.project-modal__message {
  margin: 0 0 14px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-strong);
}

.project-modal__message--success {
  color: #3ecf6f;
}

.project-modal__message--error {
  color: #ff6b6b;
}

.project-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.project-modal-table-wrap {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.project-modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.project-modal-table th,
.project-modal-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.project-modal-table td:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- Étiquettes d'information des composants ---------- */

/* Déplaçable (glisser) et redimensionnable (molette) : voir la
   délégation d'événements sur `document` dans component-info.js
   (resolveLabelTarget / pointerdown / wheel). */
.component-info-label {
  position: absolute;
  left: 100%;
  top: 0;
  margin-left: 12px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text);
  white-space: nowrap;
  pointer-events: auto;
  cursor: move;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.component-info-label strong {
  color: var(--primary);
  display: block;
  margin-bottom: 4px;
}

.port-info-badge {
  position: absolute;
  font-size: 11px;
  line-height: 1.3;
  color: var(--text);
  white-space: nowrap;
  pointer-events: auto;
  cursor: move;

  z-index: 600;

  text-shadow:
    -1px -1px 2px var(--panel), 1px -1px 2px var(--panel),
    -1px 1px 2px var(--panel), 1px 1px 2px var(--panel),
    0 0 4px var(--panel);
}

