* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

html {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
        Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue',
        sans-serif;

}

html::selection {
    background: var(--bg-active-color);
    color: var(--text-active-color);
}

/* TOOLBAR */
#toolbar {
    position: absolute;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 50%;
    /* height: 4rem; */
    background-color: var(--bg-secondary-color);
    opacity: 0.9;
    color: var(--text-primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--padding-md);
    border: 2px solid var(--border-active-color);
    border-radius: var(--border-radius-md);
    backdrop-filter: blur(10px);
    z-index: 1000;
}

#toolbar h1 {
    font-size: var(--font-size-lg);
    transition: color 0.2s ease-in-out;
}

#toolbar h1:hover {
    cursor: pointer;
    color: var(--bg-danger-color);
}

.toolbar-divider {
    width: 1px;
    height: 30px;
    background-color: var(--border-active-color);
    margin: 0 10px;
}

#export-json:hover {
    background-color: var(--bg-success-color);
    color: var(--text-primary-color);
}

#export-html:hover {
    background-color: var(--bg-warning-color);
    color: var(--text-primary-color);
}

/* EDITOR */
#editor {
    width: 100%;
    height: 100vh;
    background-color: var(--bg-primary-color);
    /* display: flex; */
    display: grid;
    grid-template-areas:
        "layers-panel canvas properties-panel"
        "layers-panel canvas properties-panel";
    grid-template-columns: 15% 1fr 15%;
}

/* PANELS */
#layers-panel {
    /* width: 15%; */
    height: 100%;
    grid-area: layers-panel;
    background-color: var(--bg-secondary-color);
    border-right: 1px solid var(--border-active-color);
    padding: 10px;

}

#layers-panel h3 {
    margin-bottom: var(--gutter-md);
    color: var(--text-primary-color);
    font-size: var(--font-size-xl);
    opacity: 0.7;
}

.no-layers {
    color: var(--text-secondary-color);
    font-style: italic;
    width: 100%;
    height: 10%;
    border: 2px dashed var(--border-active-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

.no-layers.hidden {
    display: none;
}

.layers-list {
    display: flex;
    flex-direction: column;
    gap: var(--gutter-sm);
    padding: 0 var(--padding-sm) 0 0;
    overflow-y: auto;
    height: calc(100% - 50px);
}

.layers-list::-webkit-scrollbar {
    width: 6px;
    background-color: var(--bg-primary-color);
    border-radius: var(--border-radius-md);
}

.layers-list::-webkit-scrollbar-thumb {
    background-color: var(--bg-active-color);
    border-radius: var(--border-radius-md);
    cursor: grab;
}

.layers-list::-webkit-scrollbar-thumb:active {
    cursor: grabbing;
}

.layers-list p {
    padding: var(--padding-sm);
    background-color: var(--bg-primary-color);
    border: 1px solid var(--border-active-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary-color);
    cursor: grab;
    transition: all 0.2s ease-in-out;
}

.layers-list p:hover {
    background-color: var(--bg-active-color);
    color: var(--text-active-color);
    border-color: var(--border-primary-color);
}

.layers-list p:active {
    cursor: grabbing;
    transform: scale(0.98);
}

/* Layer Item Styles */
.layer-item {
    display: flex;
    align-items: center;
    gap: var(--gutter-sm);
    padding: var(--padding-sm);
    background-color: var(--bg-primary-color);
    border: 1px solid var(--border-active-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary-color);
    cursor: grab;
    transition: all 0.2s ease-in-out;
    user-select: none;
}

.layer-item:hover {
    background-color: var(--bg-active-color);
    color: var(--text-active-color);
    border-color: var(--border-primary-color);
}

.layer-item.selected {
    background-color: var(--bg-active-color);
    color: var(--text-active-color);
    border-color: var(--border-primary-color);
    outline: 2px solid var(--border-primary-color);
}

.layer-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.layer-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-md);
    width: 20px;
    height: 20px;
}

.layer-name {
    flex: 1;
    font-size: var(--font-size-md);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-controls {
    display: flex;
    gap: var(--gutter-xs);
    align-items: center;
}

.layer-btn {
    font-size: var(--font-size-md);
    cursor: pointer;
    padding: var(--padding-xs);
    transition: all 0.2s ease-in-out;
    border-radius: var(--border-radius-sm);
}

.layer-btn:hover {
    transform: scale(1.15);
    color: var(--border-primary-color);
    background-color: rgba(255, 255, 255, 0.1);
}

.layer-visibility {
    font-size: var(--font-size-md);
    cursor: pointer;
    padding: var(--padding-xs);
    transition: all 0.2s ease-in-out;
}

.layer-visibility:hover {
    transform: scale(1.1);
    color: var(--border-primary-color);
}

#properties-panel {
    /* width: 15%; */
    height: 100%;
    grid-area: properties-panel;
    background-color: var(--bg-secondary-color);
    border-left: 1px solid var(--border-active-color);
    padding: 10px;
    /* overflow-y: auto; */
}

#properties-panel h3 {
    margin-bottom: var(--gutter-md);
    color: var(--text-primary-color);
    font-size: var(--font-size-xl);
    opacity: 0.7;
}

