/* ── Editor de Modelo — Layout Shell ───────────────────── */

body {
  overflow: hidden;
}

.model-editor-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 320px;
  gap: 0;
  background: #e0e8f1;
}

/* ── Sidebar panels shared ──────────────────────────────── */

.left-toolbox,
.right-inspector {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.left-toolbox {
  border-right: 1px solid var(--border);
}

.right-inspector {
  border-left: 1px solid var(--border);
  display: grid;
  grid-template-rows: minmax(0, auto) minmax(180px, 1fr);
}

/* ── Left Toolbox ───────────────────────────────────────── */

.left-toolbox {
  flex-direction: column;
  overflow: hidden;
}

.toolbox-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 12px;
  scrollbar-gutter: stable;
}

.toolbox-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--panel);
}

.toolbox-header h1 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.toolbox-eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.65rem;
  color: var(--accent);
  font-weight: 700;
}

.toolbox-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--border-subtle);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Tool groups */

.tool-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 10px 4px 5px;
}

.tool-section-label:first-child {
  padding-top: 4px;
}

.tool-group {
  display: grid;
  gap: 5px;
}

.tool-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 8px 0;
}

/* Tool buttons — these are full-width, icon+label style */

.button.tool-btn {
  border-radius: var(--radius-sm);
  justify-content: flex-start;
  padding: 0 12px;
  min-height: 38px;
  font-size: 0.88rem;
  gap: 9px;
  font-weight: 600;
  width: 100%;
}

.button.tool-btn.primary {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: transparent;
  box-shadow: none;
}

.button.tool-btn.primary:hover {
  background: rgba(13, 122, 115, 0.15);
  box-shadow: none;
}

.button.tool-btn.ghost {
  color: var(--text-secondary);
}

.button.tool-btn.danger-outline {
  border-color: transparent;
  background: transparent;
}

.button.tool-btn.danger-outline:hover {
  background: var(--danger-soft);
  border-color: transparent;
}

/* Tool icon dot indicator */

.tool-type-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: auto;
}

/* Info group */

.info-group {
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  border: 1px solid var(--border-subtle);
  padding: 12px;
  display: grid;
  gap: 5px;
}

.info-group h2 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0;
}

.info-group p {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

/* ── Editor main (center column) ────────────────────────── */

.editor-main {
  min-height: 0;
  display: grid;
  gap: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: #dce4ef;
}

/* ── Topbar ─────────────────────────────────────────────── */

.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}

.model-usage-notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(196, 139, 48, 0.12);
  border-bottom: 1px solid rgba(196, 139, 48, 0.28);
}

.model-usage-notice.is-archived {
  background: rgba(196, 139, 48, 0.1);
}

.model-usage-copy {
  display: grid;
  gap: 4px;
}

.model-usage-copy strong {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8e530f;
}

.model-usage-copy p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: #7b5d28;
}

.editor-topbar-main {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.editor-topbar-main .field {
  gap: 3px;
}

.editor-name-field {
  flex: 1 1 220px;
  min-width: 0;
}

.editor-type-field {
  flex: 0 1 170px;
  min-width: 0;
}

.editor-topbar-main .input {
  min-height: 36px;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
}

.editor-topbar-main .field-label {
  font-size: 0.68rem;
}

.editor-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.editor-topbar-status {
  display: flex;
  align-items: center;
  gap: 7px;
}

.editor-topbar-status .field-label {
  font-size: 0.72rem;
  white-space: nowrap;
}

/* ── Stage Controls Bar ─────────────────────────────────── */

.stage-controls {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  background: #d4dde9;
  border-bottom: 1px solid #bfcbda;
  min-height: 48px;
  overflow-x: auto;
}

.stage-control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-right: 1px solid #bfcbda;
  flex-shrink: 0;
}

.stage-control-group .field-label {
  font-size: 0.68rem;
  white-space: nowrap;
  color: #5a6e85;
}

.stage-control-group .field {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-direction: row;
}

.stage-control-group .input {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 0.82rem;
  border-radius: var(--radius-xs);
  height: 30px;
  border-color: #bfcbda;
  background: rgba(255,255,255,0.7);
}

.stage-control-group .input:focus {
  background: #fff;
}

.preset-row {
  display: flex;
  gap: 5px;
}

