:root {
    --bg-main: #0c0c0e;
    --bg-panel: #14141c;
    --bg-bar: #181822;
    --bg-box: #1a1a24;
    --text-main: #f1f5f9;
    --text-sub: #94a3b8;
    --border: #262636;
    --primary: #f59e0b;
    --secondary: #ef4444;
    --accent: #8b5cf6;
    --brand: #6366f1;
    --font: 'Inter', -apple-system, sans-serif;
}

/* RESET E BASE */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font);
    height: 100vh;
    overflow: hidden;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

#editor-root {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

#editor-main {
    display: flex;
    flex: 1;
    min-height: 0;
}

#workspace {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
}

/* ===============================
    LAYOUT PRINCIPAL
=============================== */
#editor-root {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#top-bar {
    height: 42px;
    background: var(--bg-bar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    flex-shrink: 0;
}

#editor-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ===============================
    LEFT PANEL - COM RESIZE HORIZONTAL
=============================== */
#left-panel {
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 0 0 auto;
    width: 220px; /* Largura inicial */
    min-width: 150px;
    max-width: 400px;
    position: relative;
    height: 100%;
}

.left-properties {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
    background: #252526;
}

/* ===============================
    WORKSPACE
=============================== */
#workspace {
    background: #1b1b1b;
    flex: 1;
    min-width: 300px;
    position: relative;
    overflow: auto;
}

/* ===============================
    RIGHT PANEL
=============================== */
#right-panel {
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 0 0 auto;
    width: 300px;
    min-width: 150px;
    max-width: 600px;
    position: relative;
}

/* ===============================
    RIGHT PROJECT TREE
=============================== */
.right-project-tree {
    font-size: 13px;
    color: #ddd;
    padding: 6px;
    overflow-y: auto;
    font-family: var(--font);
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
}

.tree-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 6px;
    color: #fff;
}

.tree-root {
    flex: 1;
    overflow: auto;
}

.tree-section {
    margin-bottom: 4px;
}

.tree-section:last-child {
    margin-bottom: 0;
}

.tree-section-header {
    font-size: 12px;
    text-transform: uppercase;
    opacity: 0.85;
    padding: 2px 6px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    border-radius: 3px;
    transition: background 0.15s;
}

.tree-section-header:hover {
    background: #2a2a2a;
}

.tree-section-header.folder {
    font-weight: 600;
    color: #fff;
}

.arrow {
    font-size: 10px;
    margin-right: 6px;
    transition: transform 0.15s;
}

.tree-section-header.open .arrow {
    transform: rotate(360deg);
}

.tree-section-list {
    padding-left: 16px;
}

.tree-section-list .tree-section-list {
    padding-left: 14px;
}

/* Itens de arquivo */
.tree-item {
    padding: 3px 6px;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 12px;
    color: #ccc;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tree-item:hover {
    background: #333;
    color: #fff;
}

.tree-item.active {
    background: var(--accent);
    color: #fff;
}

.tree-empty {
    font-size: 11px;
    opacity: 0.5;
    padding-left: 6px;
}

/* ===============================
    LEFT PROPERTIES PANEL - MODIFICAÇÕES SOLICITADAS
=============================== */
.prop-header {
    height: 26px;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #ccc;
    background: #1f1f1f;
    border-bottom: 1px solid #111;
    user-select: none;
    flex-shrink: 0;
}

.prop-group {
    margin-bottom: 8px;
}

.prop-group-title {
    font-size: 10px;
    color: #9aa0a6;
    text-transform: uppercase;
    margin: 6px 0 4px;
    border-bottom: 1px solid #333;
    padding-bottom: 2px;
}

.prop-group-content {
    padding: 8px;
}

/* MODIFICAÇÃO: Largura dos campos reduzida em 30% e mais próximos */
.prop-row {
    display: grid;
    grid-template-columns: 56px 1fr; /* 70px - 30% = 56px */
    gap: 3px; /* Reduzido de 6px para 3px para aproximar */
    align-items: center;
    margin-bottom: 3px;
}

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

.prop-row.textarea {
    align-items: flex-start;
}

.prop-label {
    font-size: 10px;
    color: #bbb;
    text-align: right;
    padding-right: 2px; /* Adicionado para aproximar mais */
}

.prop-input {
    height: 18px;
    padding: 1px 4px;
    font-size: 11px;
    background: #1e1e1e;
    border: 1px solid #333;
    color: #e0e0e0;
}

.prop-input:focus {
    outline: none;
    border-color: #3fa9f5;
}

