/* libs/ui/layout.css
   2012-era Roblox Studio look: light Windows theme, blue panel caption bars,
   Explorer + Properties docked right, classic controls. */

:root {
  --menu-h: 23px;              /* menu bar height */
  --toolbar-h: 62px;           /* icon toolbar (two rows) */
  --ribbon-h: 85px;            /* total header height = menu + toolbar */
  --panel-w: 280px;

  /* Light Windows toolbar */
  --bar-1: #eef0f2;
  --bar-2: #d3d8df;
  --bar-border: #8c95a0;

  /* Blue panel caption bars (the signature Studio blue) */
  --caption-1: #c2dbf5;
  --caption-2: #7faae0;
  --caption-border: #5b87bf;
  --caption-text: #14304f;

  --panel-bg: #f4f5f7;
  --panel-border: #9aa3b0;
  --panel-text: #1a1a1a;
  --muted-text: #5f6b78;

  --row-alt: #e9edf3;
  --field-bg: #ffffff;
  --field-border: #aab2bf;

  --sel-bg: #cfe3fb;           /* classic Windows selection */
  --sel-border: #7aa7dd;
}

body { margin: 0; overflow: hidden; font-family: "Segoe UI", Tahoma, system-ui, sans-serif; }
canvas { display: block; }

/* ---------- Menu bar (File / Edit / View / ...) ---------- */
#menuBar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--menu-h);
  background: linear-gradient(to bottom, #fbfbfa, #eceae3);
  border-bottom: 1px solid #c8c8c0;
  display: flex;
  align-items: stretch;
  padding: 0 2px;
  z-index: 11;
  font-size: 12px;
}
#menuBar .menu-top {
  background: transparent;
  border: 1px solid transparent;
  color: #1a1a1a;
  padding: 0 9px;
  cursor: default;
  font-size: 12px;
}
#menuBar .menu-top:hover, #menuBar .menu-top.open {
  background: #cfe3fb;
  border-color: #7aa7dd;
}
.menu-dropdown {
  position: fixed;
  min-width: 200px;
  background: #f7f7f4;
  border: 1px solid #8c95a0;
  box-shadow: 2px 2px 6px rgba(0,0,0,0.3);
  padding: 2px;
  z-index: 9999;
  font-size: 12px;
  color: #1a1a1a;
}
.menu-dropdown .menu-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 4px;
  cursor: default;
  white-space: nowrap;
}
.menu-dropdown .menu-item:hover:not(.disabled) { background: #cfe3fb; outline: 1px solid #7aa7dd; outline-offset: -1px; }
.menu-dropdown .menu-item.disabled { color: #9aa0a8; }
.menu-dropdown .menu-check { width: 14px; text-align: center; color: #14304f; }
.menu-dropdown .menu-label { flex: 1; }
.menu-dropdown .menu-accel { margin-left: 24px; color: #7a828c; }
.menu-dropdown .menu-item.disabled .menu-accel { color: #b3b8bf; }
.menu-dropdown .menu-sep { height: 1px; background: #c8c8c0; margin: 3px 2px; }

/* ---------- Top toolbar (light Windows strip, two icon rows) ---------- */
#topToolbar {
  position: absolute;
  top: var(--menu-h); left: 0; right: 0;
  height: var(--toolbar-h);
  background: linear-gradient(to bottom, var(--bar-1), var(--bar-2));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 2px 6px;
  z-index: 10;
  border-bottom: 1px solid var(--bar-border);
}
#topToolbar .tb-row { display: flex; align-items: center; gap: 2px; height: 26px; }
#topToolbar .tb-sep { width: 1px; height: 20px; background: #b7b7b0; margin: 0 4px; }
#topToolbar label { color: #2a2a2a; font-size: 12px; margin-left: 4px; }

/* Icon buttons */
#topToolbar .tb-btn {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
}
#topToolbar .tb-btn svg { width: 16px; height: 16px; display: block; }
#topToolbar .tb-btn:hover:not(.disabled) { background: #e2ecf8; border-color: #7aa7dd; }
#topToolbar .tb-btn:active:not(.disabled) { background: #cfe0f5; }
#topToolbar .tb-btn.active { background: linear-gradient(to bottom, #fde9a9, #fbcf6b); border-color: #d9a441; }
#topToolbar .tb-btn.disabled { opacity: 0.4; cursor: default; }
#topToolbar input[type="number"] {
  width: 52px;
  background: var(--field-bg);
  color: var(--panel-text);
  border: 1px solid var(--field-border);
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 12px;
}

/* ---------- Docking framework (managed by ui/dock.js) ----------
   Properties / Explorer / Output live in dock "groups" arranged in a split tree
   around the centre #mdiArea, or in floating windows. The dock manager positions
   every group/splitter inline; a group is a flex column: blue caption bar (drag =
   move whole group) on top, content host, optional tab strip at the bottom. */
.dock-group {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  color: var(--panel-text);
  border: 1px solid var(--panel-border);
  box-sizing: border-box;
  overflow: hidden;
  font-size: 12px;
  z-index: 8;
}
.dock-group.floating { border: 1px solid #5b87bf; }

/* Caption bar = drag handle for the whole group */
.dock-cap {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--caption-text);
  background: linear-gradient(to bottom, var(--caption-1), var(--caption-2));
  border-bottom: 1px solid var(--caption-border);
  cursor: move;
  -webkit-user-select: none;
  user-select: none;
}
.dock-cap-icon { width: 14px; height: 14px; flex: none; }
.dock-cap-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-cap-btn {
  margin-left: auto;
  width: 16px; height: 15px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--caption-text);
  font-size: 11px; line-height: 1; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.dock-cap-btn:hover { background: rgba(255, 255, 255, 0.55); border-color: var(--caption-border); }
.dock-cap-close:hover { background: #e8736b; color: #fff; border-color: #c0392b; }

/* Content host: the active panel body fills it (others hidden) */
.dock-host { flex: 1; position: relative; overflow: hidden; }
.dock-content { position: absolute; inset: 0; border: none !important; }
#propertiesPanel, #explorerPanel {
  display: flex; flex-direction: column;
  background: var(--panel-bg); color: var(--panel-text); font-size: 12px;
}

/* Tab strip when a group holds more than one panel */
.dock-tabstrip {
  flex: none; height: 23px;
  background: linear-gradient(to bottom, #dfe3e8, #c7ccd3);
  border-top: 1px solid #b6bdc7;
  display: flex; align-items: stretch; overflow-x: auto;
}
.dock-tab {
  border: 1px solid #b6bdc7; border-bottom: none;
  background: linear-gradient(to bottom, #f2f3f5, #dfe2e7);
  font: 11px Tahoma, sans-serif; padding: 2px 10px; margin-right: 2px;
  cursor: pointer; color: #1a1a1a; white-space: nowrap;
  -webkit-user-select: none; user-select: none;
}
.dock-tab.active { background: var(--panel-bg); font-weight: 600; }

/* Floating window resize grip (bottom-right) */
.dock-resize { position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; cursor: nwse-resize; z-index: 3; }

/* Splitters between split children */
.dock-splitter { background: linear-gradient(to bottom, #e8ebee, #cdd3da); box-sizing: border-box; }
.dock-splitter-v { cursor: ew-resize; border-left: 1px solid #b6bdc7; border-right: 1px solid #b6bdc7; }
.dock-splitter-h { cursor: ns-resize; border-top: 1px solid #b6bdc7; border-bottom: 1px solid #b6bdc7; }
.dock-splitter:hover { background: linear-gradient(to bottom, #eef4fb, #d7e3f2); }

/* Drag ghost: a flat, window-sized dashed outline that follows the cursor
   (the classic MFC drag rectangle). Size is set inline by dock.js. */
.dock-ghost {
  position: fixed; z-index: 10002; pointer-events: none;
  box-sizing: border-box;
  background: rgba(120, 140, 165, 0.12);
  border: 2px dotted #2b3a4f;
}
/* Live preview of where the panel will land (solid blue = destination) */
.dock-preview {
  position: fixed; z-index: 10000; pointer-events: none;
  border: 1px solid #2b6fb5; background: rgba(91, 135, 191, 0.28);
  box-sizing: border-box;
}
/* Dock guide buttons (4 global edges + 5-button diamond on hovered panes) */
.dock-guide {
  position: fixed; z-index: 10001; pointer-events: none;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(to bottom, #eef4fb, #cfe0f5);
  border: 1px solid #5b87bf;
  color: #1c3a5e; font-size: 13px; line-height: 1;
}
.dock-guide.active { background: linear-gradient(to bottom, #9cc4ee, #6fa3df); color: #06203d; }

#propertiesContent { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 2px 0; }

/* ---------- Explorer tree ---------- */
#explorerList { list-style: none; padding: 2px 0 0; margin: 0; flex: 1; overflow-y: auto; overflow-x: hidden; }
#explorerList li {
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px;
  line-height: 16px;
}
#explorerList li:hover { background: #e2ecf8; }
#explorerList li.selected { background: var(--sel-bg); outline: 1px solid var(--sel-border); outline-offset: -1px; }
#explorerList li.drag-over { background: var(--sel-bg) !important; outline: 1px dashed var(--sel-border); }
.explorer-icon {
  image-rendering: pixelated;
}

/* ---------- Properties: selection header + categories + rows ---------- */
.prop-empty { padding: 8px 10px; color: var(--muted-text); }

.prop-selhdr {
  padding: 4px 10px;
  background: #ffffff;
  border-bottom: 1px solid #c5ccd6;
  font-size: 12px;
}

.prop-category {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  background: linear-gradient(to bottom, #eef0f3, #dde2ea);
  border-top: 1px solid #c5ccd6;
  border-bottom: 1px solid #c5ccd6;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.prop-category .cat-arrow { display: inline-block; width: 11px; text-align: center; color: #5f6b78; }

.prop-row {
  display: grid;
  grid-template-columns: 44% 56%;
  align-items: center;
  margin: 0;
  padding: 2px 8px;
  border-bottom: 1px solid #e6e9ef;
}
.prop-row:nth-of-type(even) { background: var(--row-alt); }
.prop-name { color: var(--panel-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop-name.ro, .prop-ro { color: #9098a2; }
.prop-value { display: flex; align-items: center; min-width: 0; }
.prop-value input, .prop-value select {
  background: var(--field-bg);
  color: var(--panel-text);
  border: 1px solid var(--field-border);
  border-radius: 2px;
  padding: 1px 3px;
  font-size: 12px;
  width: 100%;
  box-sizing: border-box;
}
.prop-value input[type="color"] { width: 36px; height: 18px; padding: 0; flex: none; }
.prop-value input[type="checkbox"] { width: auto; flex: none; }
.prop-value .vec3 { display: flex; gap: 3px; width: 100%; }
.prop-value .udim2 { flex-wrap: wrap; align-items: center; }
.prop-value .udim2 input { min-width: 0; flex: 1 1 34px; }
.udim2-axis { flex: none; opacity: 0.6; font-size: 10px; padding: 0 1px; }

/* BrickColor picker */
.bc-field { display: flex; align-items: center; gap: 6px; width: 100%; cursor: pointer; }
.bc-swatch { width: 22px; height: 14px; flex: none; border: 1px solid #6b7682; }
.bc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-popup {
  position: fixed;
  background: #f4f5f7;
  border: 1px solid #6f9bd1;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.35);
  padding: 4px;
  z-index: 9999;
}
.bc-grid { display: grid; grid-template-columns: repeat(8, 22px); gap: 2px; }
.bc-cell {
  width: 22px; height: 22px;
  border: 1px solid #8c95a0;
  padding: 0; cursor: pointer; position: relative;
}
.bc-cell:hover { outline: 2px solid #1c3a5e; outline-offset: -1px; z-index: 1; }
.bc-custom {
  background: #ffffff; color: #1a1a1a; font-size: 15px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

.prop-actions { padding: 8px; }
.prop-delete {
  background: linear-gradient(to bottom, #ffffff, #e7e7e0);
  color: #1a1a1a;
  border: 1px solid #9b9b94;
  padding: 4px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}
.prop-delete:hover { border-color: #6f9bd1; background: linear-gradient(to bottom, #ffffff, #eef4fb); }

/* ---------- Insert Object dialog (Insert ▸ Object…) ----------
   2012 Studio had no permanent Insert dock; objects are inserted through this
   modal list dialog (or the right-click Insert menu / Toolbox). */
#insertDialogOverlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
}
#insertDialog {
  width: 280px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.4);
  font-size: 12px;
}
#insertDialog .insert-caption {
  padding: 4px 10px;
  font-weight: 600;
  color: var(--caption-text);
  background: linear-gradient(to bottom, var(--caption-1), var(--caption-2));
  border-bottom: 1px solid var(--caption-border);
}
#insertList {
  list-style: none;
  margin: 0;
  padding: 2px 0;
  overflow-y: auto;
  flex: 1;
  background: var(--field-bg);
}
#insertList li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  cursor: pointer;
  line-height: 16px;
}
#insertList li .explorer-icon { flex: none; }
#insertList li:hover { background: #e2ecf8; }
#insertList li.selected { background: var(--sel-bg); outline: 1px solid var(--sel-border); outline-offset: -1px; }
#insertDialog .insert-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid var(--panel-border);
}
#insertDialog .insert-actions button {
  padding: 3px 14px;
  font-size: 12px;
  border: 1px solid #9b9b94;
  background: linear-gradient(to bottom, #ffffff, #e7e7e0);
  cursor: pointer;
  border-radius: 3px;
}
#insertDialog .insert-actions button:hover { border-color: #6f9bd1; background: linear-gradient(to bottom, #ffffff, #eef4fb); }

/* ---------- Document area: browser-style tabs (2012 Studio centre) ---------- */
#mdiArea.doc-area {
  display: flex;
  flex-direction: column;
  background: #5a5f6a;
  overflow: hidden;
  z-index: 5;
}

.doc-tabbar {
  flex: none;
  height: 24px;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(to bottom, #d4d8de, #b4bac4);
  border-bottom: 1px solid #8c95a0;
  padding: 0 2px 0 4px;
  box-sizing: border-box;
}

.doc-tabs {
  flex: 1;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  min-width: 0;
  padding-bottom: 0;
}

.doc-tab {
  position: relative;
  flex: none;
  height: 21px;
  margin-right: -9px;
  padding: 0 18px 0 12px;
  border: 1px solid #8c95a0;
  border-bottom: none;
  background: linear-gradient(to bottom, #cfd3d9, #b0b6c0);
  color: #333;
  font: 11px/21px Tahoma, sans-serif;
  cursor: default;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  z-index: 1;
  -webkit-user-select: none;
  user-select: none;
}
.doc-tab-label {
  display: inline-block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
}
.doc-tab.active {
  background: #ffffff;
  color: #000;
  z-index: 3;
  height: 22px;
  margin-bottom: -1px;
  border-color: #8c95a0;
}

.doc-tabnav {
  flex: none;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0 4px 1px 8px;
}
.doc-tabnav-btn {
  width: 18px;
  height: 18px;
  border: 1px solid #8c95a0;
  background: linear-gradient(to bottom, #fdfdfb, #dcdcd4);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.doc-tabnav-btn:hover:not(:disabled) { background: #eef4fb; border-color: #7aa7dd; }
.doc-tabnav-btn:disabled { opacity: 0.45; cursor: default; }
.doc-tabnav-close:hover:not(:disabled) { background: #e8736b; color: #fff; border-color: #c0392b; }

.doc-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #1a1a1a;
  min-height: 0;
}
.doc-pane {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.doc-pane canvas { display: block; width: 100%; height: 100%; }

/* Legacy MDI rules (unused; kept for reference during transition) */
#mdiArea {
  position: absolute;
  top: var(--ribbon-h);
  left: 0;
  right: 0;
  bottom: 0;
}

/* ---------- Output pane + command bar ---------- */
.output-pane {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: #ffffff; color: #000;
  font: 12px/1.35 Consolas, 'Lucida Console', monospace;
}
.output-toolbar {
  flex: none; height: 22px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 6px;
  background: linear-gradient(to bottom, #f4f4f0, #dedeD6);
  border-bottom: 1px solid #b9b9b1;
  font: 11px Tahoma, sans-serif; color: #333;
}
.output-toolbar-label { flex: 1; font-weight: bold; }
.output-clear {
  border: 1px solid #9b9b9b; background: linear-gradient(to bottom, #fdfdfb, #e2e2da);
  font: 11px Tahoma, sans-serif; padding: 1px 8px; cursor: pointer; border-radius: 2px;
}
.output-clear:hover { background: #eef4fb; border-color: #7aa7dd; }
.output-log {
  flex: 1; overflow: auto; padding: 3px 6px;
  white-space: pre-wrap; word-break: break-word;
  background: #ffffff;
}
.output-line { color: #1a1a1a; }
.output-line.warning { color: #8a6d00; background: #fff8db; }
.output-line.error { color: #c0241b; background: #fdeceb; }
.output-line.command { color: #2358a8; }
.output-cmdrow {
  flex: none; display: flex; align-items: center; gap: 4px;
  border-top: 1px solid #b9b9b1; padding: 2px 4px; background: #f4f4f0;
}
.output-prompt { color: #2358a8; font-weight: bold; padding-left: 2px; }
.output-cmd {
  flex: 1; border: 1px solid #b9b9b1; padding: 2px 4px;
  font: 12px Consolas, 'Lucida Console', monospace; color: #000; background: #fff;
  outline: none;
}
.output-cmd:focus { border-color: #7aa7dd; }
.output-log::-webkit-scrollbar { width: 15px; }
.output-log::-webkit-scrollbar-track { background: #e6e6e6; }
.output-log::-webkit-scrollbar-thumb { background: linear-gradient(to right, #d4d4d4, #b9b9b9); border: 1px solid #9b9b9b; border-radius: 2px; }

/* ---------- Script editor (2012 Studio-style) ---------- */
.script-editor { position: absolute; inset: 0; display: flex; flex-direction: column; background: #fff; }
.se-body { flex: 1; display: flex; min-height: 0; overflow: hidden; }
.se-gutter {
  flex: none; width: 42px; overflow: hidden; background: #f0f0f0;
  border-right: 3px solid #f5f5f5; -webkit-user-select: none; user-select: none;
}
.se-ln-inner {
  padding: 4px 6px 4px 2px; text-align: right;
  font: 13px/1.4 Consolas, 'Lucida Console', monospace; color: #000;
}
.se-ln { min-height: 1.4em; position: relative; padding-right: 2px; }
.se-ln-error::before {
  content: '!'; position: absolute; left: 0; top: 0; width: 10px; text-align: center;
  color: #c00; font: bold 11px Tahoma, sans-serif;
}
.se-ln-warn::before {
  content: '!'; position: absolute; left: 0; top: 0; width: 10px; text-align: center;
  color: #c68000; font: bold 11px Tahoma, sans-serif;
}
.se-editor { flex: 1; position: relative; min-width: 0; overflow: hidden; background: #fff; }
.se-highlight, .se-text {
  position: absolute; inset: 0; margin: 0; padding: 4px 6px; border: none; outline: none;
  font: 13px/1.4 Consolas, 'Lucida Console', monospace;
  white-space: pre; overflow: auto; -moz-tab-size: 4; tab-size: 4;
  word-spacing: normal; letter-spacing: normal;
}
.se-highlight {
  pointer-events: none; color: #000; background: #fff; overflow: hidden;
}
.se-highlight code { display: block; font: inherit; white-space: pre; }
.se-text {
  resize: none; color: transparent; caret-color: #000; background: transparent;
}
.se-syn-kw { font-weight: bold; color: #000080; }
.se-syn-str { color: #800080; }
.se-syn-num { color: #008080; }
.se-syn-cmt { color: #008000; }
.se-syn-punct { color: #808000; }
.se-text::-webkit-scrollbar { width: 15px; height: 15px; }
.se-text::-webkit-scrollbar-track { background: #e6e6e6; }
.se-text::-webkit-scrollbar-thumb {
  background: linear-gradient(to right, #d4d4d4, #b9b9b9);
  border: 1px solid #9b9b9b;
}

/* ---------- Classic scrollbars ---------- */
#propertiesContent::-webkit-scrollbar, #explorerList::-webkit-scrollbar { width: 15px; }
#propertiesContent::-webkit-scrollbar-track, #explorerList::-webkit-scrollbar-track { background: #e6e6e6; border-left: 1px solid #c8c8c8; }
#propertiesContent::-webkit-scrollbar-thumb, #explorerList::-webkit-scrollbar-thumb {
  background: linear-gradient(to right, #d4d4d4, #b9b9b9);
  border: 1px solid #9b9b9b;
  border-radius: 2px;
}
