/* Atelier – Studio-Look (hell, ruhig) */
:root {
    --atelier-bg: #f5f5f3;
    --atelier-stage: #ffffff;
    --atelier-panel: #ecebe7;
    --atelier-border: #dcdcdc;
    --atelier-accent: #4a6fa5;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--atelier-bg);
    color: #222;
    overflow: hidden;
}

/* Topbar */
.atelier-topbar {
    height: 48px;
    background: var(--atelier-panel);
    border-bottom: 1px solid var(--atelier-border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.atelier-topbar .dirty {
    font-size: 12px;
    color: #888;
}

.atelier-topbar .dirty.unsaved {
    color: #c00;
}

.atelier-topbar button {
    padding: 6px 12px;
    background: var(--atelier-accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.atelier-topbar button:hover {
    filter: brightness(1.1);
}

.atelier-topbar button.secondary {
    background: transparent;
    color: #444;
    border: 1px solid var(--atelier-border);
}
.atelier-topbar select.secondary {
    padding: 6px 10px;
    border: 1px solid var(--atelier-border);
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
}

/* Viewport */
.atelier-main {
    display: flex;
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--atelier-bg);
}
.atelier-side {
    width: 220px;
    min-width: 180px;
    background: var(--atelier-panel);
    border-right: 1px solid var(--atelier-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.atelier-side-right {
    border-right: none;
    border-left: 1px solid var(--atelier-border);
}
.panel-title {
    padding: 10px 12px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #555;
    border-bottom: 1px solid var(--atelier-border);
}
.layers-panel {
    flex: 1;
    overflow: auto;
    padding: 6px;
}
.layers-panel-empty {
    padding: 12px;
    color: #888;
    font-size: 13px;
}
.layers-panel-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
}
.layers-panel-row:hover {
    background: rgba(0,0,0,0.05);
}
.layers-panel-row.selected {
    background: rgba(74, 111, 165, 0.15);
}
.layers-panel-row .layer-eye,
.layers-panel-row .layer-lock {
    cursor: pointer;
    opacity: 0.8;
}
.layers-panel-row .layer-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}
.layers-panel-row .layer-delete {
    cursor: pointer;
    color: #888;
    padding: 2px;
}
.layers-panel-row .layer-delete:hover {
    color: #c00;
}
.properties-panel {
    flex: 1;
    overflow: auto;
    padding: 10px;
}
.properties-panel-empty {
    color: #888;
    font-size: 13px;
}
.properties-panel-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.properties-panel-form label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}
.properties-panel-form input {
    width: 80px;
    padding: 4px 6px;
    border: 1px solid var(--atelier-border);
    border-radius: 4px;
}
.properties-panel-form .full-width { width: 100%; }
.properties-panel-form .full-width input { width: 100%; }
.properties-panel-form textarea {
    width: 100%;
    min-height: 80px;
    padding: 6px 8px;
    border: 1px solid var(--atelier-border);
    border-radius: 4px;
    resize: vertical;
    font-family: inherit;
}
.properties-text-fields { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--atelier-border); }
.atelier-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.viewport-wrap {
    flex: 1;
    display: flex;
    min-height: 0;
}
.ruler {
    background: #e8e6e3;
    border: 1px solid var(--atelier-border);
}
.ruler-top {
    height: 22px;
    width: 100%;
    cursor: crosshair;
}
.ruler-left {
    width: 22px;
    flex: 0 0 22px;
    cursor: crosshair;
}
#viewport {
    flex: 1;
    overflow: hidden;
    background: #e8e8e6;
}

#world {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

/* Stage */
#stage {
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
}

#stage .stage-inner {
    position: relative;
}

#stage .layers-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

#stage .layers-container .layer {
    position: absolute;
    pointer-events: auto;
    box-sizing: border-box;
    overflow: hidden;
}

#stage .layers-container .layer.selected {
    outline: 2px solid var(--atelier-accent);
    outline-offset: 1px;
}

#stage .layers-container .layer img {
    pointer-events: none;
    user-select: none;
}

#stage .guides-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.guide {
    position: absolute;
    background: rgba(74, 111, 165, 0.5);
}

.guide.vertical {
    width: 1px;
    height: 100%;
}

.guide.horizontal {
    height: 1px;
    width: 100%;
}
.guide.guide-preview {
    background: var(--atelier-accent);
    opacity: 0.9;
}

/* Smart Guides (temporär beim Drag) */
.smart-guides-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10000;
}

.smart-guide {
    position: absolute;
    background: var(--atelier-accent);
    opacity: 0.8;
}

.smart-guide.vertical {
    width: 1px;
    height: 100%;
}

.smart-guide.horizontal {
    height: 1px;
    width: 100%;
}

/* Layer-Text nicht editierbar in Präsentation */
#stage .layer-text {
    white-space: pre-wrap;
    word-break: break-word;
}
#stage .layer-text[contenteditable="true"] {
    outline: 2px solid var(--atelier-accent);
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.98);
    cursor: text;
}

/* Transform-Handles */
.transform-handles {
    position: absolute;
    box-sizing: border-box;
    outline: 2px solid var(--atelier-accent);
    outline-offset: -1px;
}

.transform-handles .handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 1px solid var(--atelier-accent);
    border-radius: 1px;
    cursor: default;
}

.transform-handles .handle-nw { cursor: nwse-resize; }
.transform-handles .handle-n  { cursor: ns-resize; }
.transform-handles .handle-ne { cursor: nesw-resize; }
.transform-handles .handle-e  { cursor: ew-resize; }
.transform-handles .handle-se { cursor: nwse-resize; }
.transform-handles .handle-s  { cursor: ns-resize; }
.transform-handles .handle-sw { cursor: nesw-resize; }
.transform-handles .handle-w  { cursor: ew-resize; }
.transform-handles .handle-rotate {
    cursor: grab;
    border-radius: 50%;
    top: -24px;
}
.transform-handles .handle-rotate:active { cursor: grabbing; }

/* Dialogs */
.atelier-dialog { padding: 0; border: 1px solid var(--atelier-border); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); max-width: 480px; }
.atelier-dialog h3 { margin: 0 0 8px 0; font-size: 1.1rem; padding: 16px 16px 0; }
.atelier-dialog .dialog-hint { font-size: 12px; color: #666; margin: 0 0 12px 0; padding: 0 16px; }
.atelier-dialog label { display: block; padding: 0 16px 10px; font-size: 13px; }
.atelier-dialog label textarea, .atelier-dialog label input[type="text"], .atelier-dialog label input[type="url"], .atelier-dialog label input[type="password"] { width: 100%; padding: 6px 8px; margin-top: 4px; border: 1px solid var(--atelier-border); border-radius: 4px; box-sizing: border-box; }
.atelier-dialog #exportMenuLinks { padding: 0 16px 10px; }
.atelier-dialog #exportMenuLinks input { width: 48%; padding: 6px 8px; margin: 2px 1% 6px 0; border: 1px solid var(--atelier-border); border-radius: 4px; box-sizing: border-box; }
.atelier-dialog .dialog-actions { padding: 12px 16px 16px; display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--atelier-border); }
.atelier-dialog .dialog-actions button { padding: 8px 14px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.atelier-dialog .dialog-actions button:not(.secondary) { background: var(--atelier-accent); color: #fff; border: none; }
.atelier-dialog .dialog-actions button.secondary { background: #fff; color: #444; border: 1px solid var(--atelier-border); }