/* MODIFICAÇÃO: Removido textarea específico para descrição */
.prop-value {
    flex: 1;
    padding: 4px 0;
    font-size: 12px;
    color: #ddd;
}

.prop-row.readonly .prop-value {
    font-size: 11px;
    color: #999;
}

/* Checkbox */
.prop-row input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
}

.object-palette-group {
    padding: 10px 12px 10px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.04);
}

.object-palette-title {
    font-size: 11px;
    color: #9da5b7;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.object-palette-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.obj-palette-btn {
    border: 1px solid rgba(255,255,255,0.08);
    background: #18181c;
    color: #ddd;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.obj-palette-btn:hover {
    background: #23232a;
    border-color: rgba(255,255,255,0.14);
}

.stage-context-menu button {
    font-family: inherit;
}

/* ===============================
    RIGHT PANEL BOTTOM - LAYERS / TILEMAP
=============================== */
#right-bottom-panel {
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    color: #ddd;
    font-size: 12px;
    overflow: hidden;
    height: 200px;
    flex-shrink: 0;
    border-top: 1px solid #333;
}

/* Tabs */
#right-panel-tabs {
    display: flex;
    height: 28px;
    background: #2d2d2d;
    flex-shrink: 0;
}

.right-panel-tab {
    flex: 1;
    text-align: center;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #333;
    transition: background 0.15s;
}

.right-panel-tab:last-child {
    border-right: none;
}

.right-panel-tab.active {
    background: #1b1b1b;
    font-weight: 600;
}

/* Layers content */
#right-panel-content {
    flex: 1;
    overflow: auto;
    padding: 6px;
}

#right-panel-content .layer-row {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
}

#right-panel-content .layer-row input[type="checkbox"] {
    margin-right: 6px;
}

#right-panel-content .layer-row span.lock {
    cursor: pointer;
    margin-right: 6px;
}

/* ===============================
    RESIZERS
=============================== */
.left-panel-resizer {
    width: 4px;
    cursor: ew-resize;
    background: #333;
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 10;
    transition: background 0.2s;
}

#right-panel-resizer {
    width: 4px;
    cursor: ew-resize;
    background: #333;
    position: absolute;
    top: 0;
    bottom: 0;
    left: -2px;
    z-index: 10;
    transition: background 0.2s;
}

#right-bottom-panel-resizer {
    height: 4px;
    cursor: ns-resize;
    background: #333;
    flex-shrink: 0;
    width: 100%;
}

.left-panel-resizer:hover,
#right-panel-resizer:hover,
#right-bottom-panel-resizer:hover {
    background: var(--accent);
}

/* ===============================
    SCROLLBAR PERSONALIZADA
=============================== */
.right-project-tree::-webkit-scrollbar,
#right-panel-content::-webkit-scrollbar,
.left-properties-content::-webkit-scrollbar {
    width: 8px;
}

.right-project-tree::-webkit-scrollbar-track,
#right-panel-content::-webkit-scrollbar-track,
.left-properties-content::-webkit-scrollbar-track {
    background: var(--bg-panel);
}

.right-project-tree::-webkit-scrollbar-thumb,
#right-panel-content::-webkit-scrollbar-thumb,
.left-properties-content::-webkit-scrollbar-thumb {
    background-color: #555;
    border-radius: 4px;
}

.right-project-tree::-webkit-scrollbar-thumb:hover,
#right-panel-content::-webkit-scrollbar-thumb:hover,
.left-properties-content::-webkit-scrollbar-thumb:hover {
    background-color: #777;
}

/* ===============================
   ÁRVORE DO PROJETO - ESTRUTURA HIERÁRQUICA
=============================== */
.tree-search {
    margin-bottom: 8px;
}

.tree-search input {
    width: 100%;
    padding: 4px 8px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 3px;
    color: #ddd;
    font-size: 12px;
    outline: none;
}

.tree-search input:focus {
    border-color: var(--accent);
}

.tree-project-root {
    margin-bottom: 8px;
}

.tree-project-root-header {
    display: flex;
    align-items: center;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s;
    font-weight: 600;
    color: #fff;
}

.tree-project-root-header:hover {
    background: #2a2a2a;
}

.tree-project-root-header .arrow {
    margin-right: 6px;
    font-size: 10px;
    transition: transform 0.15s;
}

.tree-project-root-header.open .arrow {
    transform: rotate(360deg);
}

.tree-project-root-icon {
    margin-right: 6px;
    font-size: 14px;
}

/* Ícones */
.tree-item-icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tree-item-icon.project-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    display: block;
}

.tree-item-icon.emoji-icon {
    font-size: 12px;
    background: transparent;
}

