/* ==========================================================================
   Frontend-редактор: панель, модалки, подсветка редактируемых элементов
   ========================================================================== */

body.editor-active {
    /* --ed-panel-h задаётся редактором по фактической высоте панели (см. editorApplyPanelOffset) */
    padding-top: var(--ed-panel-h, 58px);
}

body.editor-active #header {
    top: var(--ed-panel-h, 58px);
}

/* --- Панель управления (фиксированная, сверху) -------------------------- */

#editor-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 14px;
    background: #12121a;
    color: #fff;
    font-family: 'Onest', system-ui, sans-serif;
    font-size: 13px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

#editor-panel button {
    font: inherit;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

#editor-panel button:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
}

#editor-panel .ed-panel__brand {
    font-weight: 600;
    margin-right: 4px;
}

#editor-panel .ed-panel__quick {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

#editor-panel .ed-panel__tools {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}

#editor-panel .ed-btn--exit {
    background: #b3261e;
    border-color: #b3261e;
}

#editor-panel .ed-btn--exit:hover {
    background: #c93028;
}

.ed-hidden-file {
    display: none;
}

/* --- Подсветка редактируемых элементов ----------------------------------- */

body.editor-active [data-editable="text"],
body.editor-active [data-editable="image"] {
    cursor: pointer;
}

body.editor-active [data-editable="text"]:hover {
    outline: 2px dashed #ffd700;
    outline-offset: 3px;
}

body.editor-active [data-editable="image"]:hover {
    outline: 2px dashed #4caf50;
    outline-offset: 3px;
}

body.editor-active [data-editable="text"]:focus-visible,
body.editor-active [data-editable="image"]:focus-visible {
    outline: 3px solid #2196f3;
    outline-offset: 3px;
}

/* --- Модальные окна редактора ------------------------------------------- */

.ed-modal {
    position: fixed;
    inset: 0;
    z-index: 5100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.ed-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 16, 0.62);
    backdrop-filter: blur(4px);
}

.ed-modal__box {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    background: #fdfdfb;
    color: #1a1a1a;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    font-family: 'Onest', system-ui, sans-serif;
}

.ed-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid #e8e4dc;
    background: #fff;
    flex-shrink: 0;
}

.ed-modal__title {
    font-weight: 600;
    font-size: 16px;
}

.ed-modal__id {
    font-size: 12px;
    font-weight: 400;
    color: #8a8577;
    margin-left: 6px;
    word-break: break-all;
}

.ed-modal__close {
    font: inherit;
    font-size: 20px;
    line-height: 1;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    border-radius: 8px;
}

.ed-modal__close:hover {
    background: #f0ede6;
    color: #1a1a1a;
}

.ed-modal__body {
    padding: 16px;
    overflow-y: auto;
}

/* --- Поля и кнопки форм -------------------------------------------------- */

.ed-field {
    margin-bottom: 12px;
}

.ed-field__label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #6b665a;
    margin-bottom: 5px;
}

.ed-input {
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    font-size: 14px;
    padding: 9px 11px;
    border: 1px solid #d8d2c6;
    border-radius: 9px;
    background: #fff;
    color: #1a1a1a;
}

.ed-input:focus {
    outline: none;
    border-color: #b8975a;
    box-shadow: 0 0 0 3px rgba(184, 151, 90, 0.2);
}

.ed-textarea {
    resize: vertical;
    min-height: 80px;
}

.ed-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 0;
}

.ed-check input {
    width: 16px;
    height: 16px;
    accent-color: #b8975a;
}

.ed-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ed-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
    flex-wrap: wrap;
}

.ed-btn {
    font: inherit;
    font-size: 14px;
    padding: 9px 14px;
    border-radius: 9px;
    border: 1px solid #d8d2c6;
    background: #fff;
    color: #1a1a1a;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.ed-btn:hover {
    background: #f4f1ea;
}

.ed-btn--primary {
    background: #b8975a;
    border-color: #b8975a;
    color: #fff;
    font-weight: 600;
}

.ed-btn--primary:hover {
    background: #a7864d;
}

.ed-btn--block {
    display: block;
    width: 100%;
    margin-bottom: 12px;
}

.ed-btn--ghost {
    background: transparent;
    border-color: transparent;
    color: #8a8577;
}

