/**
 * =========================================================
 * Tutorial Studio
 * Layers Panel
 *
 * 文件：css/main/sidebar/layers_panel.css
 *
 * 图层树、显隐 / 锁定操作、重命名、
 * 拖动排序和右键菜单。
 * =========================================================
 */

#sidebarLayerList.layers-list {
    padding: 6px 8px 16px;

    overflow-x: hidden;
    overflow-y: auto;

    overscroll-behavior: contain;
}

.layers-count {
    display: inline-grid;
    place-items: center;

    min-width: 20px;
    height: 18px;

    padding: 0 5px;

    border-radius: 999px;

    background: #eef2ff;

    color: #4338ca;

    font-size: 10px;
    font-weight: 750;

    white-space: nowrap;
}

.layers-panel-head .panel-head-actions {
    display: flex;
    align-items: center;

    gap: 3px;
}

.layers-panel-head .panel-icon-btn svg {
    display: block;

    transition: transform .16s ease;
}

.layers-panel-head .panel-icon-btn.is-expand-all svg {
    transform: rotate(180deg);
}

.layers-panel-head .panel-icon-btn:disabled {
    opacity: .35;

    cursor: default;
}


/* =========================================================
   01. 搜索
========================================================= */

#sidebarLayerSearch {
    box-sizing: border-box;

    display: block;

    width: calc(100% - 16px);
    height: 32px;

    margin: 8px;

    padding: 0 10px;

    border: 1px solid #dbe2ea;
    border-radius: 8px;

    outline: none;

    background: #f8fafc;

    color: #1e293b;

    font: inherit;
    font-size: 12px;

    transition:
        border-color .16s ease,
        background .16s ease,
        box-shadow .16s ease;
}

#sidebarLayerSearch::placeholder {
    color: #94a3b8;
}

#sidebarLayerSearch:focus {
    border-color: #a5b4fc;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgb(99 102 241 / 12%);
}


/* =========================================================
   02. 图层树
========================================================= */

.layers-node {
    min-width: 0;
}

.layers-children {
    min-width: 0;
}

.layers-row {
    position: relative;

    display: grid;
    grid-template-columns:
        18px minmax(0, 1fr) auto;

    align-items: center;

    gap: 1px;

    min-width: 0;
    min-height: 30px;

    margin-bottom: 1px;

    padding:
        0 2px 0 calc(var(--layer-depth, 0) * 14px + 2px);

    border-radius: 7px;

    color: #334155;

    user-select: none;
    -webkit-user-select: none;

    transition:
        background-color .14s ease,
        box-shadow .14s ease,
        opacity .14s ease;
}

.layers-row:hover {
    background: #f1f5f9;
}

.layers-row.is-selected {
    background:
        linear-gradient(90deg, #eef2ff, #f5f3ff);

    box-shadow:
        inset 2px 0 0 #6366f1;
}

.layers-row.is-hidden {
    opacity: .55;
}

.layers-row.is-locked .layers-item-label,
.layers-row.is-lock-inherited .layers-item-label {
    color: #64748b;
}

.layers-row.is-dragging {
    opacity: .35;
}

.layers-row.drop-before::before,
.layers-row.drop-after::after {
    content: '';

    position: absolute;
    left: calc(var(--layer-depth, 0) * 14px + 20px);
    right: 4px;

    z-index: 3;

    height: 2px;

    border-radius: 2px;

    background: #6366f1;

    box-shadow:
        0 0 0 2px rgba(99, 102, 241, .15);
}

.layers-row.drop-before::before {
    top: -2px;
}

.layers-row.drop-after::after {
    bottom: -2px;
}

.layers-row.is-denied {
    animation:
        layers-denied .38s ease;
}

@keyframes layers-denied {
    0%, 100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-3px);
    }

    65% {
        transform: translateX(3px);
    }
}


/* =========================================================
   03. 展开按钮
========================================================= */

.layers-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 18px;
    height: 24px;

    padding: 0;

    border: 0;
    border-radius: 4px;

    background: transparent;

    color: #94a3b8;

    cursor: pointer;
}

.layers-toggle:hover:not(:disabled) {
    background: #e2e8f0;

    color: #475569;
}

.layers-toggle:disabled {
    opacity: .2;

    cursor: default;
}

.layers-toggle .layers-chevron {
    width: 12px;
    height: 12px;

    transition: transform .16s ease;
}

.layers-toggle.is-expanded .layers-chevron {
    transform: rotate(90deg);
}


/* =========================================================
   04. 图层内容
========================================================= */

.layers-item {
    display: flex;
    align-items: center;

    gap: 7px;

    min-width: 0;
    height: 26px;

    padding: 0 4px;

    border: 0;
    border-radius: 5px;

    background: transparent;

    color: inherit;

    font: inherit;

    text-align: left;

    cursor: pointer;
}

.layers-item:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: -1px;
}

.layers-item-icon {
    display: inline-flex;
    flex: 0 0 16px;
    align-items: center;
    justify-content: center;

    width: 16px;
    height: 16px;

    color: #7c8aa0;
}

