/* =========================================================
   ROOM 2 — ADMINISTRATOR PROJECT LAYOUT STUDIO

   The editor is created only when the address contains
   ?layout=1 and the Administrator account is active.
   These styles do not change normal Teacher or Student mode.
   ========================================================= */

.layout-editor-panel,
.layout-editor-panel * {
  box-sizing: border-box;
}

.layout-studio-launcher {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 4500;
  min-width: 132px;
  min-height: 50px;
  padding: 10px 18px;
  border: 3px solid #174f72;
  border-radius: 14px;
  background: #237cab;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
  color: #fff;
  font: 700 16px/1.1 Arial, sans-serif;
  cursor: pointer;
}

html[data-input-mode="mouse"] .layout-studio-launcher:hover,
.layout-studio-launcher:focus-visible {
  background: #195f84;
  outline: 4px solid rgba(35, 124, 171, .32);
  outline-offset: 3px;
}

.layout-editor-panel {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 5000;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  border: 3px solid #174f72;
  border-radius: 16px;
  background: rgba(255, 255, 255, .985);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .35);
  color: #173a4e;
  font-family: Arial, sans-serif;
  font-size: 14px;
  line-height: 1.25;
}

.layout-editor-panel.panel-left {
  right: auto;
  left: 12px;
}

.layout-editor-panel.collapsed {
  width: auto;
  overflow: hidden;
}

.layout-editor-panel.collapsed .layout-editor-body {
  display: none;
}

.layout-editor-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
  border-bottom: 2px solid #8ebed6;
  background: #dff3fd;
}

.layout-editor-history-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin: 0 0 12px;
}

.layout-pick-image {
  width: 100%;
  margin: 0 0 12px;
}

.layout-editor-title {
  margin: 0;
  font: 700 17px/1.1 Arial, sans-serif;
}

.layout-editor-icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid #174f72;
  border-radius: 9px;
  background: #fff;
  color: #174f72;
  font: 700 19px/1 Arial, sans-serif;
  cursor: pointer;
}

html[data-input-mode="mouse"] .layout-editor-icon-button:hover,
.layout-editor-icon-button:focus-visible {
  background: #c9ecfb;
}

.layout-editor-body {
  padding: 12px;
}

.layout-editor-intro {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.4;
}

.layout-editor-selectors {
  display: grid;
  gap: 9px;
  margin-bottom: 12px;
}

.layout-editor-field {
  display: grid;
  gap: 4px;
}

.layout-editor-field > span {
  font-weight: 700;
}

.layout-editor-field select,
.layout-editor-number {
  width: 100%;
  min-height: 38px;
  padding: 6px 8px;
  border: 2px solid #89b8d0;
  border-radius: 9px;
  background: #fff;
  color: #173a4e;
  font: 600 13px Arial, sans-serif;
}

.layout-editor-field select:focus-visible,
.layout-editor-number:focus-visible,
.layout-editor-range:focus-visible {
  outline: 3px solid rgba(26, 121, 173, .35);
  outline-offset: 2px;
}

.layout-editor-context {
  min-height: 36px;
  margin: 0 0 12px;
  padding: 8px 9px;
  border: 1px solid #b9d9e8;
  border-radius: 9px;
  background: #f3fbff;
  font-size: 12px;
  line-height: 1.35;
}

.layout-editor-context.unavailable {
  border-color: #d6a947;
  background: #fff8e7;
  color: #704a00;
}

.layout-editor-controls {
  display: grid;
  gap: 9px;
  margin-bottom: 12px;
}

.layout-editor-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: 5px 9px;
  align-items: center;
  padding: 8px;
  border: 1px solid #c0dce9;
  border-radius: 10px;
  background: #fbfeff;
}

.layout-editor-control-label {
  font-weight: 700;
  font-size: 13px;
}

.layout-editor-number-wrap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 3px;
}

.layout-editor-number {
  min-width: 0;
  min-height: 34px;
  padding: 5px;
  text-align: right;
}

.layout-editor-unit {
  min-width: 20px;
  color: #4b6573;
  font-size: 11px;
}