.ed-btn--ghost:hover {
    background: #f0ede6;
}

.ed-btn--sm {
    font-size: 13px;
    padding: 7px 12px;
}

.ed-btn--restore {
    font-size: 13px;
    padding: 6px 10px;
    flex-shrink: 0;
    color: #b8975a;
    border-color: #e3d5b9;
    margin-left: auto;
}

.ed-btn--restore:hover {
    background: #faf5ea;
}

.ed-btn:disabled,
.ed-btn[disabled] {
    opacity: 0.55;
    cursor: wait;
}

.ed-urlrow {
    display: flex;
    gap: 8px;
}

/* --- Списки элементов ---------------------------------------------------- */

.ed-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ed-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    font: inherit;
    font-size: 14px;
    padding: 9px 11px;
    border: 1px solid #e3dfd4;
    border-radius: 10px;
    background: #fff;
    color: #1a1a1a;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ed-item:hover {
    border-color: #b8975a;
    box-shadow: 0 2px 8px rgba(184, 151, 90, 0.18);
}

.ed-item--row {
    cursor: default;
}

.ed-item--row.is-drag {
    opacity: 0.45;
    border-style: dashed;
}

.ed-item__id {
    font-family: 'Space Grotesk', monospace;
    font-size: 11px;
    color: #8a8577;
    background: #f4f1ea;
    padding: 2px 7px;
    border-radius: 6px;
    flex-shrink: 0;
}

.ed-item__preview {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #55503f;
}

.ed-item__title {
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ed-item__sub {
    font-size: 12px;
    color: #9a9589;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ed-item__status {
    font-size: 11px;
    color: #2e7d32;
    background: #e8f5e9;
    padding: 2px 8px;
    border-radius: 20px;
    flex-shrink: 0;
}

.ed-item__status.is-off {
    color: #8a8577;
    background: #efede7;
}

.ed-item__thumb {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: #f0ede6;
}

.ed-item__grip {
    color: #b4aea0;
    cursor: grab;
    font-size: 16px;
    flex-shrink: 0;
}

.ed-item__actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

.ed-mini {
    font: inherit;
    font-size: 13px;
    width: 28px;
    height: 28px;
    border: 1px solid #e0dcd0;
    background: #fff;
    border-radius: 7px;
    cursor: pointer;
    color: #55503f;
}

.ed-mini:hover {
    border-color: #b8975a;
    color: #b8975a;
}

.ed-mini--danger:hover {
    border-color: #b3261e;
    color: #b3261e;
}

.ed-note {
    margin-top: 12px;
    font-size: 12px;
    color: #8a8577;
    line-height: 1.5;
}

.ed-empty {
    padding: 18px 12px;
    text-align: center;
    color: #9a9589;
    font-size: 14px;
    border: 1px dashed #d8d2c6;
    border-radius: 10px;
}

/* --- Предпросмотр изображения ------------------------------------------- */

.ed-imgpreview {
    margin-bottom: 12px;
    border: 1px solid #e3dfd4;
    border-radius: 10px;
    overflow: hidden;
    background: #f7f5f0;
    text-align: center;
    max-height: 220px;
}

.ed-imgpreview img {
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
    display: inline-block;
}

.ed-file {
    font-size: 13px;
    color: #55503f;
}

/* --- Чистка картинок ------------------------------------------------------ */

.ed-clean__tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #efece3;
    color: #6f6b63;
    font-size: 11px;
    white-space: nowrap;
}

.ed-clean__tag--cur {
    background: #e4f0df;
    color: #3d7a34;
}

.ed-clean__tag--free {
    background: #f7e4e0;
    color: #a04b3a;
}

/* --- Тосты ---------------------------------------------------------------- */

#editor-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(20px);
    z-index: 6000;
    background: #1c1c26;
    color: #fff;
    padding: 11px 18px;
    border-radius: 10px;
    font-family: 'Onest', system-ui, sans-serif;
    font-size: 14px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
    max-width: 86vw;
}

#editor-toast.is-show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

#editor-toast.is-error {
    background: #b3261e;
}

/* --- Мобильные ------------------------------------------------------------ */