.layers-type-icon {
    width: 14px;
    height: 14px;
}

.layers-row.is-selected .layers-item-icon {
    color: #4f46e5;
}

.layers-item-label {
    display: block;
    flex: 1;

    min-width: 0;

    overflow: hidden;

    color: inherit;

    font-size: 12px;
    line-height: 1.5;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.layers-row.is-selected .layers-item-label {
    color: #3730a3;

    font-weight: 650;
}


/* =========================================================
   05. 行操作：显隐 / 锁定
========================================================= */

.layers-row-actions {
    display: flex;
    align-items: center;

    gap: 1px;

    padding-right: 1px;
}

.layers-row-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 22px;
    height: 22px;

    padding: 0;

    border: 0;
    border-radius: 5px;

    background: transparent;

    color: #94a3b8;

    opacity: 0;

    cursor: pointer;

    transition:
        opacity .14s ease,
        background .14s ease,
        color .14s ease;
}

.layers-action-icon {
    width: 13px;
    height: 13px;
}

/*
 * 眼睛图标保持低透明度常驻，便于发现；
 * 锁定图标只在悬停或已锁定时显示。
 */
.layers-row-action[data-layer-action="visibility"] {
    opacity: .45;
}

.layers-row:hover .layers-row-action,
.layers-row:focus-within .layers-row-action,
.layers-row.is-hidden
.layers-row-action[data-layer-action="visibility"],
.layers-row.is-locked
.layers-row-action[data-layer-action="lock"],
.layers-row.is-lock-inherited
.layers-row-action[data-layer-action="lock"] {
    opacity: 1;
}

.layers-row-action:hover:not(:disabled) {
    background: #e2e8f0;

    color: #334155;
}

.layers-row-action.is-active {
    color: #4f46e5;
}

.layers-row.is-locked
.layers-row-action[data-layer-action="lock"],
.layers-row.is-lock-inherited
.layers-row-action[data-layer-action="lock"] {
    color: #d97706;
}

.layers-row-action:disabled {
    opacity: .35;

    cursor: default;
}

.layers-row-action:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 1px;
}


/* =========================================================
   06. 重命名
========================================================= */

.layers-row.is-renaming {
    background: #eef2ff;
}

.layers-rename-input {
    width: 100%;
    min-width: 0;
    height: 24px;

    padding: 0 6px;

    border: 1px solid #818cf8;
    border-radius: 5px;

    outline: none;

    background: #ffffff;

    color: #1e293b;

    font: inherit;
    font-size: 12px;

    box-shadow: 0 0 0 3px rgb(99 102 241 / 14%);
}


/* =========================================================
   07. 右键菜单
========================================================= */

.layers-context-menu {
    position: fixed;

    z-index: 1000002;

    min-width: 178px;

    padding: 5px;

    border: 1px solid #e5e7eb;
    border-radius: 10px;

    background: #ffffff;

    color: #1f2937;

    box-shadow:
        0 16px 40px rgba(15, 23, 42, .18);
}

.layers-context-menu[hidden] {
    display: none !important;
}

.layers-context-item {
    display: flex;
    width: 100%;
    align-items: center;

    gap: 10px;

    padding: 7px 9px;

    border: 0;
    border-radius: 6px;

    background: transparent;

    color: inherit;

    font: inherit;
    font-size: 12px;

    text-align: left;

    cursor: pointer;
}

.layers-context-item:hover:not(:disabled) {
    background: #f1f5f9;
}

.layers-context-item:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: -2px;
}

.layers-context-item:disabled {
    opacity: .4;

    cursor: default;
}

.layers-context-item.is-danger {
    color: #c2414f;
}

.layers-context-item.is-danger:hover:not(:disabled) {
    background: #fef2f2;
}

.layers-context-label {
    flex: 1;
}

.layers-context-shortcut {
    color: #94a3b8;

    font-size: 10px;
}

.layers-context-separator {
    height: 1px;

    margin: 4px 6px;

    background: #eef1f5;
}


/* =========================================================
   08. 空状态
========================================================= */

#sidebarLayerList .sidebar-empty {
    padding: 30px 12px;

    color: #64748b;

    font-size: 12px;
    line-height: 1.8;

    text-align: center;
}


/* =========================================================
   09. 响应式 / 触屏 / 减少动态效果
========================================================= */

@media (max-width: 768px) {
    #sidebarLayerList.layers-list {
        padding: 4px 6px 12px;
    }

    .layers-row {
        min-height: 34px;
    }

    .layers-item {
        height: 30px;
    }

    .layers-row-action {
        width: 24px;
        height: 24px;

        opacity: 1;
    }

    #sidebarLayerSearch {
        height: 36px;
    }
}

@media (hover: none) {
    .layers-row-action {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .layers-row,
    .layers-toggle .layers-chevron,
    .layers-row-action,
    .layers-panel-head .panel-icon-btn svg {
        transition: none;
    }

    .layers-row.is-denied {
        animation: none;
    }
}
