/* Stickerleinwand — komplettes Styling. Siehe README.md Teil B.1. */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: #f0f0f0;
    touch-action: none;
    position: fixed;
    width: 100%;
    height: 100%;
}

#canvasContainer {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgb(254, 252, 236);
    overflow: hidden;
}

.roundButton {
    position: fixed;
    bottom: 20px;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: transform 0.3s, background 0.3s;
}

.roundButton:active {
    transform: scale(0.95);
}

#addButton {
    left: 20px;
    background: #4CAF50;
}

#textButton {
    left: 82px;
    background: #3f51b5;
    font-size: 22px;
    font-weight: bold;
}

#imageSelector {
    position: fixed;
    bottom: 80px;
    left: 20px;
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 999;
    width: 310px;
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

#imageSelector h3 {
    margin-bottom: 10px;
    color: #333;
}

#imageSelector h4 {
    margin: 12px 0 8px;
    color: #666;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.searchRow {
    position: sticky;
    top: 0;
    background: white;
    padding-bottom: 10px;
    z-index: 2;
}

#stickerSearch {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font: inherit;
    font-size: 14px;
}

#stickerSearch:focus {
    outline: none;
    border-color: #4CAF50;
}

.groupHeader {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 2px;
    background: none;
    border: none;
    border-top: 1px solid #eee;
    font: inherit;
    color: #555;
    text-align: left;
    cursor: pointer;
}

.groupCaret {
    font-size: 10px;
    color: #aaa;
    transition: transform 0.2s;
}

.stickerGroup.open .groupCaret {
    transform: rotate(90deg);
}

.groupTitle {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.groupCount {
    font-size: 12px;
    color: #888;
    background: #f2f2f2;
    border-radius: 10px;
    padding: 1px 8px;
}

.stickerGroup .imageGrid {
    display: none;
}

.stickerGroup.open .imageGrid {
    display: grid;
}

.stickerGroup.hidden,
.imageThumb.hidden {
    display: none;
}

#searchEmpty {
    display: none;
    padding: 14px 2px;
    color: #888;
    font-size: 13px;
}

#searchEmpty.visible {
    display: block;
}

.imageGrid {
    display: grid;
    grid-template-columns: repeat(3, 80px);
    gap: 10px;
    margin-bottom: 10px;
}

.imageThumb {
    width: 80px;
    height: 80px;
    object-fit: contain;
    background: rgb(254, 252, 236);
    cursor: pointer;
    border: 2px solid #eee;
    border-radius: 4px;
    transition: transform 0.2s, border-color 0.2s;
}

.imageThumb:active {
    transform: scale(0.95);
    border-color: #4CAF50;
}

#customImageInput {
    margin-top: 10px;
    width: 100%;
}

.canvasItem {
    position: absolute;
    touch-action: none;
    cursor: move;
}

.canvasItem.selected {
    z-index: 100;
}

.canvasItem.selected > img,
.canvasItem.selected > .textBody {
    outline: 2px solid #4CAF50;
}

.textBody {
    font-size: 28px;
    line-height: 1.25;
    color: #222222;
    padding: 6px 8px;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    outline-offset: 0;
}

.canvasItem.editing {
    cursor: text;
}

.canvasItem.editing > .textBody {
    outline: 2px dashed #3f51b5;
    cursor: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.canvasItem.editing > .textBody:focus {
    outline: 2px dashed #3f51b5;
}

.itemControls {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    display: none;
}

.canvasItem.selected .itemControls {
    display: block;
}

.control-handle {
    position: absolute;
    pointer-events: auto;
    touch-action: none;
}

.rotateHandle {
    bottom: -12px;
    left: -12px;
    width: 24px;
    height: 24px;
    background: #ffeb3b;
    border-radius: 50%;
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.deleteHandle {
    top: -12px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: #f44336;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.scaleHandle {
    bottom: -12px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: #2196F3;
    border-radius: 50%;
    cursor: nwse-resize;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.editHandle {
    top: -12px;
    left: -12px;
    width: 24px;
    height: 24px;
    background: #3f51b5;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.canvasItem[data-kind="text"] .editHandle {
    display: flex;
}

#toolbar {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.toolButton {
    padding: 8px 16px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.toolButton:active {
    background: #e0e0e0;
}

#textToolbar {
    position: fixed;
    top: 70px;
    right: 20px;
    display: none;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    z-index: 1000;
}

#textToolbar.visible {
    display: flex;
}

.colorSwatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #ddd;
    cursor: pointer;
}

.colorSwatch.active {
    border-color: #333;
}

.textToolDivider {
    width: 1px;
    height: 24px;
    background: #ddd;
}

.textToolButton {
    min-width: 30px;
    height: 28px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.textToolButton.active {
    background: #3f51b5;
    border-color: #3f51b5;
    color: white;
}

#fileInput {
    display: none;
}
