/**
 * YForm Content Builder CSS
 * Styling für Slices, Toolbar und Drag&Drop
 */

/* Container */
.yform-content-builder {
    position: relative;
}

.content-builder-slices {
    min-height: 100px;
    margin-bottom: 15px;
}

/* Einzelnes Slice */
.content-builder-slice {
    position: relative;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: transparent;
    transition: all 0.2s ease;
}

/* Offline geschalteter Slice */
.content-builder-slice.is-offline {
    border-style: dashed;
    border-color: #d9534f;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(217, 83, 79, 0.05) 10px,
        rgba(217, 83, 79, 0.05) 20px
    );
}

/* Nur der gerenderte Inhalt wird "offline" dargestellt,
   Toolbar und Edit-Formular bleiben voll bedienbar */
.content-builder-slice.is-offline > .slice-rendered {
    opacity: 0.55;
    filter: grayscale(0.6);
}

.content-builder-slice.is-offline::before {
    content: "OFFLINE";
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    background: #d9534f;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    pointer-events: none;
}

.content-builder-slice.is-offline .btn-slice-toggle-online {
    background-color: #d9534f;
    color: #fff;
    border-color: #d43f3a;
}

/* Section-Element: Visuell hervorgehoben */
.content-builder-slice.is-section {
    border: 2px solid #3c8dbc;
    background: linear-gradient(to bottom, #e8f4f8 0%, #f5fbfd 100%);
    margin-bottom: 10px;
}

.content-builder-slice.is-section .slice-rendered {
    padding: 15px;
}

/* Section Backend Label */
.section-backend-label {
    font-size: 14px;
    color: #3c8dbc;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-backend-label i {
    margin-right: 5px;
}

.section-backend-label .section-info {
    margin-left: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.section-backend-label .label {
    font-size: 11px;
    margin: 0;
    vertical-align: middle;
}

/* Hintergrund-Thumbnail (kleine Preview) */
.section-bg-thumbnail {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background-size: cover;
    background-position: center center;
    vertical-align: middle;
    margin-left: auto;
    flex-shrink: 0;
}

.section-bg-thumbnail.bg-light {
    background-color: #f5f5f5;
}

.section-bg-thumbnail.bg-none,
.section-bg-thumbnail.bg-transparent {
    background-color: transparent;
}

.section-bg-thumbnail.bg-dark {
    background-color: #333;
}

.section-bg-thumbnail.bg-primary {
    background-color: #007bff;
}

.section-bg-thumbnail.bg-secondary {
    background-color: #6c757d;
}

.section-bg-thumbnail.bg-muted {
    background-color: #f8f9fa;
}

.section-bg-thumbnail.bg-white {
    background-color: #fff;
    border: 2px solid #ddd;
}

/* Bootstrap helper classes for backend preview */
.yform-content-builder .bg-light,
.content-builder-slice .bg-light {
    background-color: #f8f9fa !important;
}

.yform-content-builder .bg-white,
.content-builder-slice .bg-white {
    background-color: #ffffff !important;
}

.yform-content-builder .bg-secondary,
.content-builder-slice .bg-secondary {
    background-color: #6c757d !important;
}

.yform-content-builder .bg-transparent,
.content-builder-slice .bg-transparent {
    background-color: transparent !important;
}

/* Elemente innerhalb einer Section: Eingerückt (via JS-Klasse) */
.content-builder-slice.in-section {
    margin-left: 30px;
    margin-bottom: 15px;
    border-left: 3px solid #3c8dbc;
    background: transparent;
    position: relative;
}

.content-builder-slice.in-section::before {
    content: '';
    position: absolute;
    left: -3px;
    top: -15px;
    width: 3px;
    height: 15px;
    background: #3c8dbc;
}

.content-builder-slice.in-section:first-of-type::before {
    display: none;
}

.content-builder-slice:hover {
    border-color: #3c8dbc;
    box-shadow: 0 2px 8px rgba(60, 141, 188, 0.2);
}

.content-builder-slice.ui-sortable-helper {
    opacity: 0.8;
    cursor: move;
}

/* Sortable.js Ghost */
.content-builder-slice.slice-ghost {
    opacity: 0.4;
    background: #f0f8ff;
}

.content-builder-slice.sortable-drag {
    opacity: 0.8;
    cursor: move;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Kompaktmodus */
.yform-content-builder.compact-mode .content-builder-slice {
    margin-bottom: 0;
    border: none;
    background: transparent;
    border-radius: 0;
    transition: all 0.2s ease;
}

.yform-content-builder.compact-mode .content-builder-slice:hover {
    border: none;
    box-shadow: none;
}

.yform-content-builder.compact-mode .slice-rendered {
    padding: 0;
    min-height: 35px;
}

.yform-content-builder.compact-mode .content-builder-slice.is-section {
    border: 2px dashed #3c8dbc;
    background: rgba(232, 244, 248, 0.3);
    margin-bottom: 0;
    padding: 10px 0;
}

.yform-content-builder.compact-mode .content-builder-slice.is-section .slice-rendered {
    padding: 10px;
}

.yform-content-builder.compact-mode .content-builder-slice.in-section {
    margin-left: 10px;
    margin-bottom: 0;
    border-left: 2px solid #3c8dbc;
    background: transparent;
    padding-left: 5px;
}

.yform-content-builder.compact-mode .content-builder-slice.in-section::before {
    display: none;
}

/* Toolbar */
.slice-toolbar {
    position: absolute;
    top: -1px;
    right: -1px;
    z-index: 100;
    background: rgba(60, 141, 188, 0.9);
    border-radius: 0 4px 0 4px;
    padding: 2px;
    pointer-events: auto;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.content-builder-slice:hover > .slice-toolbar {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

.slice-toolbar .btn-group {
    display: inline-block;
    vertical-align: middle;
}

/* Element-Name-Chip links in der Toolbar */
.slice-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0 8px;
    height: 26px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 3px;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
    vertical-align: middle;
    margin-right: 2px;
    pointer-events: none;
    user-select: none;
}

.slice-toolbar .dropdown-menu {
    right: 0;
    left: auto;
    margin-top: 2px;
    z-index: 99999;
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: width 0.2s ease, max-height 0.2s ease, box-shadow 0.2s ease, scrollbar-color 0.2s;
    will-change: width;
}

.slice-toolbar .dropdown-menu:hover {
    scrollbar-color: rgba(60, 141, 188, 0.45) transparent;
}

.slice-toolbar .dropdown-menu::-webkit-scrollbar {
    width: 4px;
}

.slice-toolbar .dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
}

.slice-toolbar .dropdown-menu::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 4px;
}

.slice-toolbar .dropdown-menu:hover::-webkit-scrollbar-thumb {
    background: rgba(60, 141, 188, 0.45);
}

/* Suchfeld oben fixiert beim Scrollen */
.slice-toolbar .dropdown-menu .dropdown-search-wrapper {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fff;
    padding: 5px 8px 4px;
    border-bottom: 1px solid #e8e8e8;
    margin-bottom: 2px;
    list-style: none;
}

.slice-toolbar .dropdown-menu .dropdown-search {
    width: 100%;
    padding: 6px 8px;
    font-size: 12px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #fff;
    color: #333;
}

.slice-toolbar .dropdown-menu .dropdown-search:focus {
    outline: none;
    border-color: #3c8dbc;
    box-shadow: 0 0 3px rgba(60, 141, 188, 0.3);
}

.slice-toolbar .btn {
    margin: 0 1px;
    border: none;
    color: #fff;
    background: transparent;
    pointer-events: auto;
    cursor: pointer;
}

.slice-toolbar .btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.slice-toolbar .btn-danger {
    color: #fff;
}

.slice-toolbar .btn-danger:hover {
    background: rgba(217, 83, 79, 0.8);
}

/* Gerenderte Ansicht */
.slice-rendered {
    padding: 15px;
    min-height: 40px;
}

.slice-rendered:hover {
    background: rgba(60, 141, 188, 0.02);
}

/* Edit-Form */
.slice-edit-form {
    padding: 15px;
    background: #f9f9f9;
    border-top: 2px solid #3c8dbc;
}

.slice-edit-form .form-group {
    margin-bottom: 15px;
}

/* Nur direktes Kind: separiert die Save/Cancel-Buttonleiste am Ende des Formulars.
   Nicht auf form-groups in Spalten/Repeatern anwenden (sonst Strich über Feldern). */
.slice-edit-form > .form-group:last-child {
    margin-bottom: 0;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
}

.slice-edit-form .btn-group {
    display: inline-block;
}

.slice-edit-form .btn-slice-save {
    margin-right: 5px;
}

.slice-edit-form .slice-form-actions-note {
    float: left;
    margin-top: 9px;
    font-size: 12px;
    color: #5f6f7f;
}

.slice-edit-form .slice-form-actions-note .fa {
    margin-right: 6px;
    color: #2f8fb0;
}

.slice-edit-form .cb-slice-action-group .btn {
    font-weight: 600;
    letter-spacing: 0.01em;
}

.slice-edit-form .cb-slice-action-group .cb-btn-apply {
    background: linear-gradient(135deg, #138a70 0%, #0e7392 100%);
    border-color: #0e7392;
    color: #fff;
}

.slice-edit-form .cb-slice-action-group .cb-btn-apply:hover,
.slice-edit-form .cb-slice-action-group .cb-btn-apply:focus {
    background: linear-gradient(135deg, #10775f 0%, #0c627b 100%);
    color: #fff;
}

.slice-edit-form .cb-slice-action-group .cb-btn-cancel {
    background: #fff;
    border-color: #cc5a5a;
    color: #9f3131;
}

.slice-edit-form .cb-slice-action-group .cb-btn-cancel:hover,
.slice-edit-form .cb-slice-action-group .cb-btn-cancel:focus {
    background: #fff3f3;
    border-color: #b64040;
    color: #842323;
}

body.rex-theme-dark .slice-edit-form .slice-form-actions-note {
    color: #8fa3b3;
}

body.rex-theme-dark .slice-edit-form .slice-form-actions-note .fa {
    color: #45b8d4;
}

body.rex-theme-dark .slice-edit-form .cb-slice-action-group .cb-btn-apply {
    background: linear-gradient(135deg, #1fa889 0%, #1a7fa5 100%);
    border-color: #1a7fa5;
    color: #fff;
}

body.rex-theme-dark .slice-edit-form .cb-slice-action-group .cb-btn-apply:hover,
body.rex-theme-dark .slice-edit-form .cb-slice-action-group .cb-btn-apply:focus {
    background: linear-gradient(135deg, #1a9579 0%, #147a93 100%);
    color: #fff;
}

body.rex-theme-dark .slice-edit-form .cb-slice-action-group .cb-btn-cancel {
    background: #1a1a1a;
    border-color: #c75555;
    color: #ff8b8b;
}

body.rex-theme-dark .slice-edit-form .cb-slice-action-group .cb-btn-cancel:hover,
body.rex-theme-dark .slice-edit-form .cb-slice-action-group .cb-btn-cancel:focus {
    background: #2a1a1a;
    border-color: #d66b6b;
    color: #ffa3a3;
}

@media (prefers-color-scheme: dark) {
    body.rex-has-theme:not(.rex-theme-light) .slice-edit-form .slice-form-actions-note {
        color: #8fa3b3;
    }

    body.rex-has-theme:not(.rex-theme-light) .slice-edit-form .slice-form-actions-note .fa {
        color: #45b8d4;
    }

    body.rex-has-theme:not(.rex-theme-light) .slice-edit-form .cb-slice-action-group .cb-btn-apply {
        background: linear-gradient(135deg, #1fa889 0%, #1a7fa5 100%);
        border-color: #1a7fa5;
        color: #fff;
    }

    body.rex-has-theme:not(.rex-theme-light) .slice-edit-form .cb-slice-action-group .cb-btn-apply:hover,
    body.rex-has-theme:not(.rex-theme-light) .slice-edit-form .cb-slice-action-group .cb-btn-apply:focus {
        background: linear-gradient(135deg, #1a9579 0%, #147a93 100%);
        color: #fff;
    }

    body.rex-has-theme:not(.rex-theme-light) .slice-edit-form .cb-slice-action-group .cb-btn-cancel {
        background: #1a1a1a;
        border-color: #c75555;
        color: #ff8b8b;
    }

    body.rex-has-theme:not(.rex-theme-light) .slice-edit-form .cb-slice-action-group .cb-btn-cancel:hover,
    body.rex-has-theme:not(.rex-theme-light) .slice-edit-form .cb-slice-action-group .cb-btn-cancel:focus {
        background: #2a1a1a;
        border-color: #d66b6b;
        color: #ffa3a3;
    }
}

.yform-cb-persist-status {
    border: 1px solid #d9e4ef;
    border-radius: 6px;
    padding: 10px 12px;
    background: linear-gradient(180deg, #f9fbfd 0%, #f2f7fb 100%);
}

.yform-cb-persist-status .yform-cb-persist-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.yform-cb-persist-status .yform-cb-persist-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #32d296;
    box-shadow: 0 0 0 3px rgba(50, 210, 150, 0.18);
    flex: 0 0 10px;
}

.yform-cb-persist-status .yform-cb-persist-text {
    font-size: 13px;
}

.yform-cb-persist-status .yform-cb-persist-hint {
    margin-top: 6px;
    color: #607286;
    font-size: 12px;
}

.yform-cb-persist-status .yform-cb-persist-hint .fa {
    margin-right: 6px;
}

.yform-cb-persist-status.is-dirty {
    border-color: #f0d7a6;
    background: linear-gradient(180deg, #fffaf0 0%, #fff6e7 100%);
}

.yform-cb-persist-status.is-dirty .yform-cb-persist-dot {
    background: #f5a623;
    box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.2);
}

.yform-cb-persist-status.is-saving {
    border-color: #b8d6f4;
    background: linear-gradient(180deg, #f3f9ff 0%, #eaf4ff 100%);
}

.yform-cb-persist-status.is-saving .yform-cb-persist-dot {
    background: #2f8fb0;
    box-shadow: 0 0 0 3px rgba(47, 143, 176, 0.2);
}

body.rex-theme-dark .yform-cb-persist-status {
    border-color: #3d4a58;
    background: linear-gradient(180deg, #1f2a35 0%, #1a2330 100%);
    color: #a8b8c4;
}

body.rex-theme-dark .yform-cb-persist-status .yform-cb-persist-hint {
    color: #8fa3b3;
}

body.rex-theme-dark .yform-cb-persist-status.is-dirty {
    border-color: #5d4a2f;
    background: linear-gradient(180deg, #3d2d1a 0%, #352714 100%);
}

body.rex-theme-dark .yform-cb-persist-status.is-saving {
    border-color: #2a4570;
    background: linear-gradient(180deg, #1a2a3d 0%, #142340 100%);
}

@media (prefers-color-scheme: dark) {
    body.rex-has-theme:not(.rex-theme-light) .yform-cb-persist-status {
        border-color: #3d4a58;
        background: linear-gradient(180deg, #1f2a35 0%, #1a2330 100%);
        color: #a8b8c4;
    }

    body.rex-has-theme:not(.rex-theme-light) .yform-cb-persist-status .yform-cb-persist-hint {
        color: #8fa3b3;
    }

    body.rex-has-theme:not(.rex-theme-light) .yform-cb-persist-status.is-dirty {
        border-color: #5d4a2f;
        background: linear-gradient(180deg, #3d2d1a 0%, #352714 100%);
    }

    body.rex-has-theme:not(.rex-theme-light) .yform-cb-persist-status.is-saving {
        border-color: #2a4570;
        background: linear-gradient(180deg, #1a2a3d 0%, #142340 100%);
    }
}

@keyframes cbSlFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes cbSlFlash {
    0%   { background-color: inherit; }
    35%  { background-color: #d4f0e2; }
    100% { background-color: inherit; }
}

@keyframes cbSlShake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-4px); }
    40%       { transform: translateX(4px); }
    60%       { transform: translateX(-3px); }
    80%       { transform: translateX(3px); }
}

@keyframes cbSlSpin {
    to { transform: rotate(360deg); }
}

.cb-smart-link-row {
    margin-bottom: 12px;
    border: 1px solid #d7e4ea;
    border-radius: 6px;
    background: linear-gradient(180deg, #f7fbfc 0%, #f2f8f7 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
    animation: cbSlFadeIn 0.2s ease both;
}

.cb-smart-link-row.is-success .cb-smart-link-panel-body {
    animation: cbSlFlash 0.55s ease;
}

.cb-smart-link-row.is-removing {
    animation: cbSlShake 0.3s ease;
}

.cb-smart-link-row:last-child {
    margin-bottom: 0;
}

.cb-smart-link-panel-body {
    padding: 14px;
}

.cb-smart-link-main-row > [class*='col-'] label,
.cb-smart-link-secondary-row > [class*='col-'] label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #3c4a57;
}

.cb-smart-link-select,
.cb-smart-link-input {
    height: 38px;
    border: 1px solid #c8d4dc;
    border-radius: 5px;
    background: #fff;
    box-shadow: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.cb-smart-link-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 34px;
    background-image: linear-gradient(45deg, transparent 50%, #617285 50%), linear-gradient(135deg, #617285 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.cb-smart-link-select:focus,
.cb-smart-link-input:focus {
    border-color: #8eb5c9;
    box-shadow: 0 0 0 3px rgba(89, 150, 185, 0.16);
    outline: none;
}

.cb-smart-link-target-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
}

.cb-smart-link-target-display {
    width: 100%;
    min-width: 0;
}

.cb-smart-link-target-actions {
    display: inline-flex;
    align-items: stretch;
    flex-wrap: nowrap;
    border: 1px solid #c8d4dc;
    border-radius: 5px;
    overflow: hidden;
    background: #fff;
}

.cb-smart-link-btn {
    min-width: 36px;
    height: 38px;
    border: 0;
    border-right: 1px solid #dde7ec;
    border-radius: 0;
    background: #fff;
    color: #516171;
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.14s ease, color 0.14s ease, transform 0.1s ease;
}

.cb-smart-link-btn:active {
    transform: scale(0.88);
    transition-duration: 0.06s;
}

.cb-smart-link-detect.is-spinning .fa {
    animation: cbSlSpin 0.5s linear;
}

.cb-smart-link-target-actions > .cb-smart-link-btn:last-child,
.cb-smart-link-actions > .cb-smart-link-btn:last-child {
    border-right: 0;
}

.cb-smart-link-btn:hover,
.cb-smart-link-btn:focus {
    background: #edf4f7;
    color: #23313f;
}

.cb-smart-link-btn-danger {
    background: #fff4f3;
    color: #c65a4c;
}

.cb-smart-link-btn-danger:hover,
.cb-smart-link-btn-danger:focus {
    background: #fbe0dc;
    color: #a43c30;
}

.cb-smart-link-preview {
    min-height: 20px;
    padding-top: 7px;
    line-height: 1.35;
    color: #6a7a88;
}

.cb-smart-link-secondary-row {
    margin-top: 12px;
}

.cb-smart-link-toolbar {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.cb-smart-link-pdfjs-label {
    margin: 0;
    font-weight: 600;
    color: #4d5d6b;
    white-space: nowrap;
}

.cb-smart-link-pdfjs-label input {
    margin-right: 4px;
}

.cb-smart-link-actions {
    display: inline-flex;
    border: 1px solid #c8d4dc;
    border-radius: 5px;
    overflow: hidden;
    background: #fff;
}

@media (max-width: 991px) {
    .cb-smart-link-target-wrap {
        grid-template-columns: 1fr;
    }

    .cb-smart-link-target-actions {
        width: 100%;
    }

    .cb-smart-link-btn {
        flex: 1 1 auto;
    }

    .cb-smart-link-toolbar {
        justify-content: flex-start;
        margin-top: 10px;
    }
}

.slice-edit-form .btn-slice-cancel {
    margin-left: 5px;
}

@media (max-width: 768px) {
    .slice-edit-form .slice-form-actions-note {
        float: none;
        margin-top: 0;
        margin-bottom: 10px;
    }

    .slice-edit-form .cb-slice-action-group {
        float: none !important;
        display: flex;
        gap: 6px;
        width: 100%;
    }

    .slice-edit-form .cb-slice-action-group .btn {
        flex: 1 1 auto;
        white-space: nowrap;
    }
}

/* Drag&Drop Placeholder */
.slice-placeholder {
    height: 80px;
    background: rgba(60, 141, 188, 0.1);
    border: 2px dashed #3c8dbc;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* Add Slice Dropdown */
.content-builder-add {
    margin-top: 10px;
    text-align: center;
}

.content-builder-add .dropdown-menu {
    width: 100%;
}

.btn-add-slice {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 15px;
    color: #333;
}

.btn-add-slice:hover {
    background: #f5f5f5;
    text-decoration: none;
}

.btn-add-slice i {
    margin-right: 8px;
    color: #3c8dbc;
}

/* Hidden Data Field */
.content-builder-data {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .slice-toolbar {
        position: static;
        display: block;
        border-radius: 4px 4px 0 0;
        text-align: right;
        opacity: 1;
        pointer-events: auto;
        visibility: visible;
        transition: none;
    }
    
    .slice-rendered {
        padding-top: 50px;
    }
}

/* Element-spezifische Styles */

/* Text-Image Element */
.element-text-image {
    overflow: hidden;
}

.element-text-image img {
    max-width: 100%;
    height: auto;
}

/* Accordion Element */
.element-accordion .panel {
    margin-bottom: 5px;
}

.element-accordion .panel-heading {
    cursor: pointer;
    user-select: none;
}

.element-accordion .panel-heading:hover {
    background: #f5f5f5;
}

/* UIkit Anpassungen */
.uk-accordion-title {
    cursor: pointer;
}

/* Empty State */
.content-builder-slices:empty::before {
    content: "Noch keine Elemente vorhanden. Füge unten ein Element hinzu.";
    display: block;
    padding: 40px 20px;
    text-align: center;
    color: #999;
    border: 2px dashed #ddd;
    border-radius: 4px;
    background: #fafafa;
}

/* Repeater */
.repeater-container {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    background: #fff;
}

.repeater-item {
    position: relative;
    /* Rechts genügend Platz für Move-/Delete-Buttons (oben rechts, absolute positioniert) */
    padding: 15px 80px 15px 15px;
    margin-bottom: 10px;
    border: 1px solid #e5e5e5;
    border-radius: 3px;
    background: #fafafa;
}

.repeater-item .btn-remove-repeater {
    position: absolute;
    top: 10px;
    right: 10px;
}

/* Move Buttons für alle Repeater - rechts neben Löschen-Button */  
.repeater-item .move-buttons {
    position: absolute;
    top: 10px;
    right: 45px; /* 35px für btn-remove + 10px Abstand */
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.repeater-item .btn-move {
    opacity: 0.6;
    transition: opacity 0.2s;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 2px;
    padding: 2px 4px;
    font-size: 10px;
    width: 20px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.repeater-item:hover .btn-move {
    opacity: 1;
}

.repeater-item .btn-move:hover {
    background: rgba(0, 0, 0, 0.8);
}

.repeater-item .btn-move:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Move Animation */
.repeater-item {
    transition: all 0.15s ease;
}

/* Slice Form Button Styling – nur direkte Kind-form-group (Save/Cancel-Leiste). */
.slice-form > .form-group:last-child {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.slice-form .btn-group.pull-right {
    float: right;
}

.slice-form .clearfix {
    clear: both;
}

#nested-slice-edit-modal .modal-body {
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}

.slice-form-actions {
    background: #f9f9f9;
}

.slice-form-actions .btn-group.pull-right {
    float: right;
}

#nested-slice-edit-modal .slice-form-actions {
    position: sticky;
    bottom: 0;
    z-index: 3;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

#nested-slice-edit-modal .slice-form-actions .btn-group.pull-right {
    float: none;
}

.btn-add-repeater {
    width: 100%;
    margin-top: 10px;
}

.repeater-item .form-group:last-child {
    margin-bottom: 0;
}

/* Grid View for Repeaters */
.repeater-grid-view {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.repeater-grid-view[data-grid-columns="2"] {
    grid-template-columns: repeat(2, 1fr);
}

.repeater-grid-view[data-grid-columns="4"] {
    grid-template-columns: repeat(4, 1fr);
}

.repeater-grid-view[data-grid-columns="5"] {
    grid-template-columns: repeat(5, 1fr);
}

.repeater-grid-view .repeater-item {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 200px;
}

.repeater-grid-view .repeater-item .btn-remove-repeater {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.repeater-grid-view .repeater-item:hover .btn-remove-repeater {
    opacity: 1;
}

/* Grid View verwendet dieselben Move-Buttons */

.repeater-grid-view .media-preview-enhanced {
    flex: 1;
    min-height: 120px;
}

/* Grid View - Kompakte Form-Groups */
.repeater-grid-view .form-group {
    margin-bottom: 10px;
}

.repeater-grid-view .form-group label {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
}

.repeater-grid-view .form-control {
    font-size: 13px;
    padding: 6px 8px;
}

/* Grid View Responsive */
@media (max-width: 768px) {
    .repeater-grid-view {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .repeater-grid-view {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
}

/* Media Widget */
.media-widget .media-preview {
    margin-top: 10px;
    max-width: 200px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.media-widget .media-preview img {
    width: 100%;
    height: auto;
    display: block;
}

/* Enhanced Media Widget */
.media-widget-enhanced .media-preview-enhanced {
    margin-top: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #f9f9f9;
    max-width: 200px;
}

.media-preview-enhanced .media-item {
    position: relative;
    display: block;
}

/* Bild in kompakter Vorschau-Größe */
.media-preview-enhanced .media-item-image {
    position: relative;
    width: 100%;
    padding: 5px;
}

.media-preview-enhanced .media-item-image img {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 150px;
    object-fit: contain;
    display: block;
    border-radius: 3px;
}

.media-preview-enhanced .media-item-video {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
}

.media-preview-enhanced .media-item-video video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #000;
    cursor: pointer;
    z-index: 1;
}

.media-preview-enhanced .media-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.9);
    font-size: 48px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 10;
}

.media-preview-enhanced .media-item-video:hover .media-overlay {
    color: rgba(255, 255, 255, 1);
    font-size: 54px;
}

.media-preview-enhanced .media-controls {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 4px;
    padding: 5px 10px;
    display: none;
    z-index: 20;
    z-index: 20;
}

.media-preview-enhanced .media-item-video:hover .media-controls {
    display: block;
}

.media-preview-enhanced .media-controls button {
    background: none;
    border: none;
    color: white;
    font-size: 14px;
    margin-right: 10px;
    cursor: pointer;
    padding: 2px 5px;
}

.media-preview-enhanced .media-controls button:hover {
    color: #007bff;
}

/* Video Hover Effects */
.media-preview-enhanced .media-item-video {
    cursor: pointer;
}

.media-preview-enhanced .media-item-video:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.media-preview-enhanced .media-item-video video:hover {
    transform: scale(1.02);
    transition: transform 0.3s ease;
}

/* Play Overlay Animation */
.media-preview-enhanced .media-overlay {
    transition: all 0.2s ease;
}

.media-preview-enhanced .media-item-video:hover .media-overlay {
    transform: translate(-50%, -50%) scale(1.1);
}

.media-preview-enhanced .media-info {
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

.media-preview-enhanced .media-info i {
    margin-right: 5px;
}

/* Video Fallback Styling */
.media-preview-enhanced .video-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #6c757d;
    text-align: center;
    z-index: 5;
}

.media-preview-enhanced .media-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    background: #f5f5f5;
    border: 2px dashed #ddd;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
}

.media-preview-enhanced .media-placeholder:hover {
    border-color: #007bff;
    background: #f8f9fa;
    color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.1);
}

.media-preview-enhanced .media-placeholder i {
    font-size: 48px;
    margin-bottom: 10px;
    display: block;
}

.media-preview-enhanced .media-placeholder p {
    margin: 0;
    font-size: 14px;
}

/* Placeholder Box für Enhanced Widget */
.media-placeholder-box {
    text-align: center;
    padding: 30px 20px;
    color: #999;
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 4px;
    margin-top: 10px;
}

.media-placeholder-box i {
    font-size: 48px;
    margin-bottom: 10px;
    display: block;
    color: #ccc;
}

.media-placeholder-box p {
    margin: 0;
    font-size: 13px;
    color: #999;
}

/* Enhanced Widget - Placeholder verschwindet wenn Bild da ist */
.rex-js-widget-enhanced .rex-js-media-preview:not(:empty) + .media-placeholder-box,
.rex-js-widget-enhanced .rex-js-media-preview[style*="display: block"] + .media-placeholder-box {
    display: none;
}

/* Delete Button für Media Preview */
.media-preview-enhanced .btn-delete-preview {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    font-size: 14px;
}

.media-preview-enhanced .media-item:hover .btn-delete-preview {
    opacity: 1;
}

.media-preview-enhanced .btn-delete-preview:hover {
    background: rgba(220, 53, 69, 1);
    transform: scale(1.1);
}

/* Media Item cursor */
.media-preview-enhanced .media-item {
    cursor: pointer;
    position: relative;
}

.media-preview-enhanced .media-item:hover {
    opacity: 0.95;
}

/* Enhanced Media Widget - Clickable Placeholder/Preview */
.media-enhanced-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.media-enhanced-clickable:hover {
    opacity: 0.9;
}

/* Media Placeholder Box */
.media-placeholder-box {
    padding: 40px 30px;
    border: 2px dashed #d0d0d0;
    border-radius: 4px;
    text-align: center;
    background: #f9f9f9;
    transition: all 0.2s ease;
}

.media-placeholder-box i {
    display: block;
    font-size: 48px;
    color: #aaa;
    margin-bottom: 10px;
}

.media-placeholder-box p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

.media-enhanced-clickable:hover .media-placeholder-box {
    border-color: #0073aa;
    background: #f0f7ff;
}

.media-enhanced-clickable:hover .media-placeholder-box i {
    color: #0073aa;
}

/* Enhanced Media Preview */
.media-enhanced-preview {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
}

.media-enhanced-preview img,
.media-enhanced-preview video {
    display: block;
    max-width: 100%;
    height: auto;
}

.media-enhanced-preview:hover {
    border-color: #0073aa;
}

.media-enhanced-file {
    padding: 20px;
    text-align: center;
}

.media-enhanced-file i {
    display: block;
    font-size: 48px;
    color: #666;
    margin-bottom: 10px;
}

.media-enhanced-file span {
    display: block;
    font-size: 14px;
    color: #333;
    word-break: break-all;
}

/* Content Builder Media Preview - Eigene Implementation */
.content-builder-media-preview {
    margin-top: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 10px;
    background: #fafafa;
}

.content-builder-media-preview:empty {
    display: none;
}

.cb-media-preview-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 200px;
}

/* Kompakter Container für Medien-Vorschau */
.cb-media-preview-item .cb-media-container {
    position: relative;
    width: 100%;
    max-width: 200px;
    height: 120px;
    background: #f5f5f5;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.cb-media-preview-item img,
.cb-media-preview-item video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.cb-media-preview-item.cb-media-file {
    align-items: center;
    padding: 20px;
    text-align: center;
}

.cb-media-preview-item.cb-media-file i {
    font-size: 48px;
    color: #999;
    margin-bottom: 10px;
}

.cb-media-filename {
    font-size: 12px;
    color: #666;
    word-break: break-all;
    padding: 5px;
    background: #fff;
    border-radius: 3px;
}

/* Insert-Between Buttons - Removed */
/*
.content-builder-insert-between {
    margin: 15px 0;
    text-align: center;
}
...
*/

/* =============================================================================
   Radio Image Selection (Visual Layout Picker)
   ============================================================================= */
.radio-image-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.radio-image-item {
    position: relative;
    flex: 0 0 auto;
}

.radio-image-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-image-item label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
    min-width: 80px;
}

.radio-image-item label:hover {
    border-color: #3c8dbc;
    background: #f8f9fa;
}

.radio-image-item.active label,
.radio-image-item input[type="radio"]:checked + label {
    border-color: #3c8dbc;
    background: #e8f4fc;
    box-shadow: 0 0 0 2px rgba(60, 141, 188, 0.2);
}

.radio-image-item img {
    width: 60px;
    height: 45px;
    object-fit: contain;
    margin-bottom: 5px;
}

.radio-image-label {
    font-size: 11px;
    color: #666;
    text-align: center;
    line-height: 1.2;
}

.radio-image-item.active .radio-image-label,
.radio-image-item input[type="radio"]:checked + label .radio-image-label {
    color: #3c8dbc;
    font-weight: 600;
}

/* =============================================================================
   COLOR SWATCHES - Visuelle Farbauswahl
   ============================================================================= */

.color-swatches-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.color-swatch-item {
    position: relative;
}

.color-swatch-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.color-swatch-item label {
    display: block;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    border: 2px solid transparent;
    transition: all 0.15s ease;
}

.color-swatch-item label:hover {
    border-color: #aaa;
}

.color-swatch-item.active label,
.color-swatch-item input[type="radio"]:checked + label {
    border-color: #3c8dbc;
    box-shadow: 0 0 0 1px #3c8dbc;
}

.color-swatch {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 3px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

/* Fix für Bootstrap Modal - verhindert Springen */
.modal-open {
    padding-right: 0 !important;
}

body.modal-open {
    overflow: visible !important;
}

/* Help-Modal: stabile Lesbarkeit in Modul- und YForm-Renderer */
.ycb-help-modal-content {
    display: block;
    max-width: none;
    min-width: 0;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    column-count: 1;
    writing-mode: horizontal-tb;
    line-height: 1.5;
    text-align: left;
}

.ycb-help-modal-content p,
.ycb-help-modal-content li,
.ycb-help-modal-content h1,
.ycb-help-modal-content h2,
.ycb-help-modal-content h3,
.ycb-help-modal-content h4,
.ycb-help-modal-content td,
.ycb-help-modal-content th {
    max-width: none;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    text-align: left;
}

/* Columns backend: keep nested grid strictly inside editor width */
.content-builder-columns-row {
    width: 100%;
    max-width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box;
}

.content-builder-columns-row > .content-builder-column {
    min-width: 0;
    box-sizing: border-box;
}

.content-builder-columns-row > .content-builder-column > .content-builder-column-slices {
    max-width: 100%;
    overflow: visible;
}

.content-builder-backend-container {
    width: 100%;
    max-width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box;
}

/* Hide column add slice button when elements are present inside the column slices container */
.content-builder-column-slices:has(.content-builder-slice) + .column-add-slice {
    display: none !important;
}

/* Position toolbars of nested slices inside columns on the left to avoid overlapping parent toolbars */
.content-builder-column-slices .content-builder-slice > .slice-toolbar {
    left: -1px;
    right: auto;
}

/* Nested toolbar opens on the left side of the slice -> dropdown must open to the right */
.content-builder-column-slices .content-builder-slice > .slice-toolbar .dropdown-menu,
.content-builder-column-slices .content-builder-slice > .slice-toolbar .dropdown-menu.pull-right {
    left: 0;
    right: auto;
}

/* Paste button blue highlight */
.dropdown-menu li.paste-slice-item a.btn-paste-slice {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 15px;
    background-color: #3c8dbc !important;
    color: #fff !important;
    font-weight: bold;
    border-radius: 0;
    transition: background-color 0.15s ease;
}

.dropdown-menu li.paste-slice-item a.btn-paste-slice:hover,
.dropdown-menu li.paste-slice-item a.btn-paste-slice:focus {
    background-color: #2b6688 !important;
    color: #fff !important;
    text-decoration: none;
}

.dropdown-menu li.paste-slice-item a.btn-paste-slice i {
    color: #fff !important;
    margin-right: 8px;
}

/* Element-Suche Styling */
.dropdown-menu li.yform-cb-search-item {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 0;
    margin: 0;
    list-style: none;
}

.yform-cb-search-item .yform-cb-search-wrapper {
    padding: 3px 8px;
}

.dropdown-menu li.yform-cb-search-item:first-child {
    border-radius: 4px 4px 0 0;
}

.yform-cb-element-search-input {
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 6px 10px;
    font-size: 13px;
}

.yform-cb-element-search-input:focus {
    outline: none;
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1);
    background-color: #fff;
}
