/* ============================================================
   Infini XP — fenêtres, menus, barre d'outils, plateau
   ============================================================ */

/* ------------------------------------------------------------
   Fenêtre générique (Luna)
   ------------------------------------------------------------ */
.win {
  position: absolute;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: #ece9d8;
  border: 3px solid #0831d9;
  border-top: 0;
  border-radius: 8px 8px 0 0;
  box-shadow: 2px 3px 14px rgba(0, 0, 0, .5), inset 0 0 0 1px #6aa6ff;
  min-width: 280px;
  min-height: 180px;
  overflow: hidden;
}

.win.minimized { display: none; }

.win.maxed {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}

#win-canvas { left: max(80px, 7vw); top: 6vh; width: min(1020px, calc(100vw - 150px)); height: min(680px, calc(100vh - 120px)); }
#win-people { left: 220px; top: 100px; width: 500px; height: 430px; }
#win-help { left: 260px; top: 70px; width: 580px; height: 500px; }

/* barre de titre */
.win-title {
  height: 27px;
  flex: 0 0 27px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 3px 0 5px;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, #0f8dff 0%, #0a6ae8 8%, #1868e6 40%, #1a5fe0 88%, #0a3fc0 100%);
  color: #fff;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, .55);
  cursor: default;
  touch-action: none;
}

.win:not(.active) .win-title {
  background: linear-gradient(180deg, #a8c3ee, #86a5da 45%, #7492c8 100%);
  color: #eef3ff;
}

.win-title-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.win-ic {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35));
}

.win-btns { margin-left: auto; display: flex; gap: 3px; align-items: center; }

.wbtn {
  width: 21px;
  height: 19px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .92);
  border-radius: 3px;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: linear-gradient(180deg, #5aa4ff 0%, #2a70e0 18%, #1b5fd6 55%, #0f4bb8 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 0 0 1px rgba(4, 40, 120, .35);
}

.wbtn svg {
  width: 10px;
  height: 10px;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .35));
}

.wbtn:hover {
  background: linear-gradient(180deg, #7cb8ff 0%, #3b83f0 18%, #2a6fe0 55%, #1a5ac4 100%);
}

.wbtn:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .35);
}

