/* ============================================================
   obsStudio.css — OBS-оболочка «Bratva Studio»
   Тёмная плоская тема в духе OBS; ретро-стиль остаётся внутри виджетов
   ============================================================ */

#obs-shell {
    position: fixed;
    inset: 0;
    z-index: 99995;
    display: grid;
    grid-template-rows: 34px 1fr;
    grid-template-columns: 250px 1fr 300px;
    grid-template-areas:
        "tb tb tb"
        "left center right";
    background: #171717;
    color: #e0e0e0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 13px;
}

/* ---------- Заголовок ---------- */
#obs-shell .obs-titlebar {
    grid-area: tb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    background: #1e1e1e;
    border-bottom: 1px solid #2c2c2c;
    -webkit-user-select: none;
    user-select: none;
}

#obs-shell .obs-title {
    color: #bbb;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.4px;
}

#obs-shell .obs-close {
    background: #333;
    color: #ddd;
    border: none;
    padding: 3px 10px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
#obs-shell .obs-close:hover { background: #d0342c; color: #fff; }

#obs-shell .obs-title-right {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
}
#obs-shell .obs-btn-canvas {
    background: #333;
    color: #d0d0d0;
    border: none;
    padding: 3px 10px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.2;
    border-radius: 2px;
    font-family: inherit;
}
#obs-shell .obs-btn-canvas:hover { background: #137f96; color: #fff; }

/* Кнопка «🎮 Управление» — окно виджета «Настройка управления» для правки */
#obs-shell .obs-btn-ctr {
    background: #3a2c00;
    color: #ffcc00;
    border: 1px solid #6b5300;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.2;
    border-radius: 2px;
    font-family: inherit;
}
#obs-shell .obs-btn-ctr:hover:not(:disabled) { background: #5a4400; color: #ffe066; }
#obs-shell .obs-btn-ctr:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Селектор страниц (переключение лейаутов) ---------- */
#obs-shell .obs-page-label {
    color: #bbb;
    font-size: 13px;
    margin-right: -2px;
}
#obs-shell .obs-page-select {
    background: #2a2a2a;
    color: #e8e8e8;
    border: 1px solid #3a3a3a;
    border-radius: 2px;
    padding: 2px 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    max-width: 170px;
    outline: none;
}
#obs-shell .obs-page-select:hover { border-color: #137f96; }
#obs-shell .obs-page-select:disabled { opacity: 0.6; cursor: wait; }
#obs-shell .obs-btn-open-page {
    background: #333;
    color: #d0d0d0;
    border: none;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.2;
    border-radius: 2px;
    font-family: inherit;
}
#obs-shell .obs-btn-open-page:hover { background: #137f96; color: #fff; }

/* ---------- Меню «Холст» (размер полотна) ---------- */
#obs-canvas-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 50;
    width: 250px;
    background: #242424;
    border: 1px solid #3a3a3a;
    border-radius: 3px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
    padding: 10px;
    box-sizing: border-box;
}
#obs-canvas-menu .obs-canvas-preset { margin-bottom: 8px; }
#obs-canvas-menu .obs-canvas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 8px;
}
#obs-canvas-menu .obs-prop-input { padding: 4px 6px; }
#obs-canvas-menu .obs-canvas-apply { width: 100%; }
#obs-canvas-menu .obs-canvas-hint {
    font-size: 11px;
    color: #6a6a6a;
    margin-top: 8px;
    line-height: 1.45;
}

/* ---------- Кнопка «🎨 Тема» + панель темы, встроенная в студию ---------- */
#obs-shell .obs-btn-theme {
    background: #3a1a3a;
    color: #ff9ff3;
    border: 1px solid #6b2d6b;
    padding: 3px 10px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.2;
    border-radius: 2px;
    font-family: inherit;
}
#obs-shell .obs-btn-theme:hover { background: #5a2a5a; color: #fff; }
#obs-shell .obs-btn-theme.obs-theme-active { background: #ff00ff; color: #12001a; border-color: #ff7fff; }

/* Панель темы (ThemeCustomizer в режиме --studio). Позицию задаёт JS:
   absolute внутри #obs-shell — панель не участвует в grid-раскладке. */