/* Ajuste para setas antes dos ícones */
.tree-section-header {
    display: flex;
    align-items: center;
}

.tree-section-header .arrow {
    order: 1;
    margin-right: 6px;
}

.tree-section-header .tree-item-icon {
    order: 2;
    margin-right: 6px;
}

.tree-section-header .tree-section-label {
    order: 3;
}

.left-properties-content {
    flex: 1;
    overflow-y: auto;
    padding: 4px 6px;
    font-size: 11px;
}

/* ===============================
   LEFT PROPERTIES CONTENT - ESTILO EXCEL (AJUSTADO)
=============================== */
.prop-header {
    height: 26px;
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #ccc;
    background: #1f1f1f;
    border-bottom: 1px solid #111;
    user-select: none;
    flex-shrink: 0;
}

.left-properties-content {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
    font-size: 11px;
}

/* Grid estilo Excel - duas colunas lado a lado */
.prop-group {
    margin-bottom: 12px;
}

.prop-group-title {
    font-size: 10px;
    color: #9aa0a6;
    text-transform: uppercase;
    margin: 0 0 4px 0;
    padding: 2px 0;
    border-bottom: 1px solid #333;
}

/* MODIFICAÇÃO: Grid ajustado com largura menor */
.prop-row {
    display: grid;
    grid-template-columns: 56px 1fr; /* Reduzido de 80px para 56px (30%) */
    gap: 3px; /* Reduzido de 6px para 3px para aproximar */
    align-items: center;
    min-height: 22px;
    padding: 2px 0;
}

/* Labels alinhados à esquerda, não à direita */
.prop-label {
    font-size: 11px;
    color: #bbb;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 2px; /* Adicionado para aproximar mais */
}

/* Inputs estilo Excel */
.prop-input {
    height: 20px;
    padding: 2px 4px;
    font-size: 11px;
    background: #2d2d2d;
    border: 1px solid #3d3d3d;
    color: #e0e0e0;
    outline: none;
    transition: border-color 0.15s;
}

.prop-input:hover {
    border-color: #4d4d4d;
}

.prop-input:focus {
    border-color: var(--accent);
    background: #333;
}

/* Checkbox */
.prop-row input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
}

/* Número */
.prop-row input[type="number"] {
    padding: 2px 4px;
}

/* Valores readonly */
.prop-value {
    font-size: 11px;
    color: #999;
    padding: 2px 0;
    user-select: text;
}

/* Linhas readonly */
.prop-row.readonly .prop-label {
    color: #888;
}

/* ===============================
   SCROLLBAR DO LEFT PROPERTIES
=============================== */
.left-properties-content::-webkit-scrollbar {
    width: 6px;
}

.left-properties-content::-webkit-scrollbar-track {
    background: transparent;
}

.left-properties-content::-webkit-scrollbar-thumb {
    background-color: #444;
    border-radius: 3px;
}

.left-properties-content::-webkit-scrollbar-thumb:hover {
    background-color: #555;
}

/* ===============================
   PROP GRID - ESTILO EXCEL
=============================== */
.prop-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Hover nas linhas para destacar */
.prop-row:hover {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 2px;
}

/* Ajuste fino para alinhamento */
.prop-label {
    padding-left: 2px;
}

/* Inputs com largura total */
.prop-input {
    width: 100%;
    box-sizing: border-box;
}

/* Foco nos inputs */
.prop-input:focus {
    box-shadow: 0 0 0 1px var(--accent);
}

/* Checkbox alinhado */
.prop-row input[type="checkbox"] {
    justify-self: start;
}

/* Número com spinner oculto em alguns navegadores */
.prop-row input[type="number"]::-webkit-inner-spin-button,
.prop-row input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.5;
}

.prop-row input[type="number"]:hover::-webkit-inner-spin-button,
.prop-row input[type="number"]:hover::-webkit-outer-spin-button {
    opacity: 1;
}

/* ===============================
   ÁRVORE DO PROJETO (CORREÇÕES)
=============================== */
/* Garante que os ícones apareçam */
.tree-item-icon {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-right: 6px;
}

/* Ícones de imagem - garante visibilidade */
.tree-item-icon.project-icon {
    display: block !important;
    visibility: visible;
    opacity: 1;
}

/* Fallback visual para ícones quebrados */
.tree-item-icon.project-icon[src=""]:after,
.tree-item-icon.project-icon:not([src]):after {
    content: "🖼️";
    font-size: 12px;
    display: block;
}

/* Estrutura do item da árvore */
.tree-item {
    display: flex !important;
    align-items: center;
    min-height: 20px;
}