.preset-button {
  min-height: 28px;
  height: 28px;
  padding: 0 10px;
  font-size: 0.78rem;
  border-radius: var(--radius-xs);
  border-color: #bfcbda;
  color: var(--text-secondary);
}

.preset-button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

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

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ── Stage Panel ────────────────────────────────────────── */

.stage-panel {
  display: grid;
  gap: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
}

.stage-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px 8px;
}

.stage-panel-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.stage-panel-title h2 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5a6e85;
  margin: 0;
}

.stage-panel-title p {
  font-size: 0.78rem;
  color: #7a92a8;
  margin: 0;
}

.selected-hint {
  color: #7a92a8;
  font-size: 0.8rem;
  font-style: italic;
  text-align: right;
}

.stage-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.stage-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.7);
  border: 1px solid #bfcbda;
  color: #5a6e85;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Editor Stage Shell ─────────────────────────────────── */

.editor-stage-shell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  height: 100%;
  background:
    linear-gradient(45deg, rgba(170, 185, 205, 0.28) 25%, transparent 25%, transparent 75%, rgba(170, 185, 205, 0.28) 75%),
    linear-gradient(45deg, rgba(170, 185, 205, 0.28) 25%, transparent 25%, transparent 75%, rgba(170, 185, 205, 0.28) 75%),
    #d0dae8;
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  overflow: auto;
  padding: 24px;
}