#obs-shell .theme-customizer-panel--studio {
    border-radius: 0;
    scrollbar-width: thin;
}
#obs-shell .theme-customizer-panel--studio::-webkit-scrollbar { width: 10px; }
#obs-shell .theme-customizer-panel--studio::-webkit-scrollbar-track { background: #0d0116; }
#obs-shell .theme-customizer-panel--studio::-webkit-scrollbar-thumb {
    background: #4a2a5a;
    border-radius: 5px;
}
#obs-shell .theme-customizer-panel--studio::-webkit-scrollbar-thumb:hover { background: #ff00ff; }

/* Медиа-редактор фона в меню «Холст» не должен «распирать» попап */
#obs-canvas-menu input[type="text"],
#obs-canvas-menu input[type="url"] { max-width: 100%; box-sizing: border-box; }
#obs-canvas-menu .obs-canvas-apply + .obs-canvas-apply { margin-top: 6px; }

/* ---------- Колонки ---------- */
#obs-left {
    grid-area: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
    min-height: 0;
    background: #171717;
}

#obs-center {
    grid-area: center;
    min-width: 0;
    min-height: 0;
    display: flex;
    position: relative;
}

#obs-right {
    grid-area: right;
    padding: 4px 4px 4px 0;
    min-height: 0;
}

/* ---------- Панели ---------- */
#obs-shell .obs-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #1e1e1e;
    border: 1px solid #2c2c2c;
    border-radius: 3px;
    overflow: hidden;
}

#obs-scenes-panel { flex: 0 0 45%; }
#obs-sources-panel { flex: 1 1 auto; }

.obs-props-panel {
    height: 100%;
}

#obs-shell .obs-panel-header {
    background: #2a2a2a;
    color: #9aa0a6;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 5px 10px;
    border-bottom: 1px solid #2c2c2c;
    flex-shrink: 0;
}

#obs-shell .obs-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 3px;
}

/* ---------- Тулбары ---------- */
#obs-shell .obs-toolbar {
    display: flex;
    gap: 2px;
    padding: 4px 6px;
    border-top: 1px solid #2c2c2c;
    background: #202020;
    flex-shrink: 0;
    position: relative;
}

#obs-shell .obs-btn {
    background: #333;
    color: #d0d0d0;
    border: none;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.2;
    border-radius: 2px;
    font-family: inherit;
}
#obs-shell .obs-btn:hover { background: #454545; color: #fff; }
#obs-shell .obs-btn-add { background: #137f96; color: #fff; }
#obs-shell .obs-btn-add:hover { background: #1a9cb8; }
#obs-shell .obs-btn-danger { background: #5c2723; color: #ffb0a8; }
#obs-shell .obs-btn-danger:hover { background: #d0342c; color: #fff; }

/* ---------- Сцена: файлы (сохранить / загрузить) ---------- */
#obs-shell .obs-toolbar-files {
    padding: 3px 6px;
    flex-wrap: wrap;
}
#obs-shell .obs-toolbar-files .obs-btn {
    flex: 1 1 auto;
    padding: 3px 4px;
    font-size: 11px;
    white-space: nowrap;
}
#obs-shell .obs-scene-status {
    flex-shrink: 0;
    min-height: 15px;
    padding: 3px 8px;
    font-size: 11px;
    line-height: 1.35;
    color: #7ddb9b;
    background: #17201a;
    border-top: 1px solid #2c2c2c;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#obs-shell .obs-scene-status.error {
    color: #ffb0a8;
    background: #2a1c1c;
}

/* ---------- Сцены ---------- */
#obs-shell .obs-scene-row {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    color: #ccc;
    border-left: 2px solid transparent;
    border-radius: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#obs-shell .obs-scene-row:hover { background: #2a2a2a; color: #fff; }
#obs-shell .obs-scene-row.active {
    background: #26343a;
    border-left-color: #137f96;
    color: #fff;
}