.selection {
    color: var(--text-secondary-color);
    font-style: italic;
    width: 100%;
    height: 10%;
    border: 2px dashed var(--border-active-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

.selection.hidden {
    display: none;
}

.properties-list {
    display: flex;
    flex-direction: column;
    gap: var(--gutter-md);
    overflow-y: auto;
    height: calc(100% - 50px);
    padding-right: var(--padding-md);
}

.properties-list label {
    color: var(--text-primary-color);
    font-size: var(--font-size-md);
    font-weight: 500;
}

.properties-list input,
.properties-list select {
    width: 100%;
    padding: var(--padding-sm);
    border: 1px solid var(--border-active-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-primary-color);
    color: var(--text-primary-color);
    font-size: var(--font-size-md);
    margin-top: var(--margin-xs);
    transition: all 0.2s ease-in-out;
}

.properties-list input:focus,
.properties-list select:focus {
    outline: none;
    border-color: var(--border-primary-color);
    background-color: var(--bg-active-color);
    color: var(--text-active-color);
}

/* Property Label and Input Styling */
.property-label {
    display: flex;
    flex-direction: column;
    gap: var(--gutter-xs);
    color: var(--text-primary-color);
    font-size: var(--font-size-md);
    font-weight: 500;
}

.property-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gutter-sm);
}

.property-row .range-value {
    white-space: nowrap;
    font-size: var(--font-size-sm);
}

.property-label span {
    display: block;
}

.property-input {
    padding: var(--padding-sm);
    border: 1px solid var(--border-active-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-primary-color);
    color: var(--text-primary-color);
    font-size: var(--font-size-md);
    transition: all 0.2s ease-in-out;
}

.property-input:focus {
    outline: none;
    border-color: var(--border-primary-color);
    background-color: var(--bg-active-color);
    color: var(--text-active-color);
    box-shadow: 0 0 5px var(--border-primary-color);
}

.property-input[type="range"] {
    height: 6px;
    cursor: grab;
    padding: 0;
}

.property-input[type="range"]:active {
    cursor: grabbing;
}

.property-input.color-picker {
    width: 100%;
    height: 40px;
    cursor: pointer;
}

.range-value {
    display: inline-block;
    background-color: var(--bg-active-color);
    color: var(--text-active-color);
    padding: var(--padding-xs) var(--padding-sm);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-sm);
    font-weight: bold;
}

#rotation,
#opacity {
    cursor: grab;
}

#rotation:active,
#opacity:active {
    cursor: grabbing;
}

.properties-list::-webkit-scrollbar {
    width: 6px;
    background-color: var(--bg-primary-color);
    border-radius: var(--border-radius-md);
}

.properties-list::-webkit-scrollbar-thumb {
    background-color: var(--bg-active-color);
    border-radius: var(--border-radius-md);
    cursor: grab;
}

.properties-list::-webkit-scrollbar-thumb:active {
    cursor: grabbing;
}


#color-picker {
    width: 100%;
    height: 50px;
    border: 1px solid var(--border-active-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-primary-color);
    margin-top: var(--margin-xs);
}

.alignment {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    justify-content: center;
    align-items: center;
    /* margin-top: var(--margin-sm); */
    padding-top: var(--margin-sm);
    border-top: 2px solid var(--border-active-color);
    gap: var(--gutter-sm);
}

.alignment i {
    text-align: center;
    color: var(--text-primary-color);
    font-size: var(--font-size-lg);
    padding: var(--padding-sm);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.alignment i:hover {
    background-color: var(--bg-active-color);
    color: var(--text-active-color);
    border-radius: var(--border-radius-sm);
}

/* CANVAS */
#canvas-wrapper {
    flex: 1;
    grid-area: canvas;
    height: 100%;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

#canvas-wrapper::-webkit-scrollbar,
#canvas::-webkit-scrollbar {
    display: none;
}

#canvas {
    width: 4000px;
    height: 1000px;
    overflow: auto;
    position: relative;
    background-image: radial-gradient(#444 1px, transparent 1px);
    background-size: 20px 20px;
}

/* TOOLS */
.tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--gutter-md);
}

.tools i {
    flex: 1;
    color: var(--text-primary-color);
    font-size: var(--font-size-lg);
    font-weight: bold;
    background-color: var(--bg-secondary-color);
    padding: var(--padding-sm);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-active-color);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease-in-out;
}

.tools i:hover {
    background-color: var(--bg-active-color);
    color: var(--text-active-color);
    border-color: var(--border-primary-color);
}

.tools i:active {
    transform: scale(0.95);
}

.tools #delete:hover {
    background-color: var(--bg-danger-color);
    color: var(--text-primary-color);
}

.rectangle {
    width: 100px;
    height: 100px;
    position: absolute;
    /* border: 2px solid var(--border-active-color); */
    background-color: rgba(38, 142, 38, 0.3);
    cursor: move;
}

.circle {
    width: 100px;
    height: 100px;
    position: absolute;
    /* border: 2px solid var(--border-active-color); */
    border-radius: 50%;
    background-color: rgba(0, 190, 204, 0.3);
    cursor: move;
}

.image-element {
    width: 250px;
    position: absolute;
    border: 2px solid var(--border-active-color);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    cursor: move;
}

.text {
    position: absolute;
    /* border: 2px solid var(--border-active-color); */
    /* padding: var(--padding-sm); */
    background-color: transparent;
    cursor: move;
}

.selected {
    outline: 3px dashed var(--bg-active-color);
}

.resize {
    position: absolute;
    width: 10px;
    height: 10px;
    right: -5px;
    bottom: -5px;
    background: white;
    border: 1px solid #000;
    z-index: 1000;
    cursor: se-resize;
}

.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border: 1px solid #000;
    z-index: 1000;
}

.resize-handle.br {
    right: -5px;
    bottom: -5px;
    cursor: se-resize;
}

.resize-handle.bl {
    left: -5px;
    bottom: -5px;
    cursor: sw-resize;
}

.resize-handle.tr {
    right: -5px;
    top: -5px;
    cursor: ne-resize;
}

.resize-handle.tl {
    left: -5px;
    top: -5px;
    cursor: nw-resize;
}