/* Level Editor v1 -- layout + System 7 / platinum aesthetic. */
/* P1 scope: no JS hooks, no animations beyond focus states. */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #f0f0f0;
  color: #111;
  font-family: 'Courier New', Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* 3-pane app shell. */
#le-app {
  display: flex;
  flex-direction: row;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ---------- Palette (left pane) ---------- */
#le-palette {
  flex: 0 0 200px;
  width: 200px;
  background: #ffffff;
  border-right: 1px solid #999;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px;
}

.le-palette-group {
  margin-bottom: 10px;
  border: 1px solid #999;
  background: #ffffff;
}

.le-palette-group-title {
  margin: 0;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: bold;
  background: #e0e0e0;
  border-bottom: 1px solid #999;
  letter-spacing: 0.5px;
}

.le-palette-entries {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 6px;
}

.le-palette-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 60px;
  height: 60px;
  padding: 2px;
  background: #f5f5f5;
  border: 1px solid #999;
  cursor: pointer;
  text-align: center;
}

.le-palette-entry:hover {
  background: #ffffff;
}

.le-palette-entry:focus {
  outline: 2px solid #1e3a8a;
  outline-offset: -2px;
}

.le-palette-entry.is-active {
  background: #1e3a8a;
  color: #ffffff;
  border-color: #1e3a8a;
}

.le-palette-entry-sprite {
  display: block;
  width: 32px;
  height: 32px;
  background: #cccccc;
  border: 1px solid #888;
  margin-bottom: 2px;
}

.le-palette-entry.is-active .le-palette-entry-sprite {
  border-color: #ffffff;
}

.le-palette-entry-label {
  display: block;
  font-size: 9px;
  line-height: 1.1;
  word-break: break-word;
}

/* ---------- Center column ---------- */
#le-center {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f0f0f0;
  overflow: hidden;
}

/* Metadata form (top toolbar). */
#le-metadata {
  flex: 0 0 auto;
  padding: 6px 8px;
  background: #ffffff;
  border-bottom: 1px solid #999;
}

.le-metadata-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 4px;
}

.le-metadata-row:last-child {
  margin-bottom: 0;
}

.le-metadata-field {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-width: 80px;
}

.le-metadata-field-wide {
  flex: 1 1 200px;
  min-width: 200px;
}

.le-metadata-field-fill {
  flex: 1 1 auto;
  min-width: 200px;
}

.le-metadata-field > span {
  font-size: 10px;
  color: #555;
  margin-bottom: 2px;
}

.le-metadata-field input,
.le-metadata-field select,
.le-metadata-field textarea {
  padding: 3px 4px;
  background: #ffffff;
  border: 1px solid #999;
  border-radius: 0;
  width: 100%;
}

.le-metadata-field input:focus,
.le-metadata-field select:focus,
.le-metadata-field textarea:focus {
  outline: none;
  border-color: #1e3a8a;
}

.le-metadata-field input[readonly] {
  background: #eeeeee;
  color: #666;
}

.le-metadata-field textarea {
  resize: vertical;
  min-height: 30px;
  font-family: inherit;
}

/* Camera viewport slider. */
#le-camera-slider-wrap {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: #ffffff;
  border-bottom: 1px solid #999;
}

.le-camera-slider-hint {
  flex: 0 0 auto;
  font-size: 10px;
  color: #555;
  white-space: nowrap;
}

#le-camera-slider {
  flex: 1 1 auto;
  width: 100%;
  height: 18px;
  cursor: pointer;
}

/* Grid (the canvas). */
#le-grid-wrap {
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  background: #ffffff;
  border-bottom: 1px solid #999;
  padding: 8px;
  min-height: 260px;
}

#le-grid {
  display: block;
  height: 240px;
  background: #f8f8f8;
  border: 1px solid #999;
  image-rendering: pixelated;
}

/* Tabs. */
#le-tabs {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  gap: 0;
  background: #e0e0e0;
  border-bottom: 1px solid #999;
  padding: 0 8px;
}

.le-tab {
  padding: 6px 16px;
  background: #e0e0e0;
  border: 1px solid #999;
  border-bottom: none;
  margin-right: 2px;
  margin-top: 4px;
  cursor: pointer;
  font-weight: normal;
}

.le-tab:hover {
  background: #ffffff;
}

.le-tab.is-active {
  background: #ffffff;
  font-weight: bold;
  border-bottom: 3px solid #1e3a8a;
  margin-bottom: -1px;
}

/* Sim toolbar (P3). Sits between #le-tabs and #le-bottom-toolbar. */
#le-sim-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: #fffaf0;
  border-bottom: 1px solid #999;
  font-size: 11px;
}

#le-sim-toolbar button {
  padding: 3px 12px;
  background: #f5f5f5;
  border: 1px solid #999;
  cursor: pointer;
}

#le-sim-toolbar button:hover {
  background: #ffffff;
}

#le-sim-toolbar button:active {
  background: #d0d0d0;
}

#le-sim-toolbar button:focus {
  outline: 2px solid #1e3a8a;
  outline-offset: -2px;
}

#le-sim-toolbar button.is-sim-active {
  background: #1e3a8a;
  color: #ffffff;
  border-color: #1e3a8a;
}

#le-sim-phase {
  font-weight: bold;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  background: #ffffff;
  border: 1px solid #999;
  min-width: 120px;
  text-align: center;
}

