
/* ---------- 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.22);
  --report: rgba(74, 163, 255, 0.22);
  --report-strong: rgba(74, 163, 255, 0.22);
  --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: 600px;
  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;
  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__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: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.User__text #userWidgetSub {
  display: block;
  line-height: 1;
}

.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);
}

/* ---------- 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;
}

.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;
}

/* ---------- 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;
}

.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--report {
  background: linear-gradient(135deg, var(--report), var(--report-strong));
  color: white;
  border-color: transparent;
  font-weight: 500;
  width: 100%;
  margin-top: auto;
  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: 700px;
  margin: 20px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--canvas-bg);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.canvas:active {
  cursor: grabbing;
}

.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;
  will-change: transform;
  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%;
}

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

.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:active {
  cursor: grabbing;
}

.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;
  }
}
