* {
    box-sizing: border-box;
}
html,
body {
    margin: 0;
    height: 100%;
    font-family: Arial, sans-serif;
}
body {
    background: #eef1f5;
    overflow: hidden;
}
button,
input,
select,
textarea {
    font: inherit;
}
button {
    border: 1px solid #cfd5dc;
    background: #fff;
    border-radius: 6px;
    padding: 7px 10px;
    cursor: pointer;
}
button:hover {
    background: #f4f6f8;
}
button.primary {
    background: #1463ff;
    color: white;
    border-color: #1463ff;
}
/* =========================================================
   APP
========================================================= */
.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}
/* =========================================================
   TOPBAR
========================================================= */
.topbar {
    height: 56px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 12px;
    background: #161a1f;
    color: white;
}
.brand {
    font-weight: bold;
    min-width: 130px;
}
.toolbar {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 1;
}
.toolbar input,
.toolbar select {
    height: 34px;
    border-radius: 6px;
    border: 1px solid #454c55;
    background: #252b32;
    color: white;
    padding: 0 9px;
}
.toolbar input {
    width: 180px;
}
.toolbar select {
    min-width: 180px;
}
#status {
    font-size: 12px;
    color: #b9c1ca;
}
/* =========================================================
   WORKSPACE
========================================================= */
.workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns:
        240px
        minmax(500px, 1fr)
        290px;
}
/* =========================================================
   PANELS
========================================================= */
.panel {
    background: white;
    overflow: auto;
    border-right: 1px solid #dce1e7;
}
.right-panel {
    border-right: 0;
    border-left: 1px solid #dce1e7;
}
.panel section {
    padding: 15px;
    border-bottom: 1px solid #e5e8ec;
}
h3 {
    margin: 0 0 12px;
    font-size: 13px;
}
/* =========================================================
   ELEMENT BUTTONS
========================================================= */
.add-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}
.add-grid button {
    text-align: left;
}
/* =========================================================
   UPLOAD
========================================================= */
.upload {
    display: block;
    border: 1px dashed #aeb7c2;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    cursor: pointer;
    font-size: 13px;
}
.upload input {
    display: none;
}
/* =========================================================
   ASSETS
========================================================= */
.asset-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-top: 10px;
}
.asset {
    border: 1px solid #d9dee4;
    border-radius: 6px;
    overflow: hidden;
    background: #f8f9fa;
    cursor: grab;
}
.asset img {
    width: 100%;
    height: 80px;
    object-fit: contain;
    display: block;
    background: #eee;
}
.asset span {
    display: block;
    padding: 5px;
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* =========================================================
   CANVAS
========================================================= */
.canvas-area {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #dfe4ea;
}
.canvas-tools {
    height: 48px;
    background: white;
    border-bottom: 1px solid #d4d9df;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 7px 12px;
    font-size: 12px;
}
.canvas-tools label {
    display: flex;
    align-items: center;
    gap: 5px;
}
.canvas-tools input {
    width: 80px;
    padding: 5px;
    border: 1px solid #ccd2d9;
    border-radius: 5px;
}
#canvasViewport {
    flex: 1;
    overflow: auto;
    padding: 30px;
}
/*
 * Este es el canvas real.
 */
.canvas {
    position: relative;
    width: 1000px;
    height: 700px;
    margin: 0 auto;
    background: white;
    box-shadow:
        0 5px 25px rgba(0, 0, 0, .12);
    overflow: hidden;
}
/* =========================================================
   ELEMENTOS EDITABLES
========================================================= */
.builder-element {
    cursor: move;
    outline: 1px solid transparent;
    min-width: 20px;
    min-height: 20px;
}
.builder-element.selected {
    outline: 2px solid #1463ff;
}
/* =========================================================
   RESIZE
========================================================= */
.resize-handle {
    position: absolute;
    width: 9px;
    height: 9px;
    background: #1463ff;
    border: 1px solid white;
    right: -5px;
    bottom: -5px;
    cursor: nwse-resize;
}
/* =========================================================
   PLACEHOLDER
========================================================= */
.builder-placeholder {
    position: absolute;
    inset: 40% 20%;
    text-align: center;
    color: #a0a8b2;
    border: 2px dashed #ccd2d9;
    padding: 20px;
    pointer-events: none;
}
/* =========================================================
   PROPERTIES
========================================================= */
.properties.empty {
    color: #7a838e;
    font-size: 13px;
}
.property {
    margin-bottom: 11px;
}
.property label {
    display: block;
    font-size: 11px;
    color: #69727d;
    margin-bottom: 4px;
}
.property input,
.property select,
.property textarea {
    width: 100%;
    border: 1px solid #ccd2d9;
    border-radius: 5px;
    padding: 7px;
    background: white;
}
.property textarea {
    min-height: 70px;
    resize: vertical;
}
.prop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-top: 12px;
}
.danger {
    color: #b42318;
}
/* =========================================================
   PREVIEW
========================================================= */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.modal.hidden {
    display: none;
}
.modal-box {
    width: 90vw;
    height: 90vh;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-head {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid #ddd;
}
#previewFrame {
    flex: 1;
    border: 0;
}
/* =========================================================
   BUILDER ELEMENTS
========================================================= */
.builder-node {
    position: relative;
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
}
.builder-node.selected {
    outline: 2px solid #1463ff;
    outline-offset: -2px;
}
/* =========================================================
   CONTAINER
========================================================= */
.builder-container {
    box-sizing: border-box;
    min-width: 0;
    min-height: 20px;
    position: relative;
    border: 1px dashed transparent;
}
.builder-container:hover {
    border-color: #b8c2ce;
}
.builder-container.selected {
    border: 2px solid #1463ff;
}
/* =========================================================
   CONTAINER LAYOUTS
========================================================= */
.builder-container[data-layout="normal"] {
    display: block;
}
.builder-container[data-layout="flex"] {
    display: flex;
}
.builder-container[data-layout="grid"] {
    display: grid;
}
/* =========================================================
   FLEX
========================================================= */
.builder-container[data-layout="flex"][data-direction="row"] {
    flex-direction: row;
}
.builder-container[data-layout="flex"][data-direction="column"] {
    flex-direction: column;
}
/* =========================================================
   GRID
========================================================= */
.builder-container[data-layout="grid"] {
    grid-template-columns: repeat(
        var(--grid-columns, 2),
        minmax(0, 1fr)
    );
}
/* =========================================================
   EMPTY CONTAINER
========================================================= */
.builder-empty {
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9aa3ad;
    font-size: 12px;
    border: 1px dashed #c9d0d8;
    pointer-events: none;
}
/* =========================================================
   TREE
========================================================= */
.tree {
    font-size: 13px;
}
.tree-node {
    user-select: none;
}
.tree-row {
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 30px;
    padding: 4px 6px;
    border-radius: 5px;
    cursor: pointer;
}
.tree-row:hover {
    background: #f0f3f6;
}
.tree-row.selected {
    background: #dce9ff;
}
.tree-toggle {
    width: 20px;
    border: 0;
    background: transparent;
    padding: 0;
}
.tree-children {
    margin-left: 15px;
}
.tree-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* =========================================================
   DROP TARGET
========================================================= */
.builder-drop-target {
    outline: 2px dashed #1463ff !important;
    outline-offset: -3px;
}