@media (max-width: 768px) {
    #editor-panel {
        padding: 6px 10px;
        gap: 6px;
        font-size: 12px;
    }

    #editor-panel .ed-panel__tools {
        margin-left: 0;
    }

    #editor-panel .ed-panel__brand {
        width: 100%;
    }

    .ed-row {
        grid-template-columns: 1fr;
    }
}

/* Подсказки: что кликабельно в режиме редактирования */
body.editor-active [data-editable],
body.editor-active [data-ed-path],
body.editor-active [data-editor-img] {
    outline: 2px dashed rgba(184,151,90,.45);
    outline-offset: 2px;
    cursor: pointer;
    transition: outline-color .15s ease;
}
body.editor-active [data-editable]:hover,
body.editor-active [data-ed-path]:hover,
body.editor-active [data-editor-img]:hover {
    outline-color: #B8975A;
    outline-style: solid;
}
body.editor-active [data-editor-img] {
    position: relative;
}

/* --- Конструктор услуги: иерархия «раздел → позиция», «мастер» ----------- */

.ed-price-sec {
    border: 1px solid #E5DFD3;
    border-radius: 10px;
    padding: 10px;
    margin: 10px 0;
    background: #FAF7F0;
}

.ed-price-sec__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.ed-price-sec__head--tag {
    margin-bottom: 6px;
}

.ed-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #6B5B3F;
    background: #EDE4D2;
    border: 1px solid #DCCBA9;
    border-radius: 6px;
    padding: 2px 8px;
}

.ed-tag--item {
    color: #7A5A3A;
    background: #F5EDE0;
    border-color: #E4D4B8;
}

.ed-price-items {
    border-top: 1px dashed #E0D6C2;
    padding-top: 8px;
    display: grid;
    gap: 8px;
}

.ed-price-item {
    border: 1px solid #EADFCA;
    border-radius: 8px;
    padding: 8px;
    background: #FFFDF8;
}

.ed-price-item__row {
    display: grid;
    grid-template-columns: 1fr 1fr 130px;
    gap: 6px;
}

.ed-master-row {
    border: 1px solid #E5DFD3;
    border-radius: 10px;
    padding: 10px;
    margin: 10px 0;
    background: #FAF7F0;
    display: grid;
    gap: 6px;
}

.ed-master-row .ed-input {
    width: 100%;
}

@media (max-width: 768px) {
    .ed-price-item__row {
        grid-template-columns: 1fr;
    }
}

/* Индикатор непубликованных правок на кнопке 💾 */
.ed-btn.is-dirty { position: relative; }
.ed-btn.is-dirty::after {
    content: '';
    position: absolute;
    top: -5px;
    right: -5px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #d9534f;
    box-shadow: 0 0 0 2px #fff;
}

/* --- Портфолио: мультивыбор тегов --------------------------------------- */

.ed-tags .msel__badges {
    margin-bottom: 4px;
}

.ed-tags__row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ed-tags__row .ed-input {
    flex: 1;
    min-width: 0;
}

.ed-tags__picker {
    margin-top: 8px;
    padding: 8px;
    border: 1px solid #e3dfd4;
    border-radius: 10px;
    background: #fff;
}

.ed-empty--sm {
    padding: 12px;
    font-size: 13px;
}

/* --- Брендинг и favicon -------------------------------------------------- */

.ed-divider {
    border: none;
    border-top: 1px solid #e3dfd4;
    margin: 16px 0;
}

.ed-brand-preview {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 10px 12px;
    background: #f7f5f0;
    border-radius: 10px;
    margin-bottom: 4px;
}

.ed-brand-preview__label {
    font-size: 12px;
    color: #6b665a;
}

.ed-brand-preview__name {
    font-family: 'Space Grotesk', 'Onest', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
}

.ed-brand-preview__name span {
    color: #b8975a;
}

.ed-favicon-gen {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.ed-favicon-preview {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    border: 1px solid #d8d2c6;
    flex-shrink: 0;
    object-fit: cover;
}

.ed-favicon-gen__fields {
    flex: 1;
    min-width: 200px;
}

.ed-input--color {
    height: 42px;
    padding: 4px 6px;
    cursor: pointer;
}

.ed-input--letter {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
}

.ed-palette-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    margin-bottom: 4px;
}

.ed-palette-swatch {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(26, 26, 26, 0.12);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.ed-palette-swatch--line {
    border-color: #d8d2c6;
}