.editor-stage-mount {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Stage empty state ─────────────────────────────────── */

.stage-empty-state {
  position: absolute;
  inset: 24px;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.stage-empty-card {
  width: min(500px, calc(100% - 24px));
  padding: 28px 24px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(170, 185, 202, 0.52);
  box-shadow: 0 20px 60px rgba(15, 28, 46, 0.14);
  text-align: center;
  pointer-events: auto;
}

.stage-empty-card .eyebrow {
  font-size: 0.7rem;
  margin-bottom: 8px;
}

.stage-empty-card h3 {
  margin: 0 0 8px;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.stage-empty-card .muted {
  font-size: 0.87rem;
}

.stage-empty-actions {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* ── The actual stage ─────────────────────────────────────── */

.editor-stage {
  position: relative;
  box-shadow:
    0 0 0 1px rgba(15, 28, 46, 0.18),
    0 8px 32px rgba(15, 28, 46, 0.22),
    0 24px 72px rgba(15, 28, 46, 0.18);
}

.editor-stage__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(19, 32, 51, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(19, 32, 51, 0.07) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.editor-stage__safe {
  position: absolute;
  border: 1px dashed rgba(13, 122, 115, 0.85);
  box-shadow: inset 0 0 0 1px rgba(13, 122, 115, 0.12);
  pointer-events: none;
}

.editor-stage__guide {
  position: absolute;
  background: rgba(220, 70, 30, 0.85);
  pointer-events: none;
  z-index: 9999;
}

.editor-stage__guide.vertical {
  top: 0;
  bottom: 0;
  width: 1px;
}

.editor-stage__guide.horizontal {
  left: 0;
  right: 0;
  height: 1px;
}

/* ── Editor Layer ────────────────────────────────────────── */

.editor-layer {
  outline: 1px solid transparent;
  transition:
    outline-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

.editor-layer:not([data-locked="true"]) {
  cursor: move;
}

.editor-layer.is-selected {
  outline: 2px solid #e2621e;
  outline-offset: 1px;
  box-shadow:
    0 0 0 4px rgba(226, 98, 30, 0.16),
    0 0 0 1px rgba(226, 98, 30, 0.5);
}

.editor-layer[data-locked="true"] {
  cursor: default;
}

.editor-layer__label {
  position: absolute;
  left: 0;
  top: -26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(15, 28, 46, 0.88);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* ── Resize handles ─────────────────────────────────────── */

.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e2621e;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(15, 28, 46, 0.3);
  transition: transform 0.1s ease;
}

.resize-handle:hover {
  transform: scale(1.3);
}

.resize-handle[data-handle="nw"] { top: -5px; left: -5px; cursor: nwse-resize; }
.resize-handle[data-handle="n"]  { top: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.resize-handle[data-handle="ne"] { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-handle[data-handle="e"]  { top: calc(50% - 5px); right: -5px; cursor: ew-resize; }
.resize-handle[data-handle="se"] { right: -5px; bottom: -5px; cursor: nwse-resize; }
.resize-handle[data-handle="s"]  { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.resize-handle[data-handle="sw"] { left: -5px; bottom: -5px; cursor: nesw-resize; }
.resize-handle[data-handle="w"]  { top: calc(50% - 5px); left: -5px; cursor: ew-resize; }

/* ── Right Inspector Panel ──────────────────────────────── */

.right-inspector {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.inspector-section {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.inspector-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: var(--panel);
}

.inspector-section-header h2 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0;
}

.inspector-section-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
  align-content: start;
  scrollbar-gutter: stable;
}

.inspector-section-body.layers-body {
  padding: 8px;
}

/* Inspector form */

.inspector-form {
  display: grid;
  gap: 10px;
}

.inspector-prop-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  border: 1px solid var(--border-subtle);
}

.inspector-prop-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
}

/* Inline field compact for inspector */

.inspector-form .field-label {
  font-size: 0.7rem;
}

.inspector-form .input {
  min-height: 34px;
  font-size: 0.85rem;
  padding: 7px 10px;
}

.inspector-form .field-grid {
  gap: 8px;
}

.inspector-form .compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
}

.inspector-form .action-row {
  gap: 6px;
}

.inspector-form .action-row .button {
  font-size: 0.8rem;
  min-height: 34px;
}

.color-field {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.color-input {
  width: 44px;
  height: 34px;
  padding: 4px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: #ffffff;
  cursor: pointer;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: calc(var(--radius-xs) - 2px);
}

/* Toggle in inspector */

.inspector-toggle-row {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 6px 0;
}

/* Empty selection state */

.empty-selection {
  display: grid;
  place-items: center;
  padding: 28px 14px;
  text-align: center;
}

.empty-selection-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--panel-soft);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  color: var(--muted);
}

.empty-selection p {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* Type inspector (text/shape/image) */

.type-inspector {
  display: grid;
  gap: 8px;
}

.type-inspector h3 {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

/* Dynamic binding box */

.dynamic-binding-box {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  border: 1px solid rgba(13, 122, 115, 0.18);
}

/* ── Layer List ─────────────────────────────────────────── */

.layer-list {
  display: grid;
  gap: 4px;
  align-content: start;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  transition:
    border-color var(--transition-fast),
    background var(--transition-fast),
    box-shadow var(--transition-fast);
}

.layer-item:hover {
  border-color: var(--border-strong);
  background: var(--panel-soft);
}

.layer-item.is-selected {
  border-color: rgba(226, 98, 30, 0.65);
  background: rgba(226, 98, 30, 0.05);
  box-shadow: 0 0 0 2px rgba(226, 98, 30, 0.12);
}

.layer-type-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.layer-type-icon.type-text   { background: rgba(13, 122, 115, 0.1); color: var(--accent-strong); }
.layer-type-icon.type-shape  { background: rgba(186, 104, 30, 0.1); color: #924f0f; }
.layer-type-icon.type-image  { background: rgba(60, 80, 184, 0.1); color: #2838a0; }
.layer-type-icon.type-logo   { background: rgba(130, 50, 150, 0.1); color: #6e2a84; }

.layer-item-main {
  min-width: 0;
  flex: 1;
}

.layer-item-name {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-item-meta {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  margin-top: 2px;
}

.layer-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.icon-button {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast);
}

.icon-button:hover {
  background: var(--panel-soft);
  border-color: var(--border-strong);
  color: var(--text);
}

.icon-button.danger:hover {
  background: var(--danger-soft);
  border-color: rgba(184, 60, 60, 0.3);
  color: var(--danger);
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 1400px) {
  .model-editor-shell {
    grid-template-columns: 212px minmax(0, 1fr) 296px;
  }
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .model-editor-shell {
    height: auto;
    grid-template-columns: 1fr;
    background: var(--bg);
  }

  .left-toolbox,
  .right-inspector {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 0 12px;
    overflow: visible;
  }

  .left-toolbox {
    margin-top: 12px;
  }

  .right-inspector {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    max-height: none;
  }

  .editor-main {
    background: transparent;
  }

  .stage-controls {
    flex-wrap: wrap;
    min-height: auto;
  }

  .editor-stage-shell {
    min-height: 480px;
  }

  .inspector-section {
    max-height: none;
    overflow: visible;
  }

  .inspector-section-body {
    overflow: visible;
  }
}