.wbtn.close { background: linear-gradient(180deg, #f9b394 0%, #e0613f 18%, #d5492b 55%, #a82a12 100%); }
.wbtn.close:hover { background: linear-gradient(180deg, #ffc9b1 0%, #ef7957 18%, #e05b3c 55%, #b93318 100%); }

.ico-restore { display: none; }
.win.maxed .ico-max { display: none; }
.win.maxed .ico-restore { display: block; }

/* menu */
.win-menubar {
  flex: 0 0 22px;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0 3px;
  background: #ece9d8;
  border-bottom: 1px solid #d5d2c4;
}

.menu { position: relative; }

.menu-btn {
  border: 0;
  background: transparent;
  padding: 2px 7px;
  font-size: 11px;
  cursor: default;
  border-radius: 2px;
}

.menu-btn:hover, .menu.open > .menu-btn { background: #316ac5; color: #fff; }

.menu-pop {
  display: none;
  position: absolute;
  left: 0;
  top: 100%;
  min-width: 218px;
  padding: 2px;
  background: #fff;
  border: 1px solid #aca899;
  box-shadow: 3px 3px 6px rgba(0, 0, 0, .35);
  z-index: 50;
}

.menu.open .menu-pop { display: block; }

.menu-pop button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 18px 4px 22px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 11px;
  cursor: default;
}

.menu-pop button:hover { background: #316ac5; color: #fff; }
.menu-pop hr { margin: 3px 2px; border: 0; border-top: 1px solid #d5d2c4; }
.menu-key { color: #7a7a6a; font-size: 10px; }
.menu-pop button:hover .menu-key { color: #dbe7ff; }

/* barre d'outils */
.toolbar {
  flex: 0 0 32px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 5px;
  border-bottom: 1px solid #aca899;
  background: linear-gradient(#fdfcf8, #ece9d8 60%, #e4e0d0);
}

.tbtn {
  height: 25px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  cursor: default;
  font-size: 11px;
}

.tbtn svg { width: 16px; height: 16px; flex: 0 0 16px; }
.tbtn:hover { border-color: #98b6e4; background: linear-gradient(#fff, #dbe8fb); }
.tbtn:active { background: #c9dcf7; }
.tsep { width: 1px; align-self: stretch; margin: 2px 4px; background: #aca899; box-shadow: 1px 0 0 #fff; }

/* corps + barre d'état */
.win-body { flex: 1; min-height: 0; display: flex; }
.canvas-body { padding: 3px; }
.canvas-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  background: #fff;
  border: 1px solid #7f9db9;
  box-shadow: inset 1px 1px 0 #fff;
  overflow: hidden;
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.statusbar {
  flex: 0 0 21px;
  display: flex;
  align-items: stretch;
  gap: 3px;
  padding: 2px 3px;
  border-top: 1px solid #aca899;
  background: #ece9d8;
}

.sb-panel {
  display: flex;
  align-items: center;
  padding: 0 6px;
  border: 1px solid #aca899;
  border-color: #aca899 #fff #fff #aca899;
  background: #ece9d8;
  font-size: 11px;
  color: #3b3b33;
  white-space: nowrap;
  overflow: hidden;
}

.sb-grow { flex: 1; min-width: 0; text-overflow: ellipsis; }
.sb-zoom { min-width: 64px; justify-content: center; }

/* ------------------------------------------------------------
   Fenêtre collaborateurs
   ------------------------------------------------------------ */
.people-body { padding: 4px; gap: 4px; }

.people-left {
  width: 184px;
  flex: 0 0 184px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 5px;
  border-right: 1px solid #d5d2c4;
}

.field-label { font-size: 11px; color: #3b3b33; margin-top: 1px; }

.row { display: flex; gap: 4px; align-items: center; }

.swatches { display: flex; gap: 4px; flex-wrap: wrap; }

.swatch {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid #5a5a5a;
  border-radius: 2px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5);
}

.swatch.on { outline: 2px solid #275ecb; outline-offset: 1px; }

.peer-list {
  list-style: none;
  margin: 0;
  padding: 2px;
  border: 1px solid #7f9db9;
  background: #fff;
  flex: 1;
  min-height: 54px;
  overflow: auto;
}

.peer { display: flex; align-items: center; gap: 6px; padding: 3px 5px; border-radius: 2px; }
.peer:hover { background: #e8f0fd; }
.peer.me { background: #f2f7ff; }

.dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}

.pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag {
  font-size: 9px;
  color: #275ecb;
  background: #dce9ff;
  padding: 0 4px;
  border-radius: 8px;
}

.chat-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.chat-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 5px;
  border: 1px solid #7f9db9;
  background: #fff;
  user-select: text;
}

.msg { margin-bottom: 7px; }
.msg .meta { display: flex; gap: 6px; align-items: baseline; font-size: 10px; }
.msg .who { font-weight: bold; }
.msg .time { color: #8a8a7a; }

.msg .bubble {
  margin-top: 2px;
  padding: 3px 6px;
  background: #f2f4f8;
  border: 1px solid #dbe2ee;
  border-radius: 3px;
  word-wrap: break-word;
  user-select: text;
}

.msg.mine .bubble { background: #e8f2ff; border-color: #c9ddf7; }

.chat-form { display: flex; gap: 4px; }
.chat-form .xp-btn { min-width: 72px; }

/* ------------------------------------------------------------
   Fenêtre d'aide
   ------------------------------------------------------------ */
.help-body { padding: 0; background: #fff; overflow: auto; }
.help-page { padding: 14px 18px 26px; user-select: text; }

.help-page h2 {
  margin: 0 0 4px;
  font: bold 19px "Trebuchet MS", Tahoma, sans-serif;
  color: #0b3f9c;
}

.help-page h3 {
  margin: 18px 0 6px;
  font-size: 12px;
  color: #0b3f9c;
  border-bottom: 1px solid #dbe3f2;
  padding-bottom: 3px;
}

.help-page p { margin: 6px 0; line-height: 1.55; color: #333; }
.help-page strong { color: #16335f; }

.help-page kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid #b9b9a8;
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #f6f4ea;
  font: 10px Tahoma, sans-serif;
  color: #333;
}

.help-list { margin: 6px 0; padding-left: 18px; line-height: 1.7; }
.help-list li { color: #333; }

.help-note {
  margin: 12px 0;
  padding: 8px 10px;
  background: #ffffe1;
  border: 1px solid #d6d6a8;
  color: #4a4a2a;
  line-height: 1.5;
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */
@media (max-width: 720px) {
  #win-canvas,
  #win-people,
  #win-help {
    left: 4px !important;
    top: 4px !important;
    width: calc(100% - 8px) !important;
    height: calc(100% - 8px) !important;
  }

  .win { border-width: 2px; }
  .toolbar { overflow-x: auto; }
  .tbtn span { display: none; }
  .tbtn { padding: 0 8px; }
  .people-body { flex-direction: column; }
  .people-left {
    width: auto;
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid #d5d2c4;
    padding-bottom: 6px;
  }
  .people-left .field-label { width: 100%; }
  .people-left .peer-list { max-height: 90px; min-height: 46px; flex: 1 0 100%; }
  .chat-log { min-height: 90px; }
}