/* Ajuste fino para setas e pastas */
.tree-section-header {
    display: flex;
    align-items: center;
}

/* ===============================
   PAINEL DE CAMADAS (VISIBILIDADE)
=============================== */
/* Container principal */
#right-bottom-panel {
    background: #1e1e1e;
    border-top: 1px solid #333;
}

/* Tabs - Renomeado para "Camadas" */
.right-panel-tab[data-tab="Camadas"] {
    font-weight: 600;
}

/* Conteúdo das camadas */
#right-panel-content {
    background: #1b1b1b;
}

/* Linha de camada com estado claro */
.layer-row {
    background: transparent;
    border: 1px solid transparent;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

/* Destaque para camada ativa */
.layer-row.active {
    background: rgba(63, 169, 245, 0.1) !important;
    border: 1px solid rgba(63, 169, 245, 0.3);
    border-left: 3px solid var(--accent) !important;
}

/* Feedback visual ao passar o mouse */
.layer-row:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid #555;
}

/* ===============================
   ESTADO DO SISTEMA (FEEDBACK VISUAL)
=============================== */
/* Mensagem de estado vazio */
.system-state-empty {
    text-align: center;
    padding: 20px;
    color: #888;
    font-size: 12px;
    line-height: 1.5;
}

.system-state-empty small {
    color: #666;
    display: block;
    margin-top: 5px;
}

/* Índice visual para ordem das camadas */
.layer-order-badge {
    display: inline-block;
    background: #333;
    color: #aaa;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 6px;
    font-family: monospace;
}

/* ===============================
   ESTRUTURA DA ÁRVORE CORRIGIDA
=============================== */

/* Ajuste para a ordem correta: seta → ícone → nome */
.tree-section-header,
.tree-project-root-header {
    display: flex;
    align-items: center;
}

/* A seta deve vir primeiro */
.tree-section-header .arrow,
.tree-project-root-header .arrow {
    order: 1;
    margin-right: 6px;
    transition: transform 0.2s;
    font-size: 10px;
    width: 12px;
    text-align: center;
}

/* O ícone vem em segundo */
.tree-section-header .tree-folder-icon,
.tree-project-root-header .tree-project-root-icon {
    order: 2;
    margin-right: 6px;
    font-size: 13px;
}

/* O nome vem por último */
.tree-section-header .tree-section-label,
.tree-project-root-header .tree-project-root-label {
    order: 3;
    flex: 1;
}

/* Rotação da seta quando aberto */
.tree-section-header.open .arrow,
.tree-project-root-header.open .arrow {
    transform: rotate(360deg);
}

/* ===============================
   ESTILOS PARA O PAINEL DE CAMADAS
=============================== */

/* Cabeçalho da cena */
.scene-header {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    letter-spacing: 0.3px;
}

/* Ícones das camadas */
.layer-icon {
    transition: all 0.2s ease;
}

.layer-icon:hover {
    opacity: 1 !important;
    transform: scale(1.1);
}

/* Badge de ordem */
.layer-order {
    transition: all 0.2s ease;
}

.layer-row.active .layer-order {
    background: rgba(63, 169, 245, 0.2) !important;
    color: #3fa9f5 !important;
}

/* ===============================
   FEEDBACK VISUAL PARA INTERAÇÕES
=============================== */

/* Hover nas pastas */
.tree-section-header:hover,
.tree-project-root-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Itens da árvore ativos */
.tree-item.active {
    background: linear-gradient(90deg, rgba(63, 169, 245, 0.2), rgba(63, 169, 245, 0.1));
    color: #fff;
    border-left: 3px solid var(--accent);
}

/* Transições suaves */
.tree-item,
.layer-row,
.right-panel-tab {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===============================
   RESPONSIVIDADE BÁSICA
=============================== */

@media (max-width: 1200px) {
    #left-panel {
        min-width: 180px;
        max-width: 300px;
    }
    
    #right-panel {
        min-width: 180px;
        max-width: 400px;
    }
}

/* ===============================
   ESTADOS DE CARREGAMENTO
=============================== */

.tree-empty {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 0.8; }
    100% { opacity: 0.5; }
}

/* ===============================
   MELHORIAS DE ACESSIBILIDADE
=============================== */

.tree-item:focus-visible,
.layer-row:focus-visible,
.right-panel-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===============================
   AJUSTES FINOS DE ESPAÇAMENTO
=============================== */

.tree-section-list {
    padding-left: 18px;
}

.tree-item {
    padding: 4px 6px;
    margin: 1px 0;
}

.tree-search {
    margin-bottom: 10px;
    padding: 0 4px;
}