.layers-panel {
    position: relative !important;
    width: 260px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: visible;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.layers-panel .panel-section {
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    padding: 16px 16px 12px 16px; 
    border-bottom: 1px solid var(--border-color); 
    margin-bottom: 12px; 
}

.panel-header h3 {
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    line-height: 28px; 
}

.add-layer-btn {
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; 
}

.add-layer-btn:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-1px);
}

/* Список слоев */
.layers-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    padding: 0 16px; 
}

.layers-collapsed-preview {
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-top: 8px;
}

.layers-collapsed-preview .layer-preview-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.layers-collapsed-preview .layer-preview-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layers-panel.collapsed-panel {
    width: 72px !important;
    height: auto !important; 
    max-height: 80px !important; 
    position: absolute !important;
    right: 0 !important;
    top: 50% !important; 
    transform: translateY(-50%) !important; 
    border-radius: 12px 0 0 12px !important; 
    overflow: visible !important; 
    border: 1px solid var(--border-color) !important;
    border-right: none !important; 
    box-shadow: -1px 2px 8px rgba(0, 0, 0, 0.15) !important; 
    z-index: 99 !important;
    background: var(--bg-primary) !important; 
}

.layers-panel.collapsed-panel .panel-section {
    padding: 12px 0 !important; 
    height: 100% !important;
    min-height: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    display: flex !important;
    border: none !important; 
    background: transparent !important;
    overflow: hidden !important; 
    border-radius: 12px 0 0 12px !important; 
}

.layers-panel.collapsed-panel .layers-list {
    display: flex !important;
    overflow: visible !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: auto !important;
    background: transparent !important;
}

.layers-panel.collapsed-panel .panel-header,
.layers-panel.collapsed-panel .layers-collapsed-preview {
    display: none !important;
}

.layers-panel.collapsed-panel .layer-item {
    display: none !important;
}

.layers-panel.collapsed-panel .layer-item.active {
    display: flex !important; 
    justify-content: center !important;
    align-items: center !important;
    width: 48px !important;
    height: 48px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    transform: none !important;
    background: var(--bg-tertiary) !important;
    border: 1px solid var(--border-color) !important;
}

.layers-panel.collapsed-panel .layer-item.active .layer-info,
.layers-panel.collapsed-panel .layer-item.active .layer-actions,
.layers-panel.collapsed-panel .layer-item.active .layer-type {
    display: none !important;
}

.layers-panel.collapsed-panel .layer-item.active .layer-thumbnail {
    width: 40px !important;
    height: 40px !important;
    margin: 0 !important;
    display: block !important;
    border-radius: 4px !important;
}

.hidden {
    display: none !important;
}

.right-panel-tail {
    position: absolute;
    top: 50%;
    left: -24px; /* Сдвигаем влево, чтобы кнопка торчала наружу из панели */
    transform: translateY(-50%);
    width: 24px;
    height: 50px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-right: none; /* Убираем правую границу, так как она прижата к панели */
    border-radius: 8px 0 0 8px; /* Скругляем только левые углы */
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease, left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.right-panel-tail:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.right-panel-tail i, 
.left-panel-tail i {
    transition: transform 0.3s ease;
}

.layers-panel.collapsed-panel .right-panel-tail {
    display: flex !important;
    height: 40px !important; 
    border-radius: 6px 0 0 6px !important; 
    left: -20px !important; 
    z-index: 100 !important;
}
/* Стилизация скроллбара */
.layers-list::-webkit-scrollbar {
    width: 6px;
}

.layers-list::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.layers-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.layers-list::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Элемент слоя */
.layer-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    user-select: none;
    gap: 8px;
}

.layer-item:hover {
    background: #3a3a3a;
    transform: translateX(2px);
}

.layer-item.active {
    background: var(--accent);
    border-color: var(--accent-hover);
    box-shadow: 0 2px 8px var(--accent-shadow);
}

.layer-item.active .layer-name {
    color: white;
}

/* Thumbnail слоя - мини превью содержимого */
.layer-thumbnail {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background-color: #222;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.5);
    transition: all 0.2s;
}

.layer-item:hover .layer-thumbnail {
    transform: scale(1.05);
    border-color: var(--accent);
}

.layer-item.active .layer-thumbnail {
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 8px rgba(74, 144, 226, 0.5);
}

.layer-type {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.layer-type i {
    font-size: 8px;
}

/* Информация о слое */
.layer-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Для обрезки текста */
}

.layer-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Действия со слоем */
.layer-actions {
    display: flex;
    gap: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.layer-item:hover .layer-actions {
    opacity: 1;
}

.layer-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.layer-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.layer-item.active .layer-actions button {
    color: rgba(255, 255, 255, 0.9);
}

.layer-item.active .layer-actions button:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Индикатор видимости */
.layer-visibility.visible {
    color: var(--accent);
}

.layer-item.active .layer-visibility.visible {
    color: white;
}

/* Перетаскивание слоев */
.layer-item.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.layer-item.drag-over {
    border-top: 2px solid var(--accent);
}

/* Пустое состояние */
.empty-layers {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    text-align: center;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    margin: 20px 0;
}

.empty-layers i {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-layers p {
    font-size: 13px;
    opacity: 0.7;
}

/* Адаптивность */
@media (max-width: 768px) {
    .layers-panel {
        width: 220px;
    }
    
    .layer-name {
        font-size: 12px;
    }
    
    .layer-actions {
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .layers-panel {
        display: none;
    }
}