:root {
    --bg-color: #f0f0f0;
    --toolbar-bg: #2d2d2d;
    --toolbar-fg: #ffffff;
    --inspector-bg: #ffffff;
    --inspector-border: #cccccc;
    --accent-color: #007bff;
    --selection-color: rgba(0, 123, 255, 0.5);
    --handle-color: #ffffff;
    --handle-border: #007bff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Topbar */
.topbar {
    height: 50px;
    background-color: var(--toolbar-bg);
    color: var(--toolbar-fg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.topbar .logo {
    font-weight: bold;
    font-size: 1.2rem;
}

.topbar .tools button, .topbar .actions button {
    background: transparent;
    border: 1px solid #555;
    color: white;
    padding: 5px 10px;
    margin: 0 5px;
    cursor: pointer;
    border-radius: 4px;
}

.topbar .tools button:hover, .topbar .actions button:hover {
    background: #444;
}

.topbar .tools button.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

/* Main Workspace */
.main-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    background-color: var(--bg-color);
    overflow: auto; /* Allow scrolling if artboard is larger */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Artboard */
.artboard {
    width: 1200px;
    height: 800px; /* Default sizes, can be modified */
    background-color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    position: relative;
    transform-origin: center center;
}

/* Layers */
.layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.dom-layer {
    z-index: 1;
    pointer-events: none; /* Let pointer events go to elements or svg based on mode */
}

.dom-layer > * {
    pointer-events: auto;
}

.svg-layer {
    z-index: 2;
    pointer-events: none; /* Default none, pen tool will enable it */
}

.editor-layer {
    z-index: 3;
    pointer-events: none;
}

/* Elements on canvas */
.canvas-element {
    position: absolute;
    user-select: none;
}

/* Text editing */
.canvas-element[contenteditable="true"] {
    cursor: text;
    user-select: text;
    outline: none;
}

/* Inspector */
.inspector {
    width: 300px;
    background-color: var(--inspector-bg);
    border-left: 1px solid var(--inspector-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.inspector h3 {
    padding: 15px;
    border-bottom: 1px solid var(--inspector-border);
    font-size: 1rem;
    margin: 0;
    background: #fafafa;
}

#inspector-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
}

.inspector-group {
    margin-bottom: 15px;
}

.inspector-group label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: #555;
    font-weight: bold;
}

.inspector-group input, .inspector-group select {
    width: 100%;
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
}

.inspector-group input[type="color"] {
    height: 30px;
    padding: 2px;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
}

.btn-danger:hover {
    background-color: #c82333;
}

/* Selection Box & Handles */
.selection-box {
    position: absolute;
    border: 2px solid var(--accent-color);
    pointer-events: none;
    box-sizing: border-box;
}

.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--handle-color);
    border: 1px solid var(--handle-border);
    border-radius: 50%;
    pointer-events: auto;
    transform: translate(-50%, -50%);
}

.handle-nw { top: 0; left: 0; cursor: nwse-resize; }
.handle-n  { top: 0; left: 50%; cursor: ns-resize; }
.handle-ne { top: 0; left: 100%; cursor: nesw-resize; }
.handle-e  { top: 50%; left: 100%; cursor: ew-resize; }
.handle-se { top: 100%; left: 100%; cursor: nwse-resize; }
.handle-s  { top: 100%; left: 50%; cursor: ns-resize; }
.handle-sw { top: 100%; left: 0; cursor: nesw-resize; }
.handle-w  { top: 50%; left: 0; cursor: ew-resize; }