/* ---------- Источники ---------- */
#obs-shell .obs-source-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    cursor: pointer;
    font-size: 13px;
    color: #ccc;
    border-left: 2px solid transparent;
    border-radius: 2px;
}
#obs-shell .obs-source-row:hover { background: #2a2a2a; }
#obs-shell .obs-source-row.selected { background: #26343a; border-left-color: #137f96; }
#obs-shell .obs-source-row.hidden .obs-source-name { color: #6a6a6a; font-style: italic; }

#obs-shell .obs-source-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Вложенные источники (внутри контейнера) — отступ как дерево */
#obs-shell .obs-source-row.obs-source-nested {
    padding-left: 20px;
}
#obs-shell .obs-source-row.obs-source-nested .obs-source-name {
    color: #a8c6c0;
    font-size: 12px;
}

#obs-shell .obs-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 13px;
    opacity: 0.75;
    line-height: 1;
}
#obs-shell .obs-icon-btn:hover { opacity: 1; }
#obs-shell .obs-eye.off { opacity: 0.3; }

/* ---------- Меню добавления источника ---------- */
#obs-source-menu {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 6px;
    z-index: 20;
    background: #242424;
    border: 1px solid #3a3a3a;
    border-radius: 3px;
    max-height: 280px;
    overflow-y: auto;
    min-width: 210px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
    padding: 4px;
}
#obs-source-menu .obs-source-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: #d0d0d0;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    border-radius: 2px;
    white-space: nowrap;
}
#obs-source-menu .obs-source-menu-item:hover { background: #137f96; color: #fff; }


/* ---------- Превью ---------- */
#obs-preview {
    position: relative;
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    /* auto — превью скроллится, когда холст больше области (например «страница» 1920×3000) */
    overflow: auto;
    /* резервируем место под скроллбар, чтобы его появление/исчезновение не сдвигало лэйаут */
    scrollbar-gutter: stable;
    /* Тот же фон, что у темы/холста — чтобы вокруг сцены не было «рамки» из шашечек */
    background: var(--dashboard-bg, #0a020f);
    scrollbar-width: thin;
    scrollbar-color: #3a3a3a #141414;
}
#obs-preview::-webkit-scrollbar { width: 12px; height: 12px; }
#obs-preview::-webkit-scrollbar-track { background: #141414; }
#obs-preview::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 6px;
    border: 2px solid #141414;
}
#obs-preview::-webkit-scrollbar-thumb:hover { background: #137f96; }
#obs-preview::-webkit-scrollbar-corner { background: #141414; }

#obs-stage {
    position: relative;
    width: 1920px;
    height: 1080px;
    flex: 0 0 auto;
    /* margin:auto центрирует холст, когда он меньше превью, и не обрезает его,
       когда больше (тогда появляется скролл превью) */
    margin: auto;
    background: transparent;
}

#obs-center .obs-preview-label {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 5;
    font-size: 11px;
    color: #8a8a8a;
    background: rgba(0,0,0,0.55);
    padding: 3px 9px;
    border-radius: 3px;
    pointer-events: none;
}

/* ---------- Режим «Виджет на весь экран» (фокус) ---------- */
.obs-focus-bar {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    gap: 6px;
    align-items: center;
    background: rgba(10,10,10,.85);
    border: 1px solid #2c2c2c;
    border-radius: 6px;
    padding: 4px 8px;
    box-shadow: 0 4px 18px rgba(0,0,0,.5);
}
.obs-focus-bar .obs-btn { padding: 3px 10px; font-size: 12px; }
#main-arena .grid-stack-item.obs-focus-hidden { display: none !important; }

/* Ручки свободной раскладки не «раздуваются» при увеличении виджета */
.obs-focus-active .free-move-handle {
    transform: scale(calc(1 / var(--obs-focus-scale, 1)));
    transform-origin: top right;
}
.obs-focus-active .free-resize-handle {
    transform: scale(calc(1 / var(--obs-focus-scale, 1)));
    transform-origin: bottom right;
}

/* ---------- Свойства ---------- */
#obs-props-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

#obs-shell .obs-empty {
    color: #666;
    text-align: center;
    padding: 18px 10px;
    font-size: 12px;
}