#le-sim-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

/* Bottom toolbar. */
#le-bottom-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  gap: 6px;
  padding: 6px 8px;
  background: #ffffff;
  border-bottom: 1px solid #999;
}

#le-bottom-toolbar button {
  padding: 4px 14px;
  background: #f5f5f5;
  border: 1px solid #999;
  cursor: pointer;
}

#le-bottom-toolbar button:hover {
  background: #ffffff;
}

#le-bottom-toolbar button:active {
  background: #d0d0d0;
}

#le-bottom-toolbar button:focus {
  outline: 2px solid #1e3a8a;
  outline-offset: -2px;
}

/* Warnings panel. */
#le-warnings {
  flex: 0 0 auto;
  max-height: 180px;
  overflow-y: auto;
  background: #fef2f2;
  border: 1px solid #dc2626;
  margin: 0;
}

#le-warnings-header {
  padding: 4px 8px;
  font-weight: bold;
  font-size: 11px;
  color: #dc2626;
  background: #fee2e2;
  border-bottom: 1px solid #dc2626;
  cursor: pointer;
  user-select: none;
}

#le-warnings-list {
  padding: 6px 8px;
}

#le-warnings.is-collapsed #le-warnings-list {
  display: none;
}

#le-warnings-list .le-warning,
#le-warnings-list .le-warning-row {
  padding: 3px 0;
  border-bottom: 1px dotted #fca5a5;
  cursor: pointer;
}

#le-warnings-list .le-warning:last-child,
#le-warnings-list .le-warning-row:last-child {
  border-bottom: none;
}

#le-warnings-list .le-warning:hover,
#le-warnings-list .le-warning-row:hover {
  background: #fee2e2;
}

#le-warnings-list .le-warning-severity {
  display: inline-block;
  margin-right: 6px;
  font-weight: bold;
}

#le-warnings-list .le-warning-message {
  display: inline;
}

.le-warning.le-warning-error .le-warning-severity {
  color: #dc2626;
}

.le-warning.le-warning-warn .le-warning-severity {
  color: #b45309;
}

.le-warning.le-warning-info .le-warning-severity {
  color: #1e3a8a;
}

.le-warning-severity-error {
  color: #dc2626;
  font-weight: bold;
}

.le-warning-severity-warn {
  color: #b45309;
}

.le-warning-severity-info {
  color: #1e3a8a;
}

/* ---------- Props pane (right) ---------- */
#le-props {
  flex: 0 0 280px;
  width: 280px;
  background: #ffffff;
  border-left: 1px solid #999;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
}

#le-props-empty {
  padding: 12px;
  color: #777;
  font-style: italic;
  text-align: center;
  border: 1px dashed #ccc;
}

#le-props-form {
  display: none;
}

#le-props-form.is-active {
  display: block;
}

#le-props-form .le-props-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
}

#le-props-form .le-props-field > label {
  font-size: 10px;
  color: #555;
  margin-bottom: 2px;
  font-weight: bold;
}

#le-props-form .le-props-field > label .le-required {
  color: #dc2626;
  margin-left: 2px;
}

#le-props-form .le-props-field input,
#le-props-form .le-props-field select,
#le-props-form .le-props-field textarea {
  width: 100%;
  padding: 3px 4px;
  background: #ffffff;
  border: 1px solid #999;
  border-radius: 0;
}

#le-props-form .le-props-field textarea {
  resize: vertical;
  min-height: 50px;
  font-family: inherit;
}

#le-props-form .le-props-field input:focus,
#le-props-form .le-props-field select:focus,
#le-props-form .le-props-field textarea:focus {
  outline: none;
  border-color: #1e3a8a;
}

#le-props-form .le-props-field input.is-invalid,
#le-props-form .le-props-field textarea.is-invalid,
#le-props-form .le-props-field select.is-invalid {
  border-color: #dc2626;
  background: #fef2f2;
}

#le-props-form .le-props-field input[type="checkbox"] {
  width: auto;
}

#le-props-form .le-props-header {
  font-weight: bold;
  font-size: 12px;
  padding-bottom: 4px;
  margin-bottom: 8px;
  border-bottom: 1px solid #999;
  color: #1e3a8a;
}

/* ---------- Status feedback bits ---------- */
.is-lit {
  color: #16a34a;
}

.is-error {
  color: #dc2626;
}

#le-toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: #1e3a8a;
  color: #ffffff;
  border: 1px solid #1e3a8a;
  box-shadow: 2px 2px 0 #999;
  z-index: 100;
  font-size: 12px;
}

#le-toast.is-error {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

#le-toast.is-success {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

/* ---------- Scrollbar polish (webkit only, harmless elsewhere) ---------- */
#le-palette::-webkit-scrollbar,
#le-props::-webkit-scrollbar,
#le-grid-wrap::-webkit-scrollbar,
#le-warnings::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

#le-palette::-webkit-scrollbar-track,
#le-props::-webkit-scrollbar-track,
#le-grid-wrap::-webkit-scrollbar-track,
#le-warnings::-webkit-scrollbar-track {
  background: #e0e0e0;
}

#le-palette::-webkit-scrollbar-thumb,
#le-props::-webkit-scrollbar-thumb,
#le-grid-wrap::-webkit-scrollbar-thumb,
#le-warnings::-webkit-scrollbar-thumb {
  background: #999;
  border: 1px solid #777;
}