.layout-editor-range {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: #237cab;
  cursor: pointer;
}

.layout-editor-control-select {
  grid-column: 1 / -1;
  min-height: 38px;
  padding: 6px 8px;
  border: 2px solid #89b8d0;
  border-radius: 9px;
  background: #fff;
  color: #173a4e;
  font: 600 13px Arial, sans-serif;
}

.layout-editor-protected {
  margin: 0 0 12px;
  padding: 9px;
  border-left: 5px solid #3383ad;
  border-radius: 8px;
  background: #eaf7fd;
  font-size: 11px;
  line-height: 1.4;
}

.layout-editor-reset-actions,
.layout-editor-export-actions,
.layout-editor-preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 8px;
}

.layout-editor-export-actions {
  margin-top: 12px;
}

.layout-editor-copy-range {
  margin-top: 12px;
}

.layout-editor-preview-actions {
  margin-top: 12px;
}

.layout-editor-button {
  min-height: 41px;
  padding: 7px;
  border: 2px solid #235a7e;
  border-radius: 10px;
  background: #edf8fd;
  color: #164f73;
  font: 700 12px Arial, sans-serif;
  cursor: pointer;
}

html[data-input-mode="mouse"] .layout-editor-button:hover,
.layout-editor-button:focus-visible {
  background: #d4effb;
}

.layout-editor-button.primary {
  background: #237cab;
  color: #fff;
}

html[data-input-mode="mouse"] .layout-editor-button.primary:hover,
.layout-editor-button.primary:focus-visible {
  background: #195f84;
}

body.layout-image-picker-active img[data-layout-image-key] {
  cursor: crosshair !important;
  outline: 4px dashed rgba(255, 153, 0, .8) !important;
  outline-offset: 3px !important;
}

.layout-editor-button.danger {
  border-color: #9b4545;
  background: #fff2f2;
  color: #772b2b;
}

.layout-editor-button.wide {
  grid-column: 1 / -1;
}

.layout-editor-button:disabled,
.layout-editor-field select:disabled,
.layout-editor-control input:disabled,
.layout-editor-control select:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.layout-editor-status {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: #285b75;
  font-size: 12px;
  text-align: center;
}

body.layout-editor-active .layout-editor-selected {
  outline: 4px solid rgba(27, 131, 187, .9) !important;
  outline-offset: 4px !important;
}

body.layout-editor-active .layout-editor-selected.layout-editor-current-item {
  outline-color: rgba(183, 70, 187, .95) !important;
}

.layout-preview-overlay,
.layout-preview-overlay * {
  box-sizing: border-box;
}

.layout-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 7000;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 12px;
  background: rgba(10, 28, 40, .92);
  font-family: Arial, sans-serif;
}

.layout-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 12px 12px 0 0;
  background: #e7f5fc;
  color: #173a4e;
}

.layout-preview-toolbar strong {
  margin-right: auto;
}

.layout-preview-toolbar select,
.layout-preview-toolbar button {
  min-height: 38px;
  padding: 6px 10px;
  border: 2px solid #235a7e;
  border-radius: 9px;
  background: #fff;
  color: #164f73;
  font: 700 13px Arial, sans-serif;
}

.layout-preview-toolbar button {
  cursor: pointer;
}

.layout-preview-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 4px solid #9fc8dc;
  border-radius: 0 0 12px 12px;
  background:
    linear-gradient(45deg, #253b48 25%, transparent 25%),
    linear-gradient(-45deg, #253b48 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #253b48 75%),
    linear-gradient(-45deg, transparent 75%, #253b48 75%),
    #1c303c;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.layout-preview-frame-wrap {
  position: relative;
  flex: 0 0 auto;
}

.layout-preview-frame {
  position: absolute;
  inset: 0 auto auto 0;
  border: 0;
  background: #fff;
  transform-origin: 0 0;
}

@media (max-width: 700px) {
  .layout-editor-panel {
    width: min(330px, calc(100vw - 16px));
    top: 8px;
    right: 8px;
    max-height: calc(100vh - 16px);
  }

  .layout-editor-panel.panel-left {
    right: auto;
    left: 8px;
  }
}