.obs-prop-header { margin-bottom: 8px; }
.obs-prop-name {
    width: 100%;
    box-sizing: border-box;
    background: #0d0d0d;
    color: #fff;
    border: 1px solid #3a3a3a;
    border-radius: 2px;
    padding: 6px 8px;
    font-size: 13px;
    font-family: inherit;
}
.obs-prop-name:focus { border-color: #137f96; outline: none; }

.obs-prop-flags { display: flex; gap: 14px; margin: 8px 0; }
.obs-prop-flag {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #ccc;
    font-size: 12px;
    cursor: pointer;
}
.obs-prop-flag input { accent-color: #137f96; width: 15px; height: 15px; cursor: pointer; }

.obs-prop-geom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 8px 0;
}
.obs-prop-num { display: flex; align-items: center; gap: 6px; color: #888; font-size: 12px; }
.obs-prop-num span { flex-shrink: 0; width: 14px; }
.obs-prop-num input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: #0d0d0d;
    color: #fff;
    border: 1px solid #3a3a3a;
    border-radius: 2px;
    padding: 4px 6px;
    font-family: inherit;
}

.obs-prop-del { width: 100%; margin-top: 6px; }

/* Ряд кнопок: дублировать / копировать / вставить */
.obs-prop-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.obs-prop-actions .obs-btn {
    flex: 1;
    padding: 4px 4px;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.obs-prop-section {
    font-size: 11px;
    text-transform: uppercase;
    color: #137f96;
    font-weight: 600;
    margin: 14px 0 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid #2c2c2c;
    letter-spacing: 0.4px;
}
.obs-prop-hint { font-size: 11px; color: #6a6a6a; margin-bottom: 8px; }

.obs-prop-field { margin-bottom: 9px; }
.obs-prop-label {
    display: block;
    font-size: 12px;
    color: #aaa;
    margin-bottom: 3px;
}
.obs-prop-input,
.obs-prop-select {
    width: 100%;
    box-sizing: border-box;
    background: #0d0d0d;
    color: #fff;
    border: 1px solid #3a3a3a;
    border-radius: 2px;
    padding: 5px 7px;
    font-size: 13px;
    font-family: inherit;
}
.obs-prop-input:focus, .obs-prop-select:focus { border-color: #137f96; outline: none; }
.obs-prop-color {
    width: 100%;
    height: 32px;
    box-sizing: border-box;
    background: #0d0d0d;
    border: 1px solid #3a3a3a;
    border-radius: 2px;
    padding: 2px;
    cursor: pointer;
}
.obs-prop-checkbox { accent-color: #137f96; width: 16px; height: 16px; cursor: pointer; }

/* Вкладки панели «Свойства» */
.obs-props-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #2c2c2c;
}
.obs-props-tab {
    flex: 1 1 auto;
    min-width: 0;
    background: #161616;
    color: #999;
    border: 1px solid #333;
    border-radius: 3px;
    padding: 4px 6px;
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.obs-props-tab:hover { background: #222; color: #ddd; }
.obs-props-tab.active {
    background: #137f96;
    border-color: #137f96;
    color: #fff;
    font-weight: 600;
}
.obs-props-tabpanel { display: none; }

/* Конструктор форм — вкладка «Поля» */
.obs-field-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 0;
    border-bottom: 1px dashed #2c2c2c;
}
.obs-field-name {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    background: #0d0d0d;
    color: #fff;
    border: 1px solid #3a3a3a;
    border-radius: 2px;
    padding: 4px 6px;
    font-size: 12px;
    font-family: inherit;
}
.obs-field-name:focus { border-color: #137f96; outline: none; }
.obs-field-type {
    flex-shrink: 0;
    font-size: 10px;
    color: #137f96;
    min-width: 24px;
    text-align: center;
}
.obs-field-btn {
    flex-shrink: 0;
    background: #161616;
    color: #ccc;
    border: 1px solid #3a3a3a;
    border-radius: 3px;
    padding: 3px 5px;
    font-size: 11px;
    cursor: pointer;
    line-height: 1;
}
.obs-field-btn:hover { background: #222; color: #fff; }
.obs-field-btn-danger { color: #ff6666; border-color: #5a2233; }
.obs-field-btn-danger:hover { background: #3a1220; color: #ff8888; }

.obs-field-add { margin-top: 10px; }
.obs-field-add-row {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}
.obs-field-add-row .obs-prop-input,
.obs-field-add-row .obs-prop-select { flex: 1; min-width: 0; }

/* Свободная раскладка (deepEditor.js): ручки перемещения/размера в превью */
.free-layout-target { outline: 1px dashed rgba(19,127,150,.4); outline-offset: 1px; }
.free-move-handle {
    position: absolute;
    top: 1px; right: 1px;
    width: 16px; height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
    background: rgba(19,127,150,.9);
    color: #fff;
    border-radius: 3px;
    cursor: move;
    user-select: none;
    z-index: 6;
    opacity: .75;
}
.free-move-handle:hover { opacity: 1; }
.free-resize-handle {
    position: absolute;
    bottom: 1px; right: 1px;
    width: 12px; height: 12px;
    border-right: 3px solid #fff;
    border-bottom: 3px solid #fff;
    background: rgba(19,127,150,.9);
    border-radius: 0 0 3px 0;
    cursor: nwse-resize;
    z-index: 6;
    opacity: .75;
}
.free-resize-handle:hover { opacity: 1; }

/* ---------- Выделение виджета в превью (как в OBS) ---------- */
#main-arena .grid-stack-item.obs-selected {
    box-shadow: 0 0 0 2px #137f96, 0 0 12px rgba(19,127,150,0.45);
    z-index: 1000 !important;
}

/* Скрытый источник */
#main-arena .grid-stack-item.gs-hidden {
    display: none !important;
}

/* ============================================================
   ГЛУБОКИЙ РЕДАКТОР ЭЛЕМЕНТОВ (deepEditor.js)
   ============================================================ */

/* Заголовок панели источников с кнопкой-переключателем */
#obs-shell .obs-header-with-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#obs-shell .obs-el-toggle {
    background: #333;
    color: #ccc;
    border: none;
    border-radius: 2px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.3;
    white-space: nowrap;
}
#obs-shell .obs-el-toggle:hover { background: #454545; color: #fff; }
#obs-shell .obs-el-toggle.obs-elements-active {
    background: #ff9900;
    color: #111;
    font-weight: 600;
}
#obs-shell .obs-el-toggle.obs-elements-active:hover { background: #ffb347; }

/* Контуры элементов в превью (inset — не режутся overflow:hidden у виджета) */
#main-arena .obs-el-hover {
    box-shadow: 0 0 0 2px rgba(255,255,255,0.8) inset, 0 0 8px rgba(255,255,255,0.35) inset !important;
}
#main-arena .obs-el-selected {
    box-shadow: 0 0 0 2px #ff9900 inset, 0 0 12px rgba(255,153,0,0.55) inset !important;
}

/* Панель элемента */
.obs-el-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.obs-el-breadcrumb .obs-btn { padding: 3px 8px; font-size: 12px; flex-shrink: 0; }
.obs-el-crumb {
    font-size: 11px;
    color: #ff9900;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.obs-el-note {
    font-size: 11px;
    color: #6a6a6a;
    margin: 8px 0;
    line-height: 1.4;
}
.obs-el-actions {
    display: flex;
    gap: 6px;
    margin: 4px 0 8px;
}
.obs-el-actions .obs-btn { flex: 1; }

/* Список удалённых элементов */
.obs-deleted-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
}
.obs-deleted-name {
    flex: 1;
    font-size: 12px;
    color: #aaa;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.obs-deleted-row .obs-btn { padding: 3px 8px; font-size: 12px; flex-shrink: 0; }


/* Fold line: dashed marker where the live page viewport ends (scroll below) */
.obs-fold-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    border-top: 2px dashed rgba(255, 204, 0, 0.85);
    z-index: 9000;
    pointer-events: none;
}
.obs-fold-label {
    position: absolute;
    right: 10px;
    top: 6px;
    font-size: 11px;
    line-height: 1.2;
    color: #ffcc00;
    background: rgba(0, 0, 0, 0.65);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    font-family: 'Segoe UI', system-ui, sans-serif;
    pointer-events: none;
}
