/* Background Editor (Canva-подобен layer редактор) - bg-editor.js */
.bge-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    background: #1f2430;
    color: #e8eaf0;
    font-family: inherit;
}

.bge-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    background: #171b24;
    border-bottom: 1px solid #2b3340;
    flex: 0 0 auto;
}
.bge-title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.bge-title i { color: #d79a52; }
.bge-format {
    font-size: 12px; font-weight: 500; color: #9aa4b5;
    background: #232a37; padding: 3px 10px; border-radius: 20px; margin-left: 6px;
}
.bge-top-actions { display: flex; gap: 10px; align-items: center; }
.bge-icon-btn {
    background: #232a37; border: 1px solid #313a49; color: #c3cad6;
    width: 38px; height: 38px; border-radius: 9px; cursor: pointer;
    font-size: 15px; display: inline-flex; align-items: center; justify-content: center;
    transition: background .12s, color .12s, border-color .12s;
}
.bge-icon-btn:hover { background: #333d4e; color: #fff; border-color: #d79a52; }
.bge-icon-btn:active { transform: translateY(1px); }
.bge-save-short, .bge-close-icon { display: none !important; }
.bge-title { min-width: 0; overflow: hidden; }
.bge-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bge-workspace { flex: 1 1 auto; display: flex; min-height: 0; }

.bge-sidebar {
    flex: 0 0 250px;
    background: #1b2029;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.bge-sidebar.bge-left { border-right: 1px solid #2b3340; }
.bge-sidebar.bge-right { border-left: 1px solid #2b3340; }

.bge-panel { background: #232a37; border-radius: 12px; padding: 12px; }
.bge-panel h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #9aa4b5; }
.bge-empty { font-size: 13px; color: #7d8798; margin: 4px 0 0; }

.bge-add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.bge-add-btn {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 6px; border-radius: 10px; border: 1px solid #313a49;
    background: #2a3241; color: #e8eaf0; cursor: pointer; font-size: 12px;
    transition: background .15s, border-color .15s;
}
.bge-add-btn:hover:not(:disabled) { background: #333d4e; border-color: #d79a52; }
.bge-add-btn:disabled { opacity: .4; cursor: not-allowed; }
.bge-add-btn i { font-size: 18px; color: #d79a52; }

.bge-el-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bge-el-chip {
    padding: 0; border: 1px solid #313a49; border-radius: 8px; overflow: hidden;
    cursor: pointer; aspect-ratio: 1; background: #2a3241;
}
.bge-el-chip:hover { border-color: #d79a52; }
.bge-el-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }

.bge-stage-area {
    position: relative;
    flex: 1 1 auto; min-width: 0; display: grid; place-content: center;
    padding: 24px; overflow: auto;
    background:
        linear-gradient(45deg, #262c38 25%, transparent 25%) -10px 0/20px 20px,
        linear-gradient(-45deg, #262c38 25%, transparent 25%) -10px 0/20px 20px,
        linear-gradient(45deg, transparent 75%, #262c38 75%) 0 0/20px 20px,
        linear-gradient(-45deg, transparent 75%, #262c38 75%) 0 0/20px 20px,
        #212734;
}
.bge-stage-wrap { margin: auto; }
.bge-stage { box-shadow: 0 10px 40px rgba(0,0,0,.45); background: #fff; touch-action: none; }

/* zoom toolbar (фиксиран, не скролва с листа) */
.bge-zoombar {
    position: fixed; bottom: 16px; right: 270px; z-index: 30;
    display: flex; align-items: center; gap: 4px;
    background: #171b24; border: 1px solid #2b3340; border-radius: 10px; padding: 4px;
}
.bge-zoombar button {
    background: none; border: none; color: #c3cad6; cursor: pointer;
    width: 32px; height: 32px; border-radius: 7px; font-size: 13px;
}
.bge-zoombar button:hover { background: #2a3241; color: #fff; }
.bge-zoombar span { color: #9aa4b5; font-size: 12px; min-width: 42px; text-align: center; }

/* mobile bottom bar + bottom-sheet close (hidden on desktop) */
.bge-sheet-close, .bge-mobile-bar { display: none; }

.bge-layer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bge-layer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px; border-radius: 8px; background: #2a3241; cursor: pointer;
    border: 1px solid transparent; transition: background .12s, border-color .12s;
}
.bge-layer:hover { background: #333d4e; }
.bge-layer.active { border-color: #d79a52; background: #333d4e; }
.bge-layer-name { font-size: 13px; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bge-layer-name i { color: #9aa4b5; width: 14px; text-align: center; }
.bge-layer-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.bge-layer-actions button {
    background: none; border: none; color: #9aa4b5; cursor: pointer;
    padding: 4px; border-radius: 5px; font-size: 12px; line-height: 1;
}
.bge-layer-actions button:hover { background: #3d4859; color: #fff; }

.bge-prop { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #c3cad6; margin-bottom: 10px; }
.bge-prop input[type=range] { width: 100%; accent-color: #d79a52; }
.bge-prop select, .bge-prop input[type=number] {
    background: #2a3241; border: 1px solid #313a49; color: #e8eaf0;
    border-radius: 7px; padding: 6px 8px; font-size: 13px;
}
.bge-prop input[type=color] { width: 100%; height: 30px; border: 1px solid #313a49; border-radius: 7px; background: #2a3241; cursor: pointer; }
.bge-prop-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.bge-fullbtn { width: 100%; margin-bottom: 10px; }
.bge-prop-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 10px; }
.bge-prop-row .bge-prop { flex: 1; margin-bottom: 0; }
.bge-align { justify-content: flex-start; }
.bge-mini {
    background: #2a3241; border: 1px solid #313a49; color: #c3cad6; cursor: pointer;
    min-width: 34px; height: 34px; border-radius: 7px; font-size: 13px;
    display: inline-flex; align-items: center; justify-content: center;
}
.bge-mini:hover { background: #333d4e; color: #fff; }
.bge-mini.active { border-color: #d79a52; color: #d79a52; background: #2f2a22; }
.bge-check { flex-direction: row; align-items: center; gap: 8px; }
.bge-check input { accent-color: #d79a52; width: 16px; height: 16px; }
.bge-sep { border: none; border-top: 1px solid #2b3340; margin: 12px 0; }

/* Мои проекти модал */
.bge-modal-overlay {
    position: fixed; inset: 0; z-index: 10010;
    background: rgba(10,13,18,.6); display: flex; align-items: center; justify-content: center; padding: 20px;
}
.bge-modal {
    width: 100%; max-width: 520px; max-height: 80vh; overflow: hidden;
    background: #1b2029; border: 1px solid #2b3340; border-radius: 14px;
    display: flex; flex-direction: column;
}
.bge-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid #2b3340;
}
.bge-modal-head h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.bge-modal-head i { color: #d79a52; }
.bge-modal-body { padding: 12px 16px; overflow-y: auto; }
.bge-project-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px; border-radius: 9px; background: #232a37; margin-bottom: 8px;
}
.bge-project-name { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.bge-project-name i { color: #9aa4b5; }
.bge-project-name small { color: #7d8798; }
.bge-project-actions { display: flex; gap: 6px; flex: 0 0 auto; }

/* ---------- мобилен / тъч layout ---------- */
@media (max-width: 820px) {
    .bge-topbar { padding: 8px 10px; gap: 8px; }
    .bge-title { font-size: 15px; flex: 1 1 auto; }
    .bge-title-text { display: none; }
    .bge-format { display: none; }
    .bge-hide-mobile { display: none !important; }
    .bge-top-actions { gap: 8px; flex: 0 0 auto; }
    .bge-top-actions .btn { padding: 10px 14px; }
    .bge-close-btn .bge-btn-label { display: none !important; }
    .bge-close-icon { display: inline !important; }
    #bge-save-btn .bge-btn-label { display: none !important; }
    .bge-save-short { display: inline !important; }

    .bge-workspace { display: block; height: 100%; }
    .bge-stage-area { padding: 12px; height: 100%; }

    /* страничните панели стават bottom-sheets */
    .bge-sidebar {
        position: fixed; left: 0; right: 0; bottom: 0; top: auto;
        flex: none; width: auto; max-height: 62vh; z-index: 20;
        border: none; border-top: 1px solid #2b3340;
        border-radius: 16px 16px 0 0;
        transform: translateY(105%); transition: transform .25s ease;
        padding-bottom: 78px; /* място за долната лента */
        box-shadow: 0 -10px 40px rgba(0,0,0,.5);
    }
    .bge-sidebar.open { transform: translateY(0); }
    .bge-sheet-close {
        display: flex; align-items: center; justify-content: center;
        width: 44px; height: 30px; margin: 2px auto 8px; border-radius: 8px;
        background: #2a3241; border: 1px solid #313a49; color: #c3cad6; cursor: pointer;
    }

    /* долна лента с основните действия */
    .bge-mobile-bar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
        background: #171b24; border-top: 1px solid #2b3340;
        padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    }
    .bge-mobile-bar button {
        flex: 1; background: none; border: none; color: #c3cad6; cursor: pointer;
        display: flex; flex-direction: column; align-items: center; gap: 4px;
        font-size: 11px; padding: 4px;
    }
    .bge-mobile-bar button i { font-size: 18px; color: #d79a52; }
    .bge-mobile-bar button:active { color: #fff; }

    /* по-големи тъч таргети */
    .bge-add-btn { padding: 14px 6px; }
    .bge-add-btn i { font-size: 20px; }
    .bge-layer { padding: 12px 10px; }
    .bge-layer-actions button { padding: 8px; font-size: 14px; }
    .bge-mini { min-width: 40px; height: 40px; }
    .bge-zoombar { bottom: 84px; right: 12px; }
}
