/* Damit 100vh wirklich genutzt wird */
html,
body {
    height: 100%;
}

h1 {
    font-size: 1.6rem;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.preview-stage {
    width: 100%;
    min-width: 0;
    display: flex;
    justify-content: center;
    /* hier zentrieren */
}

/* Weichzeichnen-Option ausblenden */
#bar-style-controls [data-bar-style="blur"] {
    display: none;
}

/* Globale Editor-Styles */
.editor-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    min-height: calc(100vh - 220px);
}

#editor-container {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    /* wichtig: nicht center */
}

/* Upload & Format Container - Side by Side */
.upload-format-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.upload-section {
    flex: 0 0 auto;
}

.accordion-container {
    flex: 0 0 auto;
    position: relative;
}

#formatAccordionToggle {
    white-space: nowrap;
}

.accordion-icon {
    display: inline-block;
    transition: transform 0.2s;
    margin-left: 4px;
    font-size: 0.7rem;
}

.accordion-open .accordion-icon {
    transform: rotate(-180deg);
}

/* Format Accordion Dropdown */
.format-accordion {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 220px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
}

.format-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background-color 0.2s;
}

.format-item:last-child {
    border-bottom: none;
}

.format-item:hover {
    background-color: #f8f9fa;
}

.format-item.active {
    background-color: var(--primary-color, #007bff);
    color: white;
}

.format-item-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.format-item-size {
    font-size: 0.75rem;
    opacity: 0.8;
}

.format-item-empty {
    padding: 12px;
    font-style: italic;
    color: #6c757d;
}

/* Preview-Frame */
.preview-frame {
    position: relative;
    margin: 0 auto;
    flex: 0 0 auto;
    overflow: hidden;
    transition: background-color 0.3s, filter 0.3s;
    border: 2px solid #ddd;
    background-color: #FFFFFF;
    box-sizing: border-box;
    width: auto;
    max-height: none;
    min-height: calc(75vh - 220px);
}

/* Bar-Style: Blur */
.preview-frame.bar-style-blur::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #FFFFFF;
    filter: blur(15px);
    pointer-events: none;
    z-index: 0;
}

.image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: grab;
    z-index: 1;
    touch-action: none;
    box-sizing: border-box;
}

.image-wrapper:active {
    cursor: grabbing;
}

.image-layer-fg {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    user-select: none;
    -webkit-user-drag: none;
    z-index: 2;
}

/* Wasserzeichen-Layer (WICHTIG: exakt auf Frame stretchen) */
.watermark-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-size: 100% 100%;
    /* statt contain */
    background-position: 0 0;
    background-repeat: no-repeat;
    z-index: 10;
}

/* Optionen */
.options-panel {
    margin-top: 12px;
    display: block;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

#context-controls-bars {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
}

#context-controls-bars .form-label {
    margin-bottom: 0;
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.9rem;
}

#bar-style-controls {
    flex: 0 0 auto;
    display: flex;
    gap: 0;
}

.color-picker-square {
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    border-radius: 4px !important;
    flex: 0 0 auto;
}

/* optional: innere Fläche auch sauber */
.color-picker-square::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-square::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

/* Mobile Layout */
@media (max-width: 768px) {

    /* Preview + Controls untereinander */
    #editor-container {
        flex: 1 1 auto;
        min-width: 0;
        align-items: stretch;
    }

    .preview-frame {
        margin: 0 auto 12px auto;
    }

    /* Options/Controls: umbrechen + volle Breite */
    #context-controls-bars {
        flex-wrap: wrap !important;
        justify-content: flex-start;
        gap: 10px !important;
    }

    /* Button soll in eigene Zeile / volle Breite */
    #export-button {
        width: 100%;
        margin-left: 0 !important;
    }

    /* Button-Gruppe darf umbrechen */
    #bar-style-controls {
        width: auto;
    }

    .format-accordion {
        min-width: 260px;
        max-height: 60vh;
    }

    .format-item {
        padding: 14px 14px;
        /* größer */
        gap: 6px;
    }

    .format-item-title {
        font-size: 1rem;
    }

    .format-item-size {
        font-size: 0.85rem;
    }

    h1 {
        font-size: 1.25rem;
    }

    header {
        padding-top: 6px !important;
        padding-bottom: 6px !important;
        margin-bottom: 0.5rem !important;
    }

    header img {
        height: 44px !important;
        margin-bottom: 0 !important;
    }
